| Task {sevenbridges2} | R Documentation |
R6 Class representing a Task
Description
R6 Class representing a resource for managing tasks.
Super class
sevenbridges2::Item -> Task
Public fields
URLList of URL endpoints for this resource.
idThe ID of the task.
nameThe name of the task.
statusTask status (different from execution_status). Allowed values:
QUEUED
DRAFT
RUNNING
COMPLETED
ABORTED
FAILED
descriptionAn optional description of a task.
projectIdentifier of the project that the task is located in.
appThe identifier of the app that was used for the task.
created_byUsername of the task creator.
executed_byUsername of the task executor.
created_onThe time in form of string when the task was created.
start_timeTask start time in form of string.
end_timeTask end time in form of string .
originId of the entity that created the task, e.g. automation run, if task was created by an automation run.
use_interruptable_instancesThis field can be
TRUEorFALSE. Set this field toTRUEto allow the use of spot instances.batchTRUEfor batch tasks,FALSEfor regular and child tasks (batch this task; ifFALSE, will not create a batch task).batch_byBatching criteria (list).
batch_groupBatch 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_inputInput identifier on to which to apply batching.
batch_parentParent task ID for a batch child. (batch task which is the parent of this task).
execution_settingsExecution settings list for the task.
execution_statusTask execution status list - info about current execution status.
errorsValidations errors list stored as a high-level errors array property in the API response.
warningsValidation warnings list from API response.
priceTask cost (list) - contains amount and currency.
inputsList of inputs that were submitted to the task.
outputsList of generated outputs from the task.
output_locationList of locations where task outputs will be stored.
Methods
Public methods
Method new()
Create new Task object.
Usage
Task$new(res = NA, ...)
Arguments
resResponse 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
batchSet this to
FALSEto 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_instancesThis field can be
TRUEorFALSE. Set this field toTRUEto allow the use of spot instances.in_placeDefault
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_placeDefault
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
runSet this to
TRUEin 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, orRUNNING)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
statusYou 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.
projectProvide the project ID or Project object you wish to list the tasks from.
created_fromEnter the starting date string for querying tasks created on the specified date and onwards.
created_toEnter the ending date string for querying tasks created until the specified date. You can use it in combination with
created_fromto specify a time interval.started_fromEnter the starting date string for querying tasks started on the specified date and onwards.
started_toEnter the ending date string for querying tasks started until the specified date.
ended_fromEnter the starting date string for querying tasks that ended on a specified date.
ended_toEnter the ending date string for querying tasks that ended until a specified date.
order_byOrder returned results by the specified field. Allowed values:
created_time,start_time,name,end_timeandcreated_by.
Sort can be done only by one column. The default value iscreated_time.orderSort results in ascending or descending order by specifying
ascordesc, respectively. Only taken into account iforder_byis explicitly specified. The default value isasc.origin_idEnter an automation run ID to list all tasks created from the specified automation run.
limitThe maximum number of collection items to return for a single request. Minimum value is
1. The maximum value is100and the default value is50. This is a pagination-specific attribute.offsetThe 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:
-
1If 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. -
2If 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
nameThe name of the task.
descriptionAn optional description of the task.
execution_settingsNamed 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 toFALSEby default. Set toTRUEto enable memoization; -
use_elastic_disk: Set toTRUEto 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 )
-
inputsList 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_locationThe 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 toTRUEto be able to define individual locations per output node. Default:FALSE. Even if nodes_override is set toTRUE, 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 asvolumes://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://).
-
-
batchThis is set to
FALSEby default. Set toTRUEto create a batch task and specify thebatch_inputandbatch-bycriteria as described below.batch_inputThe 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_byBatching 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
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## Method `Task$print`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$reload`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$run`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$abort`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$clone_task`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$get_execution_details`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$list_batch_children`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$delete`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$rerun`
## ------------------------------------------------
## Not run:
# 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()
## End(Not run)
## ------------------------------------------------
## Method `Task$update`
## ------------------------------------------------
## Not run:
# 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)
## End(Not run)