/opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_wrapper/parser.py:3: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources
Pattern 1 - one input/one output¶
The CWL includes:
- one input parameter of type
Directory
- one output parameter of type
Directory
This scenario typically takes one input, applies an algorithm and produces a result
Implementation: delineate water bodies using NDWI and Otsu automatic threshold taking as input a Landsat-9 acquisition
Read the parameters¶
--------------------------------------------------------------------------- ValidationException Traceback (most recent call last) Cell In[6], line 5 2 cwl_dict = yaml.safe_load(StringIO(res)) 4 # baseuri just needs to not interfere ----> 5 workflow = load_document(cwl_dict, baseuri="file:///", id_="_main") File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:297, in load_document(doc, baseuri, loadingOptions, id_, load_all) 295 if isinstance(doc, str): 296 return load_document_by_string(doc, baseuri, loadingOptions, id_) --> 297 return load_document_by_yaml(doc, baseuri, loadingOptions, id_, load_all) File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:321, in load_document_by_yaml(yaml, uri, loadingOptions, id_, load_all) 313 def load_document_by_yaml( 314 yaml: Any, 315 uri: str, (...) 318 load_all: bool = False, 319 ) -> Any: 320 """Load a CWL object from a YAML object.""" --> 321 version = cwl_version(yaml) 322 if "$graph" in yaml and not load_all: 323 yaml = _get_id_from_graph(yaml, id_) File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:236, in cwl_version(yaml) 228 """ 229 Return the cwlVersion of a YAML object. 230 (...) 233 :raises ValidationException: If `yaml` is not a MutableMapping. 234 """ 235 if not isinstance(yaml, MutableMapping): --> 236 raise ValidationException("MutableMapping is required") 237 if "cwlVersion" not in list(yaml.keys()): 238 return None ValidationException: MutableMapping is required
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[7], line 3 1 md = "## Inputs\n" ----> 3 for inp in workflow.inputs: 5 md += f"- `{inp.id.replace("file:///#_main/", "")}`: {inp.type_}\n" 7 display(Markdown(md)) NameError: name 'workflow' is not defined
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[8], line 3 1 md = "## Outputs\n" ----> 3 for inp in workflow.outputs: 5 md += f"- `{inp.id.replace("file:///#_main/", "")}`: {inp.type_}\n" 7 display(Markdown(md)) NameError: name 'workflow' is not defined
--------------------------------------------------------------------------- GraphTargetMissingException Traceback (most recent call last) Cell In[9], line 7 2 cwl_dict = yaml.safe_load(f) 4 #cwl_dict = yaml.safe_load(StringIO(res)) 5 6 # baseuri just needs to not interfere ----> 7 workflow = load_document(cwl_dict, baseuri="file:///", id_="water-bodies-detection") File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:297, in load_document(doc, baseuri, loadingOptions, id_, load_all) 295 if isinstance(doc, str): 296 return load_document_by_string(doc, baseuri, loadingOptions, id_) --> 297 return load_document_by_yaml(doc, baseuri, loadingOptions, id_, load_all) File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:323, in load_document_by_yaml(yaml, uri, loadingOptions, id_, load_all) 321 version = cwl_version(yaml) 322 if "$graph" in yaml and not load_all: --> 323 yaml = _get_id_from_graph(yaml, id_) 324 yaml["cwlVersion"] = version 325 if version == "v1.0": File /opt/hostedtoolcache/Python/3.13.5/x64/lib/python3.13/site-packages/cwl_utils/parser/__init__.py:221, in _get_id_from_graph(yaml, id_) 219 if el["id"].lstrip("#") == id_: 220 return el --> 221 raise GraphTargetMissingException( 222 "Tool file contains graph of multiple objects, must specify " 223 "one of #%s" % ", #".join(el["id"] for el in yaml["$graph"]) 224 ) GraphTargetMissingException: Tool file contains graph of multiple objects, must specify one of #pattern-1, #clt
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[10], line 3 1 md = "## Inputs\n" ----> 3 for inp in workflow.inputs: 5 md += f"- `{inp.id.replace("file:///#water-bodies-detection/", "")}`: {inp.type_}\n" 7 display(Markdown(md)) NameError: name 'workflow' is not defined
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[11], line 3 1 md = "## Outputs\n" ----> 3 for inp in workflow.outputs: 5 md += f"- `{inp.id.replace("file:///#water-bodies-detection/", "")}`: {inp.type_}\n" 7 display(Markdown(md)) NameError: name 'workflow' is not defined