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

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 • 958 views
ADD COMMENTlink modified 19 months ago by Michael R. Crusoe1.8k • written 20 months ago by johnegarza0
2
gravatar for bogdan.gavrilovic
19 months ago by
bogdan.gavrilovic230 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 19 months ago • written 19 months ago by bogdan.gavrilovic230
2
gravatar for Michael R. Crusoe
19 months ago by
Common Workflow Language project
Michael R. Crusoe1.8k 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: https://github.com/common-workflow-language/cwl-utils

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

Help
Access

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