Create a controller object from a client and launcher.
Source:R/crew_controller.R
crew_controller.Rd
This function is for developers of crew
launcher plugins.
Users should use a specific controller helper such as
crew_controller_local()
.
Arguments
- client
An
R6
client object created bycrew_client()
.- launcher
An
R6
launcher object created by one of thecrew_launcher_*()
functions such ascrew_launcher_local()
.- crashes_max
In rare cases, a worker may exit unexpectedly before it completes its current task. If this happens,
pop()
returns a status of"crash"
instead of"error"
for the task. The controller does not automatically retry the task, but you can retry it manually by callingpush()
again and using the same task name as before. (However,targets
pipelines runningcrew
do automatically retry tasks whose workers crashed.)crashes_max
is a non-negative integer, and it sets the maximum number of allowable consecutive crashes for a given task. If a task's worker crashes more thancrashes_max
times in a row, thenpop()
throws an error when it tries to return the results of the task.- backup
An optional
crew
controller object, orNULL
to omit. If supplied, thebackup
controller runs any pushed tasks that have already reachedcrashes_max
consecutive crashes. Usingbackup
, you can create a chain of controllers with different levels of resources (such as worker memory and CPUs) so that a task that fails on one controller can retry using incrementally more powerful workers. All controllers in a backup chain should be part of the same controller group (seecrew_controller_group()
) so you can call the group-levelpop()
andcollect()
methods to make sure you get results regardless of which controller actually ended up running the task.Limitations of
backup
: *crashes_max
needs to be positive in order forbackup
to be used. Otherwise, every task would always skip the current controller and go tobackup
. *backup
cannot be a controller group. It must be an ordinary controller.- auto_scale
Deprecated. Use the
scale
argument ofpush()
,pop()
, andwait()
instead.
See also
Other controller:
crew_class_controller
Examples
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
launcher <- crew_launcher_local()
controller <- crew_controller(client = client, launcher = launcher)
controller$start()
controller$push(name = "task", command = sqrt(4))
controller$wait()
controller$pop()
controller$terminate()
}