Skip to main content

No project description provided

Project description

cwl-utils

A collection of scripts to demonstrate the use of the new Python classes for loading and parsing CWL v1.0 , CWL v1.1, and CWL v1.2 documents.

Install

Requires Python 3.6+

virtualenv -p python3.6 venv3.6  # Python 3.7, 3.8, or 3.9 would also work
source venv3.6/bin/activate
pip install cwl-utils

or install the latest development version of cwl-utils

git clone https://github.com/common-workflow-language/cwl-utils.git
cd cwl-utils
virtualenv -p python3.6 venv3.6  # Python 3.7, 3.8, or 3.9 would also work
source venv3.6/bin/activate
pip install .

Usage

Pull the all referenced software container images

docker_extract.py 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.

python docker_extract.py 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.

python docker_extract.py --singularity DIRECTORY path_to_my_workflow.cwl

Using the CWL Parsers

# Imports
from pathlib import Path
from ruamel import yaml
import sys

# File Input - This is the only thing you will need to adjust or take in as an input to your function:
cwl_file = Path("/path/to/wf.cwl")

# Read in the cwl file from a yaml
with open(cwl_file, "r") as cwl_h:
 yaml_obj = yaml.main.round_trip_load(cwl_h, preserve_quotes=True)

# Check CWLVersion
if 'cwlVersion' not in list(yaml_obj.keys()):
    print("Error - could not get the cwlVersion")
    sys.exit(1)

# Import parser based on CWL Version    
if yaml_obj['cwlVersion'] == 'v1.0':
    from cwl_utils import parser_v1_0 as parser
elif yaml_obj['cwlVersion'] == 'v1.1':
    from cwl_utils import parser_v1_1 as parser
elif yaml_obj['cwlVersion'] == 'v1.2':
    from cwl_utils import parser_v1_2 as parser
else:
    print("Version error. Did not recognise {} as a CWL version".format(yaml_obj["CWLVersion"]))
    sys.exit(1)

# Import CWL Object
cwl_obj = parser.load_document_by_yaml(yaml_obj, cwl_file.as_uri())

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

Development

Regenerate parsers

To regenerate install the schema_salad package and run:

cwl_utils/parser_v1_0.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/main/v1.0/CommonWorkflowLanguage.yml

cwl_utils/parser_v1_1.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/main/CommonWorkflowLanguage.yml

cwl_utils/parser_v1_2.py was created via schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/main/CommonWorkflowLanguage.yml

Release

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cwl-utils-0.11.tar.gz (170.1 kB view details)

Uploaded Source

Built Distribution

cwl_utils-0.11-py3-none-any.whl (194.6 kB view details)

Uploaded Python 3

File details

Details for the file cwl-utils-0.11.tar.gz.

File metadata

  • Download URL: cwl-utils-0.11.tar.gz
  • Upload date:
  • Size: 170.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for cwl-utils-0.11.tar.gz
Algorithm Hash digest
SHA256 110be87f8c27041d7a728b99341549a4c498f6695c7b4a463b3f8528f02910fc
MD5 271cb6805a505510ce26b6d717119085
BLAKE2b-256 54932153b39e57e6a4e9754439fd70be4ca70dd2122a0aca443934b0d85e3127

See more details on using hashes here.

Provenance

File details

Details for the file cwl_utils-0.11-py3-none-any.whl.

File metadata

  • Download URL: cwl_utils-0.11-py3-none-any.whl
  • Upload date:
  • Size: 194.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for cwl_utils-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8172d1856ac407d5e7a7d6e83d150904c8f03350420cf32a3ffd26bfa92f123e
MD5 029398eb0cd0b4d1587ce50739f1d095
BLAKE2b-256 56ef57f39759ba679f7111cbbad4bedcf0f6f0d9d0aef7808a472457e2642941

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page