| queue_base | R Documentation |
A base class, on top of which queues can be developed. This includes all methods except for support for actually submitting tasks.
contextThe context object
new()Constructor
queue_base$new(context_id, root = NULL, initialize = TRUE)
context_idA context identifier; either a context
object or an name/id of a saved context (see
context::context_save()).
rootRoot path to load contexts from, if using a string
identifier for context_id. If context_id is a context
object then root must be NULL.
initializeLogical, indicating if the context should be
loaded immediately. If you want to run tasks this must be
TRUE, but to query it can be FALSE. See
context::context_load() and the $initialise_context() method.
initialize_context()Load the context. This causes the packages to be loaded and all script files to be sourced. This is required before any tasks can be queued, because we need to be check against this environment to work out what is available on any workers.
queue_base$initialize_context()
task_list()List all tasks known to this queue
queue_base$task_list()
task_status()Return the status of selected tasks
queue_base$task_status(task_ids = NULL, named = TRUE)
task_idsTask identifiers to query. If NULL, then all
tasks are queried.
namedLogical, indicating if the status result should be named by by task id.
task_times()Return the times taken by tasks as a data.frame
queue_base$task_times(task_ids = NULL, unit_elapsed = "secs", sorted = TRUE)
task_idsTask identifiers to query. If NULL, then all
tasks are queried.
unit_elapsedTime unit to use for the elapsed fields
sortedLogical indicating of the fields should be sorted by submitted time.
task_get()Retrieve a task by id
queue_base$task_get(task_id, check_exists = TRUE)
task_idA task identifier (hexadecimal string)
check_existsLogical, indicating if we should check that the task exists.
task_result()Retrieve a task's result
queue_base$task_result(task_id)
task_idA task identifier (hexadecimal string)
task_delete()Delete tasks
queue_base$task_delete(task_ids)
task_idsA vector of task identifiers (each a hexadecimal string)
task_retry_failed()Retry failed tasks
queue_base$task_retry_failed(task_ids)
task_idsA vector of task identifiers (each a hexadecimal string)
task_bundle_list()List all known task bundles
queue_base$task_bundle_list()
task_bundle_info()List all known task bundles along with information about what was run and when.
queue_base$task_bundle_info()
task_bundle_get()Get a task bundle by name
queue_base$task_bundle_get(name)
nameA task bundle identifier (a string of the form
adjective_anmimal)
task_bundle_retry_failed()Retry failed tasks in a bundle
queue_base$task_bundle_retry_failed(name)
nameA task bundle identifier (a string of the form
adjective_anmimal)
enqueue()Queue a task
queue_base$enqueue( expr, envir = parent.frame(), submit = TRUE, name = NULL, depends_on = NULL )
exprAn unevaluated expression to put on the queue
envirThe environment that you would run this expression in
locally. This will be used to copy across any dependent variables.
For example, if your expression is sum(1 + a), we will also send
the value of a to the worker along with the expression.
submitLogical indicating if the task should be submitted
nameOptional name for the task
depends_onOptional vector of task ids to depend on
enqueue_()Queue a task
queue_base$enqueue_( expr, envir = parent.frame(), submit = TRUE, name = NULL, depends_on = NULL )
exprA quoted expression to put on the queue
envirThe environment that you would run this expression in
locally. This will be used to copy across any dependent variables.
For example, if your expression is sum(1 + a), we will also send
the value of a to the worker along with the expression.
submitLogical indicating if the task should be submitted
nameOptional name for the task
depends_onOptional vector of task ids to depend on
enqueue_bulk()Send a bulk set of tasks to your workers.
This function is a bit like a mash-up of Map and do.call,
when used with a data.frame argument, which is typically what
is provided. Rather than $lapply() which applies FUN to each
element of X, enqueue_bulk will apply over each row of X, spreading the columms out as arguments. If you have a function f(a, b)and a [data.frame] with columnsaandb' this
should feel intuitive.
queue_base$enqueue_bulk( X, FUN, ..., do_call = TRUE, envir = parent.frame(), timeout = 0, time_poll = 1, progress = NULL, name = NULL, overwrite = FALSE, depends_on = NULL )
XTypically a data.frame, which you want to apply FUN
over, row-wise. The names of the data.frame must match the
arguments of your function.
FUNA function
...Additional arguments to add to every call to FUN
do_callLogical, indicating if each row of X should be
treated as if it was do.call(FUN, X[i, ]) - typically this is what
you want.
envirThe environment to use to try and find the function
timeoutOptional timeout, in seconds, after which an error will be thrown if the task has not completed.
time_pollOptional time with which to "poll" for completion.
progressOptional logical indicating if a progress bar
should be displayed. If NULL we fall back on the value of the
global option rrq.progress, and if that is unset display a
progress bar if in an interactive session.
nameOptional name for a created bundle
overwriteLogical, indicating if we should overwrite any
bundle that exists with name name.
depends_onOptional task ids to depend on (see
context::bulk_task_save()).
lapply()Apply a function over a list of data. This is
equivalent to using $enqueue() over each element in the list.
queue_base$lapply( X, FUN, ..., envir = parent.frame(), timeout = 0, time_poll = 1, progress = NULL, name = NULL, overwrite = FALSE, depends_on = NULL )
XA list of data to apply our function against
FUNA function to be applied to each element of X
...Additional arguments to add to every call to FUN
envirThe environment to use to try and find the function
timeoutOptional timeout, in seconds, after which an error will be thrown if the task has not completed.
time_pollOptional time with which to "poll" for completion.
progressOptional logical indicating if a progress bar
should be displayed. If NULL we fall back on the value of the
global option rrq.progress, and if that is unset display a
progress bar if in an interactive session.
nameOptional name for a created bundle
overwriteLogical, indicating if we should overwrite any
bundle that exists with name name.
depends_onOptional task ids to depend on (see
context::bulk_task_save()).
mapply()A wrapper like mapply
Send a bulk set of tasks to your workers.
This function is a bit like a mash-up of Map and do.call,
when used with a data.frame argument, which is typically what
is provided. Rather than $lapply() which applies FUN to each
element of X, enqueue_bulk will apply over each row of X, spreading the columms out as arguments. If you have a function f(a, b)and a [data.frame] with columnsaandb' this
should feel intuitive.
queue_base$mapply( FUN, ..., MoreArgs = NULL, envir = parent.frame(), timeout = 0, time_poll = 1, progress = NULL, name = NULL, use_names = TRUE, overwrite = FALSE, depends_on = NULL )
FUNA function
...Additional arguments to add to every call to FUN
MoreArgsAs for mapply, additional arguments that apply to every function call.
envirThe environment to use to try and find the function
timeoutOptional timeout, in seconds, after which an error will be thrown if the task has not completed.
time_pollOptional time with which to "poll" for completion.
progressOptional logical indicating if a progress bar
should be displayed. If NULL we fall back on the value of the
global option rrq.progress, and if that is unset display a
progress bar if in an interactive session.
nameOptional name for a created bundle
use_namesUse names
overwriteLogical, indicating if we should overwrite any
bundle that exists with name name.
depends_onOptional task ids to depend on (see
context::bulk_task_save()).
XTypically a data.frame, which you want to apply FUN
over, row-wise. The names of the data.frame must match the
arguments of your function.
submit()Submit a task into a queue. This is a stub method and must be overridden by a derived class for the queue to do anything.
queue_base$submit(task_ids, names = NULL, depends_on = NULL)
task_idsVector of tasks to submit
namesOptional vector of names of tasks
depends_onOptional named list of task ids to vectors of dependencies, e.g. list("t3" = c("t", "t1"), "t4" = "t)
unsubmit()Unsubmit a task from the queue. This is a stub method and must be overridden by a derived class for the queue to do anything.
queue_base$unsubmit(task_ids)
task_idsVector of tasks to submit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.