Unable to export a workflow if the workflow was imported with requirements
mattdoug604 opened this issue · 2 comments
mattdoug604 commented
Hi, I'm trying to import an existing workflow, make a few edits, then export it to a new file, but I run into an error if the original workflow lists any requirements.
The workflow being imported looks like this:
class: Workflow
cwlVersion: v1.0
label: joint calling workflow
doc: Perform joint calling on multiple sets aligned reads from the same family.
requirements:
- class: MultipleInputFeatureRequirement
- class: StepInputExpressionRequirement
- class: SubworkflowFeatureRequirement
inputs:
...
Example:
>>> import cwlgen
>>> cwl = cwlgen.import_cwl.parse_cwl("/path/to/workflow.cwl")
>>> cwl.export()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/python/lib/python3.7/site-packages/cwlgen/workflow.py", line 97, in export
rep = self.export_string()
File "/python/lib/python3.7/site-packages/cwlgen/workflow.py", line 90, in export_string
cwl_tool = self.get_dict()
File "/python/lib/python3.7/site-packages/cwlgen/workflow.py", line 84, in get_dict
cwl_workflow['requirements'] = {r.get_class(): r.get_dict() for r in self.requirements}
File "/python/lib/python3.7/site-packages/cwlgen/workflow.py", line 84, in <dictcomp>
cwl_workflow['requirements'] = {r.get_class(): r.get_dict() for r in self.requirements}
AttributeError: 'dict' object has no attribute 'get_dict'
Seems like this is because the requirements get parsed into a simple dict:
>>> vars(cwl)
{..., 'requirements': [{'class': 'MultipleInputFeatureRequirement'}, {'class': 'StepInputExpressionRequirement'}, {'class': 'SubworkflowFeatureRequirement'}]}
illusional commented
Hey @mattdoug604, I was able to replicate your issue and you're correct it wasn't parsing the Requirement types. I've got a PR here (#26) that adds support for (almost) every Requirement (except SchemaDefRequirement).
I'll ask the community to review the PR, but you should be able to checkout my code through the PR.
I'll leave this issue open until the changes are merged and released.
mattdoug604 commented
Thanks!