Modify a task

Change the details of the specified task, including its name, description, and inputs. The task is referred to by its ID, which you can obtain by making the call to list all tasks you can access.

Note that you can only modify tasks with a task status of DRAFT. Tasks which are RUNNING, QUEUED, ABORTED, COMPLETED or FAILEDcannot be modified in order to enable the reproducibility of analyses which have been queued for execution or has initiated executing.

See the section on task inputs for details on how to refer to a task's inputs.

Request

https://api.sbgenomics.com/v2/tasks/{task_id}
https://eu-api.sbgenomics.com/v2/tasks/{task_id}

Example request

PATCH /v2/tasks/08c5ce64-1551-4b7d-b054-63a1517bc7bb HTTP/1.1
Host: api.sbgenomics.com
X-SBG-Auth-Token: 3259c50e1ac5426ea8f1273259740f74
curl  --data-binary "@modify-task.json" -s -H "X-SBG-Auth-Token: 6282d5e2121d43e7900e9d52b15845e7" -H "content-type: application/json" -X PATCH "https://cgc-api.sbgenomics.com/v2/tasks/08c5ce64-1551-4b7d-b054-63a1517bc7bb"
from sevenbridges import Api

api = Api(url='https://api.sbgenomics.com/v2',
          token='3259c50e1ac5426ea8f1273259740f74')

task = api.tasks.get(id='08c5ce64-1551-4b7d-b054-63a1517bc7bb')

# modify task
task.description = 'my draft task'
task.name = 'RFranklin, Experiment IV'
task.use_interruptible_instances = False
task.execution_settings = {
    "instance_type": "c4.2xlarge;ebs-gp2;2000",
    "max_parallel_instances": 1
}
task.inputs['cuffdiff_zip'] = api.files.get(id='562785e6e4b00a1d67a8b1aa')

# send PATCH request to SB API
task.save()

print(task.name, task.description)

See below for an example of the content of the request, sent here as modify-task.json.

Header Fields

Name

Description

X-SBG-Auth-Token
required

Your Seven Bridges Platform authentication token.

Path parameters

Name

Description

task_id
required

The ID of the task you are querying

Query parameters

Name

Data type

Description

fields

string

Selector specifying a subset of fields to include in the response.

Request body

In the body of the request you should enter key-value pairs, as explained below:

Key

Datatype of value

Description of value

"name"

string

The name of the task

"description"

string

The description of the task

"execution_settings"

dictionary

Detailed task execution parameters:

instance_type: Possible value is the specific instance type, e.g. "c4.2xlarge;ebs-gp2;2000".

max_parallel_instances - Maximum number of instances running at the same time. Takes any integer value equal to or greater than 1, e.g. "max_parallel_instances": 2.

use_memoization - Set to false by default. Set to true to enable memoization.

use_elastic_disk - Set to true to enable Elastic Disk.

"inputs"

dictionary

See the section on specifying task inputs for information on creating input task objects.

"batch"

Boolean

This is set to false by default. Set to true to create a batch task and specify the batch_input and batch-by as described below.

"batch_input"

string

The 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"

dictionary

This 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.

There are two further things to note if you are editing a batch task:

  1. If you want to change the input on which to batch and the batch criteria, you need to specify the batch_input and batch_by parameters together in the same PATCH request.

  2. If you want to disable batching on a task, set batch to false. Or, you can also set the parameters batch_input and batch_by to null.

{
    "batch":false 
}

Example request body

{   "description": "my draft task",
    "name": "RFranklin, Experiment IV",
        "use_interruptible_instances": false,
    "execution_settings": {
            "instance_type": "c4.2xlarge;ebs-gp2;2000",
            "max_parallel_instances": 1
        },
    "inputs": {
        "cuffdiff_zip": {
            "class": "File",
            "path": "562785e6e4b00a1d67a8b1aa",
            "name": "example_human_known_indels.vcf"
        }
    }
}

Response

See a list of Seven Bridges Platform-specific response codes that may be contained in the body of the response.

Example response body

{
  "href": "https://api.sbgenomics.com/v2/tasks/08c5ce64-1551-4b7d-b054-63a1517bc7bb",
  "id": "08c5ce64-1551-4b7d-b054-63a1517bc7bb",
  "name": "RFranklin, Experiment IV",
  "description": "my draft task",
  "status": "DRAFT",
  "project": "RFranklin/my-project",
  "use_interruptible_instances": false,
  "execution_settings": {
            "instance_type": "c4.2xlarge;ebs-gp2;2000",
            "max_parallel_instances": 1
        },
  "app": "RFranklin/my-project/new-test-app/0",
  "type": "v2",
  "created_by": "RFranklin",
  "start_time": "2016-01-12T19:20:10Z",
  "origin_id": "e1b28692-d911-4f2f-9afe-fd0213a64e41",
  "inputs": {
    "dispersion_threshold": null,
    "cuffdiff_zip": {
      "class": "File",
      "path": "562785e6e4b00a1d67a8b1aa",
      "name": "example_human_known_indels.vcf"
    },
    "density_threshold": null,
    "thresholds_off": null
  },
  "outputs": {
    "archive": null,
    "html": null
  }
}