Document graph¶
Document graph refers to the 2.4 Document graph paragraph of the 2. Document model chapter of the Semantic Annotations for Linked Avro Data (SALAD).
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_documents = load_cwl_from_location('https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl')
cwl_converters = [BaseCWLtypes2OGCConverter(cwl_document) for cwl_document in cwl_documents]
from cwl_loader import load_cwl_from_location
from cwl2ogc import BaseCWLtypes2OGCConverter
cwl_documents = load_cwl_from_location('https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl')
cwl_converters = [BaseCWLtypes2OGCConverter(cwl_document) for cwl_document in cwl_documents]
2025-08-12 16:36:59.819 | INFO | cwl_loader:load_cwl_from_location:186 - Loading CWL document from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl...
2025-08-12 16:36:59.944 | INFO | cwl_loader:load_cwl_from_yaml:117 - Updating the model to v1.2...
2025-08-12 16:36:59.949 | INFO | cwl_loader:load_cwl_from_yaml:128 - Raw CWL document successfully updated to v1.2! Now converting to the CWL model...
2025-08-12 16:37:00.032 | INFO | cwl_loader:load_cwl_from_yaml:136 - Raw CWL document successfully updated to v1.2! Now dereferencing the FQNs...
2025-08-12 16:37:00.032 | INFO | cwl_loader:_clean_process:62 - Cleaning Workflow test-primitives...
2025-08-12 16:37:00.033 | INFO | cwl_loader:_clean_process:62 - Cleaning CommandLineTool clt...
2025-08-12 16:37:00.034 | INFO | cwl_loader:load_cwl_from_yaml:144 - CWL document successfully dereferenced!
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
for cwl_converter in cwl_converters:
print(f"'{cwl_converter.cwl.id}' Inputs:")
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
print('\n------------------------------------------------------------------------', file=sys.stderr)
import sys
for cwl_converter in cwl_converters:
print(f"'{cwl_converter.cwl.id}' Inputs:")
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
print('\n------------------------------------------------------------------------', file=sys.stderr)
'test-primitives' Inputs: { "null_input": { "schema": { "nullable": true, "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "[ null, string ]" } ], "minOccurs": 0, "maxOccurs": 1, "valuePassing": "byValue", "title": "Nullable Input", "description": "A nullable input that can be null or a string" }, "boolean_input": { "schema": { "type": "boolean", "default": true }, "metadata": [ { "title": "cwl:type", "value": "boolean" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "Boolean Input", "description": "A boolean value" }, "int_input": { "schema": { "type": "integer", "format": "int32", "default": 42 }, "metadata": [ { "title": "cwl:type", "value": "int" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "Integer Input", "description": "An integer value" }, "long_input": { "schema": { "type": "integer", "format": "int64", "default": 1234567890123 }, "metadata": [ { "title": "cwl:type", "value": "long" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "Long Input", "description": "A long integer value" }, "float_input": { "schema": { "type": "number", "format": "float", "default": 3.14 }, "metadata": [ { "title": "cwl:type", "value": "float" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "Float Input", "description": "A floating-point number" }, "double_input": { "schema": { "type": "number", "format": "double", "default": 2.7182818284 }, "metadata": [ { "title": "cwl:type", "value": "double" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "Double Input", "description": "A double-precision float" }, "string_input": { "schema": { "type": "string", "default": "Hello, CWL!" }, "metadata": [ { "title": "cwl:type", "value": "string" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "title": "String Input", "description": "A string input" } }'clt' Inputs: { "null_input": { "schema": { "nullable": true, "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "[ null, string ]" } ], "minOccurs": 0, "maxOccurs": 1, "valuePassing": "byValue", "description": "A nullable input (null or string)" }, "boolean_input": { "schema": { "type": "boolean", "default": true }, "metadata": [ { "title": "cwl:type", "value": "boolean" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "A boolean value" }, "int_input": { "schema": { "type": "integer", "format": "int32", "default": 42 }, "metadata": [ { "title": "cwl:type", "value": "int" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "An integer value" }, "long_input": { "schema": { "type": "integer", "format": "int64", "default": 1234567890123 }, "metadata": [ { "title": "cwl:type", "value": "long" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "A long integer" }, "float_input": { "schema": { "type": "number", "format": "float", "default": 3.14 }, "metadata": [ { "title": "cwl:type", "value": "float" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "A floating-point number" }, "double_input": { "schema": { "type": "number", "format": "double", "default": 2.7182818284 }, "metadata": [ { "title": "cwl:type", "value": "double" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "A double-precision float" }, "string_input": { "schema": { "type": "string", "default": "Hello, CWL!" }, "metadata": [ { "title": "cwl:type", "value": "string" } ], "minOccurs": 1, "maxOccurs": 1, "valuePassing": "byValue", "description": "A string input" } }
------------------------------------------------------------------------ ------------------------------------------------------------------------
3. Outputs conversion¶
Users can reuse the BaseCWLtypes2OGCConverter
instance to convert the CWL outputs to the OGC JSON format:
In [3]:
Copied!
for cwl_converter in cwl_converters:
print(f"'{cwl_converter.cwl.id}' Outputs:")
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
print('\n------------------------------------------------------------------------', file=sys.stderr)
for cwl_converter in cwl_converters:
print(f"'{cwl_converter.cwl.id}' Outputs:")
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
print('\n------------------------------------------------------------------------', file=sys.stderr)
'test-primitives' Outputs: { "echoed_values": { "schema": { "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "string" } ], "title": "Echoed Values", "description": "The string containing echoed primitive values" } }'clt' Outputs: { "echoed": { "schema": { "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "string" } ] } }
------------------------------------------------------------------------ ------------------------------------------------------------------------