Logo
  • Introduction

Supported conversions

  • Essential Input Parameters
  • Array Inputs
  • Inclusive and Exclusive Inputs
  • Exclusive Input Parameters with Expressions
  • Document graph
  • More examples
    • Complex CWL types
      • 1. Parsing
    • Imported CWL types
    • String formats
    • JSON Schema generation
  • Transpiler-Mate plugin
  • API doc
CWL to OGC
  • Supported conversions
  • More examples
  • Complex CWL types
  • Edit on transpiler-mate/cwl2ogc

Complex CWL types¶

Follow below an example to demonstrate how the library handles and convert a CWL where inputs are declared with hybrid types.

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(
    "https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl"
)
cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
from cwl_loader import load_cwl_from_location from cwl2ogc import BaseCWLtypes2OGCConverter cwl_document = load_cwl_from_location( "https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl" ) cwl_converter = BaseCWLtypes2OGCConverter(cwl_document)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 2
      1 from cwl_loader import load_cwl_from_location
----> 2 from cwl2ogc import BaseCWLtypes2OGCConverter
      3 
      4 cwl_document = load_cwl_from_location(
      5     "https://raw.githubusercontent.com/transpiler-mate/cwl2ogc/refs/heads/develop/tests/artifacts/cwl-types/complex-cwl-types.cwl"

ModuleNotFoundError: No module named 'cwl2ogc'

3. 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)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 3
      1 import sys
      2 
----> 3 cwl_converter.dump_inputs(stream=sys.stdout, pretty_print=True)

NameError: name 'cwl_converter' is not defined

2. 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)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 cwl_converter.dump_outputs(stream=sys.stdout, pretty_print=True)

NameError: name 'cwl_converter' is not defined
Previous Next

Apache License, Version 2.0

Built with MkDocs using a theme provided by Read the Docs.
transpiler-mate/cwl2ogc « Previous Next »