Inclusive and Exclusive Inputs¶
Inclusive and Exclusive Inputs refers to the 2.4.3. Inclusive and Exclusive Inputs paragraph of the 2.4. Inputs chapter of the Common Workflow Language User Guide.
It shows also how the library is able to handle and convert record 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/eoap/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/record.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/eoap/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/record.cwl')
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
2025-11-06 22:55:11.594 | DEBUG | cwl_loader:load_cwl_from_location:228 - Loading CWL document from https://raw.githubusercontent.com/eoap/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/record.cwl...
2025-11-06 22:55:11.720 | DEBUG | cwl_loader:_load_cwl_from_stream:231 - Reading stream from https://raw.githubusercontent.com/eoap/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/record.cwl...
2025-11-06 22:55:11.728 | DEBUG | cwl_loader:load_cwl_from_stream:203 - CWL data of type <class 'ruamel.yaml.comments.CommentedMap'> successfully loaded from stream
2025-11-06 22:55:11.729 | DEBUG | cwl_loader:load_cwl_from_yaml:143 - No needs to update the Raw CWL document since it targets already the v1.2
2025-11-06 22:55:11.729 | DEBUG | cwl_loader:load_cwl_from_yaml:145 - Parsing the raw CWL document to the CWL Utils DOM...
2025-11-06 22:55:11.898 | DEBUG | cwl_loader:load_cwl_from_yaml:158 - Raw CWL document successfully parsed to the CWL Utils DOM!
2025-11-06 22:55:11.899 | DEBUG | cwl_loader:load_cwl_from_yaml:160 - Dereferencing the steps[].run...
2025-11-06 22:55:11.899 | DEBUG | cwl_loader:load_cwl_from_yaml:167 - steps[].run successfully dereferenced! Dereferencing the FQNs...
2025-11-06 22:55:11.900 | DEBUG | cwl_loader:load_cwl_from_yaml:171 - CWL document successfully dereferenced! Now verifying steps[].run integrity...
2025-11-06 22:55:11.901 | DEBUG | cwl_loader:load_cwl_from_yaml:175 - All steps[].run link are resolvable!
2025-11-06 22:55:11.902 | DEBUG | cwl_loader:load_cwl_from_yaml:178 - Sorting Process instances by dependencies....
2025-11-06 22:55:11.902 | DEBUG | cwl_loader:load_cwl_from_yaml:180 - Sorting process is over.
2025-11-06 22:55:11.903 | DEBUG | cwl_loader:_load_cwl_from_stream:240 - Stream from https://raw.githubusercontent.com/eoap/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/record.cwl successfully load!
2. 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)
{
"dependent_parameters": {
"schema": {
"type": "object",
"properties": {
"itemA": {
"type": "string"
},
"itemB": {
"type": "string"
}
},
"required": [
"itemA",
"itemB"
]
},
"metadata": [
{
"title": "cwl:type",
"value": "record"
}
],
"minOccurs": 1,
"maxOccurs": 1,
"valuePassing": "byValue",
"title": "dependent_parameters label",
"description": "dependent_parameters doc"
},
"exclusive_parameters": {
"schema": {
"nullable": false,
"anyOf": [
{
"type": "object",
"properties": {
"itemC": {
"type": "string"
}
},
"required": [
"itemC"
]
},
{
"type": "object",
"properties": {
"itemD": {
"type": "string"
}
},
"required": [
"itemD"
]
}
]
},
"metadata": [
{
"title": "cwl:type",
"value": "[ record, record ]"
}
],
"minOccurs": 1,
"maxOccurs": 1,
"valuePassing": "byValue",
"title": "dependent_parameters label",
"description": "dependent_parameters doc"
}
}
3. 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)
{
"example_out": {
"schema": {
"type": "string"
},
"metadata": [
{
"title": "cwl:type",
"value": "stdout"
}
]
}
}