Complex CWL types¶
Follow below an example to demonstrate how the library handles and convert a CWL where inputs are declared with hybrid types.
1. Parsing¶
In this sample we'll show the access from a remote public URL.
In [1]:
Copied!
from cwl_loader import load_cwl_from_location
from cwl2ogc import BaseCWLtypes2OGCConverter
cwl_document = load_cwl_from_location(
"https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl"
)
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
from cwl_loader import load_cwl_from_location
from cwl2ogc import BaseCWLtypes2OGCConverter
cwl_document = load_cwl_from_location(
"https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl"
)
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 2 1 from cwl_loader import load_cwl_from_location ----> 2 from cwl2ogc import BaseCWLtypes2OGCConverter 3 4 cwl_document = load_cwl_from_location( 5 "https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl" ModuleNotFoundError: No module named 'cwl2ogc'
3. Inputs conversion¶
Once the document is parsed, invoke the cwl2ogc APIs to convert the CWL inputs to the OGC JSON format:
In [2]:
Copied!
import sys
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
import sys
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[2], line 3 1 import sys 2 ----> 3 cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True) NameError: name 'cwl_converter' is not defined
2. Outputs conversion¶
Users can reuse the BaseCWLtypes2OGCConverter instance to convert the CWL outputs to the OGC JSON format:
In [3]:
Copied!
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[3], line 1 ----> 1 cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True) NameError: name 'cwl_converter' is not defined