Pattern 2
Application Package Pattern 2¶
The CWL includes:
- two input parameters of type
Directory - one output parameter of type
Directory
This scenario typically takes as input one pre-event acquisition, one post-even acquisition, applies an algorithm and produces a result
Implementation: delineate water bodies using NDWI and Otsu automatic threshold taking as input two Landsat-8/9 acquisitions
Inputs¶
| Id | Type | Label | Doc |
|---|---|---|---|
aoi |
string |
area of interest | area of interest as a bounding box |
epsg |
string |
EPSG code | EPSG code |
bands |
string[] |
bands used for the NDWI | bands used for the NDWI |
item_1 |
Directory |
Landsat-8/9 acquisition reference | Landsat-8/9 acquisition reference |
item_2 |
Directory |
Landsat-8/9 acquisition reference | Landsat-8/9 acquisition reference |
Steps¶
| Id | Runs | Label | Doc |
|---|---|---|---|
step |
#clt |
None | None |
Outputs¶
| Id | Type | Label | Doc |
|---|---|---|---|
water_bodies |
Directory |
Water bodies detected | Water bodies detected based on the NDWI and otsu threshold |
Data flow management¶
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[7], line 2 1 w = WorkflowWrapper(workflow=wf.workflow, entrypoint=entrypoint) ----> 2 wrapped = w.wrap() 3 4 app_cwl_file = f".{entrypoint}.cwl" 5 File ~/work/application-package-patterns/application-package-patterns/docs/helpers.py:121, in WorkflowWrapper.wrap(self) 114 file_stage_in = load_cwl_from_location( 115 path=f"{self.base_url}/templates/stage-in-file.cwl" 116 ) 117 stage_out_cwl = load_cwl_from_location( 118 path=f"{self.base_url}/templates/stage-out.cwl" 119 ) --> 121 return wrap( 122 directory_stage_in=directory_stage_in, 123 file_stage_in=file_stage_in, 124 workflows=self.workflow, 125 workflow_id=self.entrypoint, 126 stage_out=stage_out_cwl, 127 ) TypeError: wrap() got an unexpected keyword argument 'workflows'. Did you mean 'workflow'?
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[8], line 1 ----> 1 wf = WorkflowViewer(cwl_file=app_cwl_file, workflow=wrapped, entrypoint="main") 2 3 wf.plot() NameError: name 'wrapped' is not defined
Workflow components diagram¶
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[9], line 1 ----> 1 wf.display_components_diagram() File ~/work/application-package-patterns/application-package-patterns/docs/helpers.py:72, in WorkflowViewer.display_components_diagram(self) 70 def display_components_diagram(self): 71 out = StringIO() ---> 72 to_puml( 73 cwl_document=self.workflow, 74 diagram_type=DiagramType.COMPONENT, 75 output_stream=out, 76 ) 78 clear_output = out.getvalue() 79 encoded = deflate_and_encode(clear_output) File /opt/hostedtoolcache/Python/3.14.6/x64/lib/python3.14/site-packages/cwl2puml/__init__.py:222, in to_puml(cwl_document, diagram_type, output_stream, workflow_id) 205 def to_puml( 206 cwl_document: Process | List[Process], 207 diagram_type: DiagramType, 208 output_stream: TextIO, 209 workflow_id: str = "main", 210 ): 211 """ 212 Converts a CWL, given its document model, to a PlantUML diagram. 213 (...) 220 `None`: none 221 """ --> 222 assert_process_contained(process=cwl_document, process_id=workflow_id) 224 assert_connected_graph(cwl_document) 226 index = ( 227 to_index(cwl_document) 228 if isinstance(cwl_document, list) 229 else {workflow_id: cwl_document} 230 ) File /opt/hostedtoolcache/Python/3.14.6/x64/lib/python3.14/site-packages/cwl_loader/utils.py:50, in assert_process_contained(process_id, process) 48 def assert_process_contained(process_id: str, process: Process | List[Process]): 49 if not contains_process(process_id=process_id, process=process): ---> 50 raise ValueError( 51 f"Process {process_id} does not exist in input CWL document, only {list(map(lambda p: p.id, process)) if isinstance(process, list) else [process.id]} available." 52 ) ValueError: Process main does not exist in input CWL document, only ['pattern-2', 'clt'] available.
Inputs¶
| Id | Type | Label | Doc |
|---|---|---|---|
aoi |
string |
area of interest | area of interest as a bounding box |
epsg |
string |
EPSG code | EPSG code |
bands |
string[] |
bands used for the NDWI | bands used for the NDWI |
item_1 |
Directory |
Landsat-8/9 acquisition reference | Landsat-8/9 acquisition reference |
item_2 |
Directory |
Landsat-8/9 acquisition reference | Landsat-8/9 acquisition reference |
Steps¶
| Id | Runs | Label | Doc |
|---|---|---|---|
step |
#clt |
None | None |
Outputs¶
| Id | Type | Label | Doc |
|---|---|---|---|
water_bodies |
Directory |
Water bodies detected | Water bodies detected based on the NDWI and otsu threshold |
Execution¶
Inputs¶
{
"aoi": "-118.985,38.432,-118.183,38.938",
"epsg": "EPSG:4326",
"bands": [
"green",
"nir08"
],
"item_1": {
"class": "https://raw.githubusercontent.com/eoap/schemas/main/url.yaml#URL",
"value": "https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_042033_20231007_02_T1"
},
"item_2": {
"class": "https://raw.githubusercontent.com/eoap/schemas/main/url.yaml#URL",
"value": "https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC09_L2SP_042033_20231015_02_T1"
}
}
--------------------------------------------------------------------------- AssertionError Traceback (most recent call last) Cell In[16], line 19 15 stdout=stream_out, 16 stderr=stream_err, 17 ) 18 ---> 19 assert res == 0 20 21 md = f""" 22 AssertionError: