Question: Load/parse cwl in python
gravatar for johnegarza
9 months ago by
johnegarza0 wrote:


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 • 508 views
ADD COMMENTlink modified 8 months ago by Michael R. Crusoe1.6k • written 9 months ago by johnegarza0
gravatar for bogdan.gavrilovic
9 months ago by
bogdan.gavrilovic210 wrote:

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 COMMENTlink modified 9 months ago • written 9 months ago by bogdan.gavrilovic210
gravatar for Michael R. Crusoe
8 months ago by
Common Workflow Language project
Michael R. Crusoe1.6k wrote:

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:

ADD COMMENTlink written 8 months ago by Michael R. Crusoe1.6k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1131 users visited in the last hour