Open nyue opened 3 years ago
Hi @nyue, this issue on cwlgen has a rough guide on how cwl-utils can be used to generate CWL: https://github.com/common-workflow-lab/python-cwlgen/issues/27
In essence, you can do something like the following:
import cwl_utils.parser_v1_2 as cwl
clt = cwl.CommandLineTool(
# eg: keys from https://github.com/common-workflow-language/cwl-utils/blob/c7308efbbbd4d64f5d479f27bf46ca6041cfb7b2/cwl_utils/parser_v1_2.py#L7000-L7021
id="mytoolid",
inputs=[
cwl. CommandInputParameter(**fields)
]
)
dict_representation = clt.save()
Thanks Michael. I am making some progress.
After the call to save() [I get a dictionary], what calls/method is there to write that out to a CWL file I can test with cwltool/cromwell ?
Cheers
This is a rough excerpt of the code I've used in the past:
def convert_tool_to_yaml(tool):
# Convert dict to YAML
import ruamel.yaml
yaml = ruamel.yaml.YAML()
tool_dict = tool.save()
io = StringIO()
yaml.dump(tool_dict, io)
return io.getvalue()
Thank you, got it writing out CWL/YAML file.
Glad you found a solution! I'm reopening this to remind us to improve the docs
This issue has been mentioned on Common Workflow Language Discourse. There might be relevant details there:
https://cwl.discourse.group/t/how-to-implement-a-reduce-method-in-cwl/294/3
This was super helpful.
I am looking at the possibility of using cwl-utils to generate CWL files programmatically in Python
I discover cwl-utils when browsing python-cwlgen
I am hoping to find example that illustrate how CommandLineTool and CommandInputParameter should be put together via cwl-utils
I have not found any examples thus far.
Cheers