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 cwl2ogc import load_converter_from_location
cwl_coverter = load_converter_from_location('../tests/artifacts/cwl-types/app.cwl')
from cwl2ogc import load_converter_from_location
cwl_coverter = load_converter_from_location('../tests/artifacts/cwl-types/app.cwl')
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_coverter.dump_inputs(stream=sys.stdout, pretty_print=True)
import sys
cwl_coverter.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": "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" } }, "required": [ "href", "rel", "type", "hreflang", "title", "length" ] } }, "timeStamp": { "type": "string" }, "numberMatched": { "type": "integer" }, "numberReturned": { "type": "integer" } }, "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_coverter.dump_outputs(stream=sys.stdout, pretty_print=True)
cwl_coverter.dump_outputs(stream=sys.stdout, pretty_print=True)
{ "echo_output": { "schema": { "type": "string" }, "metadata": [ { "title": "cwl:type", "value": "stdout" } ] }, "persistent_output": { "schema": { "type": "string", "format": "uri" }, "metadata": [ { "title": "cwl:type", "value": "File" } ] }, "dir_output": { "schema": { "type": "array", "items": { "type": "string", "format": "uri" } }, "metadata": [ { "title": "cwl:type", "value": "Directory[]" } ], "title": "Vegetation indexes", "description": "Vegetation indexes" } }