Load/parse cwl in python
2
0
Entering edit mode
6.0 years ago
johnegarza • 0

Hello,

I have been working with cwl a lot recently, and found myself needing to parse cwl documents within python for various tasks. Is there an existing simple library or tool to load cwl into a format that can be easily manipulated within python (ideally a dictionary or dictionary-like structure), rather than writing code to parse it myself each time? I'm generally only working with one file at a time, just trying to grab a list of inputs, outputs + metadata, etc. I know there are implementations like cwltool in python, but these are large and complicated, and lacking in documentation for tasks as simple as mine.

cwl • 2.3k views
ADD COMMENT
2
Entering edit mode
6.0 years ago

You can use pyyaml.
Install with pip install pyyaml

Load a CWL (which can be in JSON or YAML format) using

with open(cwl_file_path, 'r') as cwl_file:  
    cwl_dict = yaml.safe_load(cwl_file)

This will return a python dict with all the fields.

ADD COMMENT
2
Entering edit mode
6.0 years ago

There's a new Python 3.6/3.7 method of accessing CWL documents, but you get full objects (with doc strings copied from the spec), not dictionaries: https://github.com/common-workflow-language/cwl-utils

ADD COMMENT

Login before adding your answer.

Traffic: 1159 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6