Create a new draft task

/tasks

This call creates a new task. You can create either a single task or a batch task by using the app's default batching, override batching, or disable batching completely.

A parent task is a task that specifies criteria by which to batch its inputs into a series of further sub-tasks, called child tasks.

See the documentation on batching tasks for more details on batching criteria.

https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/tasks

Request

Example request

In the example, the new task is included in the body as new-task.json, shown below.

POST /v2/tasks HTTP/1.1
Host: api.sb.biodatacatalyst.nhlbi.nih.gov
X-SBG-Auth-Token: 3259c50e1ac5426ea8f1273259740f74
curl --data-binary "@new-task.json" -s -H "X-SBG-Auth-Token: 6282d5e2121d43e7900e9d52b15845e7" -H "content-type: application/json" -X POST "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/tasks"

Header Fields

NameDescription
X-SBG-Auth-Token
required
Your authentication token.

Query parameters

NameData typeDescription
fieldsstringSelector specifying a subset of fields to include in the response.
runbooleanIf set to true, API will run the task upon creation. If not specified, default value of false is applied and task is not run, but a draft task is created.

Request body

The request body should be a JSON object specifying the app that you want to run, and assigning input files to its input nodes. It is entered as a list of key-value pairs. The keys specify the name and description of the task to be created, the app to executed, and details of its inputs files. The keys, and their permitted values, are described below.

You can see a list of the app's input nodes on the Platform, on the apps page for the project. Specify the files to input to the nodes using the files' IDs, which you can obtain using the call to GET /files.

KeyDatatype of valueDescription of value
"name"stringThe name of the task
"description"stringAn optional description of the task
"project"stringThe short name of the project that you want to create the task in.
"app"stringThe specification of the app that you want to run. Recall that apps are specified by their projects, in the form {project_owner}/{project}/{app_name}
"inputs"dictionary.See the API Overview section on specifying inputs for information on creating input objects.
"bath"BooleanThis is set to false by default. Set to true to create a batch task and specify the batch_input and batch-by criteria as described below.
"batch_input"stringThe ID of the input on which you wish to batch. You would typically batch on the input consisting of a list of files. If this parameter is omitted, the default batching criteria defined for the app will be used.
"batch_by"dictionaryThis specifies the criteria on which to batch. It can be in one of two formats.

1. If you wish to batch per item in the app's input (i.e., typically per file in a list of files) then specify a dictionary with the following format:
{ "type": "ITEM" }

2. If you wish to batch by groups of inputs, you should specify the criteria satisfied by each group. This should be a common metadata value in one, or more, metadata fields.

To do this, specify a dictionary with the following format:

{ "type": "CRITERIA", "criteria": [ "metadata.<field_1>", "metadata.<field_2>" ] }
This will group inputs by shared metadata values for <field_1> and <field_2>, in that order. Arbitrarily many metadata fields may be listed, and the order in which fields are grouped will respect the order of the list.
use_interruptible_instancesBooleanThis field can be true or false. Set this field to true to allow the use of spot instances.

Example request body

{   "description": "my draft task",
    "name": "RFranklin, Experiment IV",
    "app": "RFranklin/my-project/new-test-app",
    "project": "RFranklin/my-project",
    "use_interruptible_instances": true,
    "inputs": {
        "cuffdiff_zip": {
            "class": "File",
            "path": "567890abc9b0307bc0414164",
            "name": "example_human_known_indels.vcf"
        }
    }
}

Response

See a list of response codes that may be contained in the body of the response.

The response body for a batch task will contain information about the task. The content will be a little different depending on whether the task in question is a batch task (a parent task) or one task that is part of a batch (a child task).
The following key-value pairs in the response body indicate the batch status of the task:

KeyDatatype of valueDescription
"batch"booleanSet to True if the task is a parent batch task; otherwise False.
"parent"stringThe ID of the parent task, in the case that the task is part of a batch (i.e. a child task).
"batch_group"dictionaryPresent only for child tasks.
This describes the structure of the parent task, i.e. the criteria by which tasks are batched.

1. If tasks are batched per item in the input, the structure is as shown in the following example:

"batch_group": { "value": "C18-146.fastq", "fields": {} }

2. If tasks are batched by metadata fields, the structure is as shown in the following example:

"batch_group": { "value": "hg19, E18127-pool40-L2355", "fields": { "metadata.library_id": "hg19", "metadata.sample_id": "E18127-pool40-L2355" } }
"execution_status"dictionaryFor a parent task, this describes the number of child tasks in any given state, in the following form:

"execution_status": { "message": "Running", "queued": 1, "running": 5, "completed": 2, "failed": 1, "aborted": 0 }

For a child task or a single task (not part of a batch), the execution status lists a number of steps.

Example response body

{
  "href": "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/tasks/48f79ccf-12b3-45b6-789c-b1e8d88dabcd",
  "id": "48f79ccf-12b3-45b6-789c-b1e8d88dabcd",
  "name": "RFranklin, Experiment IV",
  "description": "my draft task",
  "status": "DRAFT",
  "project": "RFranklin/my-project",
  "use_interruptible_instances": true,
  "app": "RFranklin/my-project/new-test-app/0",
  "type": "v2",
  "created_by": "RFranklin",
  "start_time": "2016-01-12T19:20:10Z",
  "inputs": {
    "dispersion_threshold": null,
    "cuffdiff_zip": {
      "class": "File",
      "path": "567890abc9b0307bc0414164",
      "name": "example_human_known_indels.vcf"
    },
    "density_threshold": null,
    "thresholds_off": null
  },
  "outputs": {
    "archive": null,
    "html": null
  }
}