Imported CWL types¶
Follow below an example to demonstrate how the library handles and convert a CWL where inputs are imported from an external URL.
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('../tests/artifacts/cwl-types/app.cwl')
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
from cwl_loader import load_cwl_from_location
from cwl2ogc import BaseCWLtypes2OGCConverter
cwl_document = load_cwl_from_location('../tests/artifacts/cwl-types/app.cwl')
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
2026-02-05 18:21:02.832 | DEBUG | cwl_loader:load_cwl_from_location:228 - Loading CWL document from ../tests/artifacts/cwl-types/app.cwl...
2026-02-05 18:21:02.833 | DEBUG | cwl_loader:_load_cwl_from_stream:231 - Reading stream from ../tests/artifacts/cwl-types/app.cwl...
2026-02-05 18:21:02.839 | DEBUG | cwl_loader:load_cwl_from_stream:203 - CWL data of type <class 'ruamel.yaml.comments.CommentedMap'> successfully loaded from stream
2026-02-05 18:21:02.840 | DEBUG | cwl_loader:load_cwl_from_yaml:143 - No needs to update the Raw CWL document since it targets already the v1.2
2026-02-05 18:21:02.840 | DEBUG | cwl_loader:load_cwl_from_yaml:145 - Parsing the raw CWL document to the CWL Utils DOM...
2026-02-05 18:21:03.504 | DEBUG | cwl_loader:load_cwl_from_yaml:158 - Raw CWL document successfully parsed to the CWL Utils DOM!
2026-02-05 18:21:03.505 | DEBUG | cwl_loader:load_cwl_from_yaml:160 - Dereferencing the steps[].run...
2026-02-05 18:21:03.505 | DEBUG | cwl_loader:load_cwl_from_yaml:167 - steps[].run successfully dereferenced! Dereferencing the FQNs...
2026-02-05 18:21:03.506 | DEBUG | cwl_loader:load_cwl_from_yaml:171 - CWL document successfully dereferenced! Now verifying steps[].run integrity...
2026-02-05 18:21:03.506 | DEBUG | cwl_loader:load_cwl_from_yaml:175 - All steps[].run link are resolvable!
2026-02-05 18:21:03.507 | DEBUG | cwl_loader:load_cwl_from_yaml:178 - Sorting Process instances by dependencies....
2026-02-05 18:21:03.507 | DEBUG | cwl_loader:load_cwl_from_yaml:180 - Sorting process is over.
2026-02-05 18:21:03.507 | DEBUG | cwl_loader:_load_cwl_from_stream:240 - Stream from ../tests/artifacts/cwl-types/app.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)
{
"aoi": {
"schema": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"FeatureCollection"
]
},
"features": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Feature"
]
},
"id": {
"type": "string"
},
"geometry": {
"nullable": false,
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Point"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"LineString"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Polygon"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"MultiPoint"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"MultiLineString"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"MultiPolygon"
]
},
"coordinates": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
}
}
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"coordinates",
"bbox"
]
}
]
},
"bbox": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
},
"required": [
"type",
"id",
"geometry",
"bbox"
]
}
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string"
},
"rel": {
"type": "string"
},
"type": {
"type": "string"
},
"hreflang": {
"type": "string"
},
"title": {
"type": "string"
},
"length": {
"type": "integer",
"format": "int32"
}
},
"required": [
"href",
"rel",
"type",
"hreflang",
"title",
"length"
]
}
},
"timeStamp": {
"type": "string"
},
"numberMatched": {
"type": "integer",
"format": "int32"
},
"numberReturned": {
"type": "integer",
"format": "int32"
}
},
"required": [
"type",
"features",
"links",
"timeStamp",
"numberMatched",
"numberReturned"
]
},
"metadata": [
{
"title": "cwl:type",
"value": "https://raw.githubusercontent.com/eoap/schemas/main/geojson.yaml#FeatureCollection"
}
],
"minOccurs": 1,
"maxOccurs": 1,
"valuePassing": "byValue",
"title": "Area of interest",
"description": "Area of interest defined as a bounding box"
}
}
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)
{
"echo_output": {
"schema": {
"type": "string"
},
"metadata": [
{
"title": "cwl:type",
"value": "stdout"
}
]
},
"persistent_output": {
"schema": {
"oneOf": [
{
"type": "string",
"format": "uri"
},
{
"$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
}
]
},
"metadata": [
{
"title": "cwl:type",
"value": "File"
}
]
},
"dir_output": {
"schema": {
"type": "array",
"items": {
"oneOf": [
{
"type": "string",
"format": "uri"
},
{
"$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
},
{
"$ref": "https://schemas.stacspec.org/v1.0.0/collection-spec/json-schema/collection.json"
}
]
}
},
"metadata": [
{
"title": "cwl:type",
"value": "Directory[]"
}
],
"title": "Vegetation indexes",
"description": "Vegetation indexes"
}
}