Skip to main content

Linux Build Status Code coverage Documentation Status

cwl-utils

Python Utilities and Autogenerated Classes for loading and parsing CWL v1.0, CWL v1.1, and CWL v1.2 documents.

Requires Python 3.8+

Installation

pip3 install cwl-utils

To install from source:

git clone https://github.com/common-workflow-language/cwl-utils.git
cd cwl-utils
pip3 install .

Usage

Pull the all referenced software container images

cwl-docker-extract is useful to cache or pre-pull all software container images referenced in a CWL CommandLineTool or CWL Workflow (including all referenced CommandLineTools and sub-Workflows and so on).

The default behaviour is to use the Docker engine to download and save the software container images in Docker format.

cwl-docker-extract path_to_my_workflow.cwl
cwl-docker-extract --dir DIRECTORY path_to_my_workflow.cwl

Or you can use the Singularity software container engine to download and save the software container images and convert them to the Singularity format at the same time.

cwl-docker-extract --singularity --dir DIRECTORY path_to_my_workflow.cwl

Print all referenced software packages

cwl-cite-extract prints all software packages found (recursively) in the specified CWL document.

Currently the package name and any listed specs and version field are printed for all SoftwareRequirement s found.

cwl-cite-extract path_to_my_workflow.cwl

Replace CWL Expressions with concrete steps

cwl-expression-refactor refactors CWL documents so that any CWL Expression evaluations are separate steps (either CWL ExpressionTools or CWL CommandLineTools.) This allows execution by CWL engines that do not want to support inline expression evaluation outside of concrete steps, or do not want to directly support CWL’s optional InlineJavascriptRequirement at all.

cwl-expression-refactor directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]

Split a packed CWL document

cwl-graph-split splits a packed CWL document file into multiple files.

Packed CWL documents use the $graph construct to contain multiple CWL Process objects (Workflow, CommandLineTool, ExpressionTool, Operation). Typically packed CWL documents contain a CWL Workflow under the name “main” and the workflow steps (including any sub-workflows).

cwl-graph-split --outdir optional/directory/path/to/save/outputs path_to_my_workflow.cwl

Pack a CWL document

cwl-pack packs a CWL document and all of its referenced documents into a single JSON document. Unlike cwl-normalizer, cwl-pack does not upgrade the CWL version and does not refactor expressions; it is a thin CLI wrapper around cwl_utils.pack.pack().

cwl-pack path_to_my_workflow.cwl
cwl-pack --outfile packed.json path_to_my_workflow.cwl

Normalize a CWL document

cwl-normalizer normalizes one or more CWL document so that for each document, a JSON format CWL document is produces with it and all of its dependencies packed together, upgrading to CWL v1.2, as needed. Can optionally refactor CWL Expressions into separate steps in the manner of cwl-expression-refactor.

cwl-normalizer directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]

Generate for Workflow Parameters from a CWL document

cwl-inputs-schema-gen generates a JSON Schema for workflow input parameters from a CWL document.

cwl-inputs-schema-gen path_to_my_workflow.cwl

Using the CWL Parsers

from pathlib import Path
from ruamel import yaml
import sys

from cwl_utils.parser import load_document_by_uri, save

# File Input - This is the only thing you will need to adjust or take in as an input to your function:
cwl_file = Path("testdata/md5sum.cwl")  # or a plain string works as well

# Import CWL Object
cwl_obj = load_document_by_uri(cwl_file)

# View CWL Object
print("List of object attributes:\n{}".format("\n".join(map(str, dir(cwl_obj)))))

# Export CWL Object into a built-in typed object
saved_obj = save(cwl_obj)
print(f"Export of the loaded CWL object: {saved_obj}.")

Choosing a JavaScript engine

CWL expressions are evaluated with QuickJS when a usable qjs executable is found on the PATH, and with Node.js otherwise (falling back to a node:slim software container if Node.js is not installed either). QuickJS starts quickly enough that every evaluation runs in its own short-lived subprocess; there is no software container fallback for QuickJS. Setting the CWL_JS_ENGINE environment variable to node or quickjs forces a specific engine.

A specific engine can also be installed programmatically, which takes precedence over CWL_JS_ENGINE:

from cwl_utils.sandboxjs import QuickJSEngine, set_js_engine

set_js_engine(QuickJSEngine())

Development

Regenerate parsers

To regenerate install the schema_salad package and run:

cwl_utils/parser/cwl_v1_0.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_0" > cwl_utils/parser/cwl_v1_0.py

cwl_utils/parser/cwl_v1_1.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_1" > cwl_utils/parser/cwl_v1_1.py

cwl_utils/parser/cwl_v1_2.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.py

Release

To release CWLUtils, bump the version in src/cwl_utils/__meta__.py, and tag that commit with the new version. The gh-action-pypi-publish should release that tag.

Metadata

Release files for cwl-utils 0.47

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cwl-utils 0.47
File Size Uploaded Provenance Actions
cwl_utils-0.47.tar.gz 386.2 kB With provenance Details for cwl_utils-0.47.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cwl-utils 0.47
File Interpreter ABI Platform Actions
cwl_utils-0.47-py3-none-any.whl Python 3 none any Details for cwl_utils-0.47-py3-none-any.whl

Total release size: 835.3 kB

Release files / cwl_utils-0.47.tar.gz

Download URL cwl_utils-0.47.tar.gz
Size 386.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb077afc7265c7549ee847b778bcfa85315dffcf4cfc4e1210e19bf89154eb60
BLAKE2b-256 checksum
How to use checksums
18bba937be7aad624c7e2db4111508cd107d3a54e29631cc7392fd968c61c245
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / cwl_utils-0.47-py3-none-any.whl

Download URL cwl_utils-0.47-py3-none-any.whl
Size 449.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45dce3efbb5294eea726b2eea0e7de88f06b36efae5c8a14ceccbcc180dc2608
BLAKE2b-256 checksum
How to use checksums
82da4bcde26797e576da7a68c65e15f0246611931e1c50d96fa7fb9866910f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for cwl-utils 0.47

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cwl_utils-0.47.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.47 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page