Skip to content

OGC API Process Client CommandLineTool

Goal

Wrap the ogc-api-processes-client step as a Common Workflow Language CommandLineTool and execute it with a CWL runner. Indeed, it will interact with the a deployrd process (e.g. water-bodies) on the OGC API endpint, submit a job with the recived inputs, monitor the job for any upcoming event(e.g running, successful, failed), and finally create STAC ItemCollection with assets pointing to the results.

How to wrap a step as a CWL CommandLineTool

The CWL document below shows the ogc-api-processes-client step wrapped as a CWL CommandLineTool:

ogc-api-processes-client-cli.cwl
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
cwlVersion: v1.2
$graph:
- class: CommandLineTool
  id: ogc-api-processes-client
  label: geo API - Processes

  requirements:
  - class: InlineJavascriptRequirement
  - class: DockerRequirement
    dockerPull:  localhost/ogc 
  - class: SchemaDefRequirement
    types:
    - $import: https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml
    - $import: https://raw.githubusercontent.com/eoap/schemas/main/geojson.yaml
    - $import: |-
        https://raw.githubusercontent.com/eoap/schemas/main/experimental/api-endpoint.yaml
    - $import: https://raw.githubusercontent.com/eoap/schemas/main/experimental/process.yaml
  inputs:
    api_endpoint:
      label: OGC API endpoint
      doc: OGC API endpoint for Landsat-9 data
      type: |-
        https://raw.githubusercontent.com/eoap/schemas/main/experimental/api-endpoint.yaml#APIEndpoint
    execute_request:
      label: OGC API Processes settings
      doc: OGC API Processes settings for Landsat-9 data
      type: File
    process_id:
      label: Process ID
      doc: Process ID for the OGC API Processes
      type: Any

  outputs:
    process_output:
      type: File
      outputBinding:
        glob: feature-collection.json
  baseCommand: ["ogc-api-processes-client"]
  arguments:
    - --api-endpoint
    - $(inputs.api_endpoint.url.value)
    - --process-id
    - $(inputs.process_id)
    - --execute-request 
    - $(inputs.execute_request.path)
    - --output
    - feature-collection.json

Let's break down the key components of this CWL document:

  • cwlVersion: v1.2 Specifies that this CWL document uses version 1.2 of the CWL specification.

  • class: CommandLineTool Indicates that this CWL document defines a command-line tool.

  • id and label

  • id: ogc-api-processes-client — unique identifier for this tool.

  • label: Geo API - Processes — human-readable name.

  • requirements Defines the execution environment and runtime features:

  • InlineJavascriptRequirement — Allows the use of inline JavaScript expressions in the tool like $(inputs.xyz) in arguments.

  • DockerRequirement — specifies the Docker container image refrence for execution.
  • SchemaDefRequirement — imports custome schemas for input validation:

    • string_format.yaml
    • geojson.yaml
    • api-endpoint.yaml
    • process.yaml
  • inputs The tool expects three inputs:

  • api_endpoint: the OGC API URL (validated against a schema).

  • execute_request: JSON file with process parameters. An expample of this JSON file is mentioned below:

    ```
    {
        "inputs": {
            "stac_items": [
                "https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_044032_20231208_02_T1",
                "https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_043033_20231201_02_T1"
            ],
            "aoi": "-121.399,39.834,-120.74,40.472",
            "epsg": "EPSG:4326",
            "bands": [
                "green",
                "nir08"
            ]
        }
    }
    ```
    
    • process_id: identifier of the OGC process to run.
  • outputs Defines what the tool produces:

  • process_output: a file called feature-collection.json.

  • baseCommand and arguments

  • baseCommand: ["ogc-api-processes-client"] which is the command executed inside Docker.

  • arguments — maps CWL inputs to command-line flags:

    • --api-endpoint$(inputs.api_endpoint.url.value)
    • --process-id$(inputs.process_id)
    • --execute-request$(inputs.execute_request.path)
    • --outputfeature-collection.json