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-11-06 22:55:05.792 | DEBUG | cwl_loader:load_cwl_from_location:228 - Loading CWL document from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl...
2025-11-06 22:55:05.938 | DEBUG | cwl_loader:_load_cwl_from_stream:231 - Reading stream from https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl...
2025-11-06 22:55:05.958 | 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:05.959 | 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:05.959 | DEBUG | cwl_loader:load_cwl_from_yaml:145 - Parsing the raw CWL document to the CWL Utils DOM...
2025-11-06 22:55:06.296 | DEBUG | cwl_loader:load_cwl_from_yaml:158 - Raw CWL document successfully parsed to the CWL Utils DOM!
2025-11-06 22:55:06.297 | DEBUG | cwl_loader:load_cwl_from_yaml:160 - Dereferencing the steps[].run...
2025-11-06 22:55:06.297 | DEBUG | cwl_loader:_on_process:78 - Checking if https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl#clt must be externally imported...
2025-11-06 22:55:06.298 | DEBUG | cwl_loader:_on_process:82 - run_url: https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl - uri: https://raw.githubusercontent.com/eoap/application-package-patterns/refs/heads/main/cwl-workflow/test-primitives.cwl
2025-11-06 22:55:06.299 | DEBUG | cwl_loader:load_cwl_from_yaml:167 - steps[].run successfully dereferenced! Dereferencing the FQNs...
2025-11-06 22:55:06.299 | DEBUG | cwl_loader:load_cwl_from_yaml:171 - CWL document successfully dereferenced! Now verifying steps[].run integrity...
2025-11-06 22:55:06.300 | DEBUG | cwl_loader:load_cwl_from_yaml:175 - All steps[].run link are resolvable!
2025-11-06 22:55:06.300 | DEBUG | cwl_loader:load_cwl_from_yaml:178 - Sorting Process instances by dependencies....
2025-11-06 22:55:06.301 | DEBUG | cwl_loader:load_cwl_from_yaml:180 - Sorting process is over.
2025-11-06 22:55:06.301 | DEBUG | cwl_loader:_load_cwl_from_stream:240 - 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. 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"
}
}
2.2. 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"
}
}
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. clt Outputs:¶
{
"echoed": {
"schema": {
"type": "string"
},
"metadata": [
{
"title": "cwl:type",
"value": "string"
}
]
}
}
3.2. test-primitives Outputs:¶
{
"echoed_values": {
"schema": {
"type": "string"
},
"metadata": [
{
"title": "cwl:type",
"value": "string"
}
],
"title": "Echoed Values",
"description": "The string containing echoed primitive values"
}
}