Skip to content

Submit a processing job on Ades v1

bbrauzzi edited this page Dec 20, 2022 · 7 revisions

Prepare the job order payload

A HTTP POST request to the execution-endpoint creates a new job. The inputs and outputs need to be passed in a JSON execute-request.

Method Path Headers Status Code
POST /{WORKSPACE_NAME}/wps3/processes/{PROCESS_ID}
  • Accept: application/json
  • Content-Type: application/json
  • (Optional) Authorization: Bearer ***
201

Request payload body:

{
    "inputs": [
        {
            "id": "input1_id",
            "input": {
                "dataType": {
                    "name": "application/json"
                },
                "value": "https://example.com/sample.json"
            }
        },
        {
            "id": "input2_id",
            "input": {
                "dataType": {
                    "name": "string"
                },
                "value": "This is a string"
            }
        }
    ],
    "outputs": [
        {
            "format": {
                "mimeType": "string",
                "schema": "string",
                "encoding": "string"
            },
            "id": "wf_outputs",
            "transmissionMode": "value"
        }
    ],
    "mode": "auto",
    "response": "raw"
}

App execution example:

We first create the job order JSON file app-deploy-payload.json describing our input parameters following thew input specification from the processing services description.

{
    "inputs": [
        {
            "id": "input_reference",
            "input": {
                "dataType": {
                    "name": "application/json"
                },
                "value": "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_36RTT_20191205_0_L2A"
            }
        },
        {
            "id": "input_reference",
            "input": {
                "dataType": {
                    "name": "application/json"
                },
                "value": "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_36RTT_20191215_0_L2A"
            }
        },
        {
            "id": "s_expression",
            "input": {
                "dataType": {
                    "name": "string"
                },
                "value": "nbr:(/ (- B05 B02) (+ B05 B02))"
            }
        },
                {
            "id": "s_expression",
            "input": {
                "dataType": {
                    "name": "string"
                },
                "value": "ndvi:(/ (- B05 B03) (+ B05 B03))"
            }
        },
                {
            "id": "s_expression",
            "input": {
                "dataType": {
                    "name": "string"
                },
                "value": "ndwi:(/ (- B06 B03) (+ B06 B03))"
            }
        }
    ],
    "outputs": [
        {
            "format": {
                "mimeType": "string",
                "schema": "string",
                "encoding": "string"
            },
            "id": "wf_outputs",
            "transmissionMode": "value"
        }
    ],
    "mode": "auto",
    "response": "raw"
}

We then submit the job order with a curl command line using the OGC API interface

curl -v -L -X POST "http://{HOSTNAME:PORT}/{WORKSPACE_NAME}/wps3/processes/snuggs-0_3_0/jobs" \
    -H "accept: application/json" -H  "Prefer: respond-async" -H  "Content-Type: application/json" -d "@test/sample_apps/v1/snuggs/app-execute-payload.json"

The command line's result should be similar to

TODO << place here the response with the redirect to the get status >>

The server replied with a HTTP 201 created acknowledging the job sucessfully created. It also contains a redirect link to the job on the ADES

We also can see the newly created job by querying the current job list.

curl -s -L "http://{HOSTNAME:PORT}/{WORKSPACE_NAME}/wps3/processes/snuggs-0_3_0/jobs" -H "accept: application/json"

And the result should include a new job with the same identifier returned by the job submission query

[
  ...
  {
    "id": "06223bbe-9e9e-11ea-8f64-a0c5899f98fe",
    "infos": {
      "status": "successful",
      "message": "ZOO-Kernel successfully run your service!",
      "links": [
        {
          "Title": "Status location",
          "href": "/watchjob/processes/snuggs-0_3_0/jobs/06223bbe-9e9e-11ea-8f64-a0c5899f98fe"
        },
        {
          "Title": "Result location",
          "href": "/watchjob/processes/snuggs-0_3_0/jobs/06223bbe-9e9e-11ea-8f64-a0c5899f98fe/result"
        }
      ]
    }
  }
  ...
]

We can see 2 links in the response:

  1. A status location where we can poll regurarly the status of this job

    curl -s -L "http://{HOSTNAME:PORT}/{WORKSPACE_NAME}/watchjob/processes/snuggs-0_3_0/jobs/06223bbe-9e9e-11ea-8f64-a0c5899f98fe" -H "accept: application/json"
  2. A result location available when the job is complete

    curl -s -L "http://{HOSTNAME:PORT}/{WORKSPACE_NAME}/watchjob/processes/snuggs-0_3_0/jobs/06223bbe-9e9e-11ea-8f64-a0c5899f98fe/result" -H "accept: application/json"

This last link will return the following response when the job is complete.

{
    "outputs": [
        {
            "id": "wf_outputs",
            "time": "2021-09-30T16:03:42.801714Z",
            "value": {
                "inlineValue": "{\"StacCatalogUri\": \"s3://processingresults/wf-76d50612-513d-11ed-888e-32db482e8b42/catalog.json\"}"
            }
        }
    ]
}

It includes a link to the catalog entry of the result and a link to the resource manager hosting the processing results.

Get Status

Method Path Headers Status Code
GET /{WORKSPACE_NAME}/watchjob/processes/snuggs-0_3_0/jobs/{JOB_ID}
  • Accept: application/json
  • Content-Type: application/json
200

Get Results

Method Path Headers Status Code
GET /{WORKSPACE_NAME}/watchjob/processes/snuggs-0_3_0/jobs/{JOB_ID}/result
  • Accept: application/json
  • Content-Type: application/json
200