Package: cwl-utils
cwl-utilsPython Utilities and Autogenerated Classes for loading and parsingCWL
v1.0,CWL
v1.1,
andCWL
v1.2documents.Requires Python 3.8+Installationpip3 install cwl-utilsTo install from source:git clone https://github.com/common-workflow-language/cwl-utils.git
cd cwl-utils
pip3 install .UsagePull the all referenced software container imagescwl-docker-extractis 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-extractpath_to_my_workflow.cwlcwl-docker-extract--dirDIRECTORYpath_to_my_workflow.cwlOr 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--dirDIRECTORYpath_to_my_workflow.cwlPrint all referenced software packagescwl-cite-extractprints all software packages found (recursively) in the
specified CWL document.Currently the package name and any listed specs and version field are printed
for allSoftwareRequirements found.cwl-cite-extractpath_to_my_workflow.cwlReplace CWL Expressions with concrete stepscwl-expression-refactorrefactors 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
optionalInlineJavascriptRequirementat all.cwl-expression-refactordirectory/path/to/save/outputspath_to_my_workflow.cwl[more_workflows.cwl]Split a packed CWL documentcwl-graph-splitsplits 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--outdiroptional/directory/path/to/save/outputspath_to_my_workflow.cwlNormalize a CWL documentcwl-normalizernormalizes 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-normalizerdirectory/path/to/save/outputspath_to_my_workflow.cwl[more_workflows.cwl]Using the CWL ParsersfrompathlibimportPathfromruamelimportyamlimportsysfromcwl_utils.parserimportload_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 Objectcwl_obj=load_document_by_uri(cwl_file)# View CWL Objectprint("List of object attributes:\n{}".format("\n".join(map(str,dir(cwl_obj)))))# Export CWL Object into a built-in typed objectsaved_obj=save(cwl_obj)print(f"Export of the loaded CWL object:{saved_obj}.")DevelopmentRegenerate parsersTo regenerate install theschema_saladpackage and run:cwl_utils/parser/cwl_v1_0.pywas created viaschema-salad-tool--codegenpythonhttps://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml--codegen-parser-info"org.w3id.cwl.v1_0" > cwl_utils/parser/cwl_v1_0.pycwl_utils/parser/cwl_v1_1.pywas created viaschema-salad-tool--codegenpythonhttps://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml--codegen-parser-info"org.w3id.cwl.v1_1" > cwl_utils/parser/cwl_v1_1.pycwl_utils/parser/cwl_v1_2.pywas created viaschema-salad-tool--codegenpythonhttps://github.com/common-workflow-language/cwl-v1.2/raw/1.2.1_proposed/CommonWorkflowLanguage.yml--codegen-parser-info"org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.pyReleaseTo release CWLUtils, bump the version incwl_utils/__meta__.py, and
tag that commit with the new version. Thegh-action-pypi-publishshould release that tag.