cwlgen export functionality
JoanaFMorgado opened this issue · comments
Joana F. Morgado commented
Hello,
I would like to know if cwl-utils provides a method such as export that enables the generation of a CWL file from python Classes?
It would be useful and I am not able to currently find it within cwl-utils.
Many thanks!
Kind Regards,
Joana
Michael Franklin commented
Hey Joanna, you can!
Every cwl object has a .save()
method which will convert it to dictionary which you could write with ruamel.yaml.
For example:
from io import StringIO
import ruamel.yaml
yaml = ruamel.yaml.YAML()
def convert_cwl_object_to_string(cwlobj: cwlgen.Savable):
dict_object: dict = cwlobj.save()
io = StringIO()
yaml.dump(m, io)
return io.getvalue()