GBDX

Auto Ordering Task Tutorial

This tutorial shows how to include the Auto Ordering task in a workflow.

Last Updated: May 23, 2019

Overview

We recommend including the Auto Ordering task in a Workflow. The input to this task is a catalog ID. When the Workflow is run, the Auto Ordering task will order the 1B product for the specified catalog ID.

The auto ordering task places an order for a catalog ID. If the catalog ID has already been delivered to the catalog, the task will return its S3 location. If the catalog ID needs to be ordered, the task will place the order and wait for it to be delivered. Once the order has been delivered, the task will return the S3 location.

GBDX Registered Task Name: Auto_Ordering
Input: a single Catalog ID
Output: S3 location for the catalog ID

Quickstart:

This example shows a simple workflow that starts with the Auto Ordering task, using the python-based project GBDXtools. The catalog ID ordered is used as an input to the AOP task.

PYTHON

from gbdxtools import Interface
gbdx = Interface()

tasks = []
output_location = '[add the output location here]'

cat_id = '105001000672E000'

# Image Auto ordering task parameters
order = gbdx.Task("Auto_Ordering")
order.inputs.cat_id = cat_id
order.impersonation_allowed = True
order.persist = True
order.timeout = 36000
tasks += [order]

# Image AOP task parameters
aop = gbdx.Task("AOP_Strip_Processor")
aop.inputs.data = order.outputs.s3_location.value
aop.inputs.bands = 'MS'
aop.inputs.enable_dra = False
aop.outputs.data.persist = True
aop.outputs.data.persist_location = output_location+'/aop'
aop.timeout = 36000
tasks += [aop]

# Set up workflow save data
workflow = gbdx.Workflow(tasks)
workflow.savedata(aop.outputs.data, location=output_location)

workflow.execute()

Workflow API example

Make a POST request to:

   workflows/v1/workflows

Include this JSON request body

    {
        "name": " the name of the workflow. ex. Auto_Ordering_Workflow",
        "tasks": [
            {
                "outputs": [
                    {
                        "name": "s3_location"
                    }
                ],
                "name": "auto_ordering",
                "taskType": "Auto_Ordering",
                "impersonation_allowed": true,
                "inputs": [
                    {
                        "name": "cat_id",
                        "value": "<string>"
                    }
                ]
            }
        ]
    }

Rules for the Auto Ordering Task

The Auto Ordering task will submit an order using your GBDX credentials to the Ordering Endpoint orders/v2/ordercb The "ordercb" endpoint returns a callback when the order is delivered.

  • If the order has already been delivered, the task will return the S3 location immediately.

  • If the order has not been delivered, the task will wait for the order to be fulfilled.

  • Once the order is delivered,a callback is sent. When the callback is received, the Auto Ordering task will resume and return the S3 Location.

  • When the Auto Ordering task is in the "waiting" state, it will return the order ID as a "note." You can use this order ID to query the Orders API for status. See Get Order Status v2.

  • The S3 Location returned from the Auto Ordering task can be piped into another task by using the output port s3_location

Workflow Events for the Auto Ordering Task

The following are workflow events for the Auto Ordering Task:

        "Events": [
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:15:42.795775+00:00",
                "when": "20 minutes ago",
                "note": "",
                "state": "pending",
                "event": "submitted"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:16:45.145101+00:00",
                "when": "19 minutes ago",
                "note": "instance_id: i-86f35cb7",
                "state": "pending",
                "event": "scheduled"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:16:45.225323+00:00",
                "when": "19 minutes ago",
                "note": "instance_id: i-14933a25, domain: default",
                "state": "running",
                "event": "started"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:17:40.404544+00:00",
                "when": "18 minutes ago",
                "note": "instance_id: i-14933a25,  Note: Waiting for Ordering System to Complete Order. OrderId: b77224ec-3015-4460-89f9-17ddaba9a6bc",
                "state": "pending",
                "event": "waiting"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:33:57.300772+00:00",
                "when": "2 minutes ago",
                "note": "instance_id: i-86f35cb7",
                "state": "pending",
                "event": "scheduled"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:33:57.417425+00:00",
                "when": "2 minutes ago",
                "note": "instance_id: i-959039a4, domain: default",
                "state": "running",
                "event": "started"
            },
            {
                "task": "auto_ordering",
                "timestamp": "2016-09-01T19:35:23.740966+00:00",
                "when": "seconds ago",
                "note": "instance_id: i-959039a4,  Note: Waiting for Ordering System to Complete Order. OrderId: b77224ec-3015-4460-89f9-17ddaba9a6bc, Order has been Completed, Location: s3://receiving-dgcs-tdgplatform-com/055567707010_01_003",
                "state": "complete",
                "event": "succeeded"
            }
        ]
    }

Updated 6 months ago


What's Next

Learn how to order a list of catalog IDs with a request to the Ordering API

Place an Order

Auto Ordering Task Tutorial


This tutorial shows how to include the Auto Ordering task in a workflow.

Last Updated: May 23, 2019

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.