Skip to contents

R6 Class representing a resource for managing tasks.

Super class

sevenbridges2::Item -> Task

Public fields

URL

List of URL endpoints for this resource.

id

The ID of the task.

name

The name of the task.

status

Task status (different from execution_status). Allowed values:

  • QUEUED

  • DRAFT

  • RUNNING

  • COMPLETED

  • ABORTED

  • FAILED

description

An optional description of a task.

project

Identifier of the project that the task is located in.

app

The identifier of the app that was used for the task.

created_by

Username of the task creator.

executed_by

Username of the task executor.

created_on

The time in form of string when the task was created.

start_time

Task start time in form of string.

end_time

Task end time in form of string .

origin

Id of the entity that created the task, e.g. automation run, if task was created by an automation run.

use_interruptable_instances

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

batch

TRUE for batch tasks, FALSE for regular and child tasks (batch this task; if FALSE, will not create a batch task).

batch_by

Batching criteria (list).

batch_group

Batch group for a batch task (list). Represents the group that is assigned to the child task from the batching criteria that was used when the task was started.

batch_input

Input identifier on to which to apply batching.

batch_parent

Parent task ID for a batch child. (batch task which is the parent of this task).

execution_settings

Execution settings list for the task.

execution_status

Task execution status list - info about current execution status.

errors

Validations errors list stored as a high-level errors array property in the API response.

warnings

Validation warnings list from API response.

price

Task cost (list) - contains amount and currency.

inputs

List of inputs that were submitted to the task.

outputs

List of generated outputs from the task.

output_location

List of locations where task outputs will be stored.

Methods


Method new()

Create new Task object.

Usage

Task$new(res = NA, ...)

Arguments

res

Response containing Task object information.

...

Other response arguments.


Method print()

Print method for Task class.

Usage

Task$print()

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Print task object
 task_object$print()
}


Method reload()

Reload Task object information.

Usage

Task$reload(...)

Arguments

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Reload task object
 task_object$reload()
}


Method run()

This call runs (executes) the task. Only tasks whose status is DRAFT can be run.

Usage

Task$run(
  batch = NULL,
  use_interruptible_instances = NULL,
  in_place = TRUE,
  ...
)

Arguments

batch

Set this to FALSE to disable the default batching for this task. Running a batch task is a recommended way to run multiple tasks considering the API rate limit (learn more).

use_interruptible_instances

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

in_place

Default TRUE. Should the new object of Task class be returned or the current to be reinitialized.

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Run task
 task_object$run()
}


Method abort()

This call aborts the specified task. Only tasks whose status is RUNNING or QUEUED may be aborted.

Usage

Task$abort(in_place = TRUE, ...)

Arguments

in_place

Default TRUE. Should the new object of Task class be returned or the current to be reinitialized.

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

. # Run task
 task_object$run()

 # Then abort task
 task_object$abort()
}


Method clone_task()

This call clones the specified task. Once cloned, the task can either be in DRAFT mode or immediately ran, by setting the run parameter to TRUE.

Usage

Task$clone_task(run = FALSE, ...)

Arguments

run

Set this to TRUE in order to create a draft task and execute it immediately. Default: FALSE.

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Clone task object
 task_object$clone_task()
}


Method get_execution_details()

This call returns execution 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 call breaks down the information into the task's distinct jobs. A job is a single subprocess carried out in a task. The information returned by this call is broadly similar to that which can be found in the task stats and logs provided on the Platform. The task execution details include the following information:

  • The name of the command line job that executed

  • The start time of the job

  • End time of the job (if it completed)

  • The status of the job (DONE, FAILED, or RUNNING)

  • Information on the computational instance that the job was run on, including the provider ID, the type of instance used and the cloud service provider

  • A link that can be used to download the standard error logs for the job.

  • SHA hash of the Docker image ('checksum').

Usage

Task$get_execution_details(...)

Arguments

...

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

Returns

List of execution details.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Get task execution details
 task_object$get_execution_details()
}


Method list_batch_children()

This call retrieves batch child tasks for this task if its a batch task.

Usage

Task$list_batch_children(
  status = NULL,
  project = NULL,
  created_from = NULL,
  created_to = NULL,
  started_from = NULL,
  started_to = NULL,
  ended_from = NULL,
  ended_to = NULL,
  order_by = NULL,
  order = NULL,
  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.

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.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # List batch children of a task
 task_object$list_batch_children()
}


Method delete()

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

Usage

Task$delete(...)

Arguments

...

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

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Delete task
 task_object$delete()
}


Method rerun()

This call reruns (executes) the specified task.

Usage

Task$rerun(...)

Arguments

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Rerun task
 task_object$rerun()
}


Method update()

Change the details of the specified task, including its name, description, and inputs. Note that you can only modify tasks with a task status of DRAFT. Tasks which are RUNNING, QUEUED, ABORTED, COMPLETED or FAILED cannot be modified in order to enable the reproducibility of analyses which have been queued for execution or has initiated executing. There are two 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 function call.

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

Usage

Task$update(
  name = NULL,
  description = NULL,
  execution_settings = NULL,
  inputs = NULL,
  output_location = NULL,
  batch = NULL,
  batch_input = NULL,
  batch_by = NULL,
  ...
)

Arguments

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

...

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

Returns

Task object.

Examples

\dontrun{
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Update task
 task_object$update(name = new_name)
}


Method clone()

The objects of this class are cloneable with this method.

Usage

Task$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Task$print`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Print task object
 task_object$print()
}


## ------------------------------------------------
## Method `Task$reload`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Reload task object
 task_object$reload()
}


## ------------------------------------------------
## Method `Task$run`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Run task
 task_object$run()
}


## ------------------------------------------------
## Method `Task$abort`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

. # Run task
 task_object$run()

 # Then abort task
 task_object$abort()
}


## ------------------------------------------------
## Method `Task$clone_task`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Clone task object
 task_object$clone_task()
}


## ------------------------------------------------
## Method `Task$get_execution_details`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Get task execution details
 task_object$get_execution_details()
}


## ------------------------------------------------
## Method `Task$list_batch_children`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # List batch children of a task
 task_object$list_batch_children()
}


## ------------------------------------------------
## Method `Task$delete`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Delete task
 task_object$delete()
}


## ------------------------------------------------
## Method `Task$rerun`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Rerun task
 task_object$rerun()
}


## ------------------------------------------------
## Method `Task$update`
## ------------------------------------------------

if (FALSE) {
# x is API response when task is requested
task_object <- Task$new(
                    res = x,
                    href = x$href,
                    auth = auth,
                    response = attr(x, "response")
                   )

 # Update task
 task_object$update(name = new_name)
}