Skip to contents

R6 Class representing tasks resource endpoints.

Super class

sevenbridges2::Resource -> Tasks

Public fields

URL

List of URL endpoints for this resource.

Methods


Method new()

Create new Tasks resource object.

Usage

Tasks$new(...)

Arguments

...

Other response arguments.


Method query()

This call lists all tasks you can access.

Read more about how to use query parameters properly here.

Usage

Tasks$query(
  status = NULL,
  parent = NULL,
  project = NULL,
  created_from = NULL,
  created_to = NULL,
  started_from = NULL,
  started_to = NULL,
  ended_from = NULL,
  ended_to = NULL,
  order_by = c("created_time", "start_time", "name", "end_time", "created_by"),
  order = c("asc", "desc"),
  origin_id = NULL,
  limit = getOption("sevenbridges2")$limit,
  offset = getOption("sevenbridges2")$offset,
  ...
)

Arguments

status

You can filter the returned tasks by their status. Set the value of status to one of the following values: QUEUED, DRAFT, RUNNING, COMPLETED, ABORTED, FAILED.

parent

Provide task ID or Task object of the parent task to return all child tasks from that parent. 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 how to run tasks in batches.

project

Provide the project ID or Project object you wish to list the tasks from.

created_from

Enter the starting date string for querying tasks created on the specified date and onwards.

created_to

Enter the ending date string for querying tasks created until the specified date. You can use it in combination with created_from to specify a time interval.

started_from

Enter the starting date string for querying tasks started on the specified date and onwards.

started_to

Enter the ending date string for querying tasks started until the specified date.

ended_from

Enter the starting date string for querying tasks that ended on a specified date.

ended_to

Enter the ending date string for querying tasks that ended until a specified date.

order_by

Order returned results by the specified field. Allowed values:
created_time, start_time, name, end_time and created_by.
Sort can be done only by one column. The default value is created_time.

order

Sort results in ascending or descending order by specifying asc or desc, respectively. Only taken into account if order_by is explicitly specified. The default value is asc.

origin_id

Enter an automation run ID to list all tasks created from the specified automation run.

limit

The maximum number of collection items to return for a single request. Minimum value is 1. The maximum value is 100 and the default value is 50. This is a pagination-specific attribute.

offset

The zero-based starting index in the entire collection of the first item to return. The default value is 0. This is a pagination-specific attribute.

...

Other arguments that can be passed to core api() function like 'fields', etc.

Returns

Collection of Task objects.


Method get()

This call returns details of the specified task. The task is referred to by its ID, which you can obtain by making the call to list all tasks you can access. The task details include its creator, its start and end time, the number of jobs completed in it, and its input and output files. You can also see the status of the task.

Usage

Tasks$get(id, ...)

Arguments

id

The ID of the task you are querying.

...

Other arguments that can be passed to core api() function like 'fields', etc.

Returns

Task object.


Method delete()

This call deletes a task from the Seven Bridges Platform. Tasks are specified by their IDs, which you can obtain by using Tasks$query() to list tasks or by getting a single task using Tasks$get().

Usage

Tasks$delete(task, ...)

Arguments

task

Task object or task ID.

...

Other arguments that can be passed to core api() function as 'fields', etc.


Method create()

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. the documentation on batching tasks for more details on batching criteria.

Usage

Tasks$create(
  project,
  app,
  revision = NULL,
  name = NULL,
  description = NULL,
  execution_settings = NULL,
  inputs = NULL,
  output_location = NULL,
  batch = NULL,
  batch_input = NULL,
  batch_by = NULL,
  use_interruptible_instances = NULL,
  action = NULL,
  ...
)

Arguments

project

The ID of a project or a Project object where you want to create the task in.

app

The ID of an app or an App object you want to run. Recall that apps are specified by their projects, in the form <project_id>/<app_name>.

revision

The app revision (version) number.

name

The name of the task.

description

An optional description of the task.

execution_settings

Named list with detailed task execution parameters. Detailed task execution parameters:

  • instance_type: Possible value is the specific instance type, e.g. "instance_type" = "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.

Here is an example:

execution_settings <- list(
  "instance_type" = "c4.2xlarge;ebs-gp2;2000",
  "max_parallel_instances" = 2,
  "use_memoization" = TRUE,
  "use_elastic_disk" = TRUE
  )

inputs

List of objects. See the section on specifying task inputs for information on creating task input objects. Here is an example with various input types:

inputs <- list(
  "input_file"= "<file_id/file_object>",
  "input_directory" = "<folder_id/folder_object>",
  "input_array_string" = list("<string_elem_1>", "<string_elem_2>"),
  "input_boolean" = TRUE,
  "input_double" = 54.6,
  "input_enum" = "enum_1",
  "input_float" = 11.2,
  "input_integer" = "asdf",
  "input_long" = 4212,
  "input_string" = "test_string",
  "input_record" = list(
    "input_record_field_file" = "<file_id/file_object>",
    "input_record_field_integer" = 42
   )
  )

output_location

The output location list allows you to define the exact location where your task outputs will be stored. The location can either be defined for the entire project using the main_location parameter, or individually per each output node, by setting the nodes_override parameter to true and defining individual output node locations within nodes_location. See below for more details.

  • main_location - Defines the output location for all output nodes in the task. Can be a string path within the project in which the task is created, for example
    /Analysis/<task_id>_<task_name>/
    or a path on an attached volume, such as
    volumes://volume_name/<project_id>/html.
    Parts of the path enclosed in angle brackets <> are tokens that are dynamically replaced with corresponding values during task execution.

  • main_location_alias: The string location (path) in the project that will point to the actual location where the outputs are stored. Used if main_location is defined as a volume path (starting with volumes://), to provide an easy way of accessing output data directly from project files.

  • nodes_override: Enables defining of output locations for output nodes individually through nodes_location (see below). Set to TRUE to be able to define individual locations per output node. Default: FALSE. Even if nodes_override is set to TRUE, it is not necessary to define output locations for each of the output nodes individually. Data from those output nodes that don't have their locations explicitly defined through nodes_location is either placed in main_location (if defined) or at the project files root if a main output location is not defined for the task.

  • nodes_location: List of output paths for individual task output nodes in the following format for each output node:
    <output-node-id> = list(
    "output_location" = "<output-path>",
    "output_location_alias" = "<alias-path>"
    )
    Example:

    b64html = list(
     "output_location" = "volumes://outputs/tasks/mar-19",
     "output_location_alias" = "/rfranklin/tasks/picard"
    )

     In the example above, b64html is the ID of the output node for which
     you want to define the output location, while the parameters are
     defined as follows:

    • output_location - Can be a path within the project in which the task is created, for example /Analysis/<task_id>_<task_name>/ or a path on an attached volume, such as volumes://volume_name/<project_id>/html. Also accepts tokens.

    • output_location_alias - The location (path) in the project that will point to the exact location where the output is stored. Used if output_location is defined as a volume path (starting with volumes://).

batch

This 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

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

Batching criteria in form of list. For example:

batch_by = list(
  type = "CRITERIA",
  criteria = list("metadata.condition")
)

use_interruptible_instances

This field can be TRUE or FALSE. Set this field to TRUE to allow the use of spot instances.

action

If set to run, the task will be run immediately upon creation.

...

Other arguments that can be passed to core api() function like 'fields', etc.

Returns

Task object.


Method bulk_get()

This call returns statistics for all specified tasks.

Usage

Tasks$bulk_get(tasks)

Arguments

tasks

A list of Task objects or list of strings (IDs) of the tasks you are requesting the statistics for.

Returns

Collection (list of Task objects).

Examples

\dontrun{
 # Get details of multiple tasks
 a$tasks$bulk_get(
               tasks = list("task_1_ID", "task_2_ID")
              )
}


Method clone()

The objects of this class are cloneable with this method.

Usage

Tasks$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Tasks$bulk_get`
## ------------------------------------------------

if (FALSE) {
 # Get details of multiple tasks
 a$tasks$bulk_get(
               tasks = list("task_1_ID", "task_2_ID")
              )
}