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-09-17 21:15:35.864 | DEBUG | cwl_loader:load_cwl_from_location:220 - Loading CWL document from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl...
2025-09-17 21:15:35.906 | DEBUG | cwl_loader:_load_cwl_from_stream:223 - Reading stream from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl...
2025-09-17 21:15:35.928 | DEBUG | cwl_loader:load_cwl_from_stream:197 - CWL data of type <class 'ruamel.yaml.comments.CommentedMap'> successfully loaded from stream
2025-09-17 21:15:35.929 | DEBUG | cwl_loader:load_cwl_from_yaml:141 - Updating the model of type 'CommentedMap' to version 'v1.2'...
2025-09-17 21:15:35.933 | DEBUG | cwl_loader:load_cwl_from_yaml:152 - Raw CWL document successfully updated to v1.2! Now converting to the CWL model...
2025-09-17 21:15:36.121 | DEBUG | cwl_loader:load_cwl_from_yaml:160 - Raw CWL document successfully updated to v1.2! Now dereferencing the steps[].run...
2025-09-17 21:15:36.122 | DEBUG | cwl_loader:load_cwl_from_yaml:170 - steps[].run successfully dereferenced! Now dereferencing the FQNs...
2025-09-17 21:15:36.122 | DEBUG | cwl_loader:_clean_process:90 - Cleaning Workflow test-primitives...
2025-09-17 21:15:36.123 | DEBUG | cwl_loader:_clean_process:90 - Cleaning CommandLineTool clt...
2025-09-17 21:15:36.124 | DEBUG | cwl_loader:load_cwl_from_yaml:175 - CWL document successfully dereferenced!
2025-09-17 21:15:36.124 | DEBUG | cwl_loader:_load_cwl_from_stream:231 - Stream from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.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!
from IPython.display import (
display,
Markdown
)
import sys
for i, cwl_converter in enumerate(cwl_converters):
index = i + 1
display(Markdown(f"## 2.{index}. `{cwl_converter.cwl.id}` Inputs:"))
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
display(Markdown('---'))
from IPython.display import (
display,
Markdown
)
import sys
for i, cwl_converter in enumerate(cwl_converters):
index = i + 1
display(Markdown(f"## 2.{index}. `{cwl_converter.cwl.id}` Inputs:"))
cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)
display(Markdown('---'))
2.1. 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" } }
2.2. 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 i, cwl_converter in enumerate(cwl_converters):
index = i + 1
display(Markdown(f"## 3.{index}. `{cwl_converter.cwl.id}` Outputs:"))
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
display(Markdown('---'))
for i, cwl_converter in enumerate(cwl_converters):
index = i + 1
display(Markdown(f"## 3.{index}. `{cwl_converter.cwl.id}` Outputs:"))
cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)
display(Markdown('---'))
3.1. test-primitives
Outputs:¶
{ "echoed_values": { "schema": { "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "string" } ], "title": "Echoed Values", "description": "The string containing echoed primitive values" } }
3.2. clt
Outputs:¶
{ "echoed": { "schema": { "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "string" } ] } }