run: Run the stages in a stageRunner object.

Description Usage Arguments Value Examples

Description

Run the stages in a stageRunner object.

Usage

1
2
3
run(from = NULL, to = NULL, verbose = FALSE,
  remember_flag = getOption("stagerunner.remember", TRUE),
  mode = self$.mode, normalized = FALSE, .depth = 1, ...)

Arguments

from

an indexing parameter. Many forms are accepted, but the easiest is the name of the stage. For example, if we have stageRunner$new(context, list(stage_one = some_fn, stage_two = some_other_fn)) then using run('stage_one') will execute some_fn. Additional indexing forms are logical (which stages to execute), numeric (which stages to execute by indices), negative (all but the given stages), character (as above), and nested forms of these. The latter refers to instances of the following: stageRunner$new(context, list(stage_one = stageRunner$new(context, substage_one = some_fn, substage_two = other_fn), stage_two = another_fn)). Here, the following all execute only substage_two: run(list(list(FALSE, TRUE), FALSE)), run(list(list(1, 2))), run('stage_one/substage_two'), run('one/two'), Notice that substrings are allowed for characters. The default is NULL, which runs the whole sequences of stages.

to

an indexing parameter. If from refers to a single stage, attempt to run from that stage to this stage (or, if this one comes first, this stage to that stage). For example, if we have stages = list(a = list(b = 1, c = 2), d = 3, e = list(f = 4, g = 5)) where the numbers are some functions, and we call run with from = 'a/c' and to = 'e/f', then we would execute stages "a/c", "d", "e/f".

verbose

logical. Whether or not to display pretty colored text informing about stage progress. nested list of logicals.

remember_flag

logical. An internal argument used by run recursively if the stageRunner object has the remember field set to TRUE. If remember_flag is FALSE, run will not attempt to restore the context from cache (e.g., if we are executing five stages simultaneously with remember = TRUE, the first stage's context should be restored from cache but none of the remaining stages should).

mode

character. If mode = 'head', then by default the from parameter will be used to execute that stage and that stage only. If mode = 'next', then the from parameter will be used to run (by default, if to is left missing) from the last successfully executed stage to the stage given by from. If from occurs before the last successfully executed stage (say S), the stages will be run from from to S.

normalized

logical. A convenience recursion performance helper. If TRUE, stageRunner will assume the from argument is a nested list of logicals.

.depth

integer. Internal parameter for keeping track of nested execution depth.

...

Any additional arguments to delegate to the stageRunnerNode object that will execute its own run method. (See stageRunnerNode$run)

Value

TRUE or FALSE according as running the stages specified by the from and to keys succeeded or failed. If remember = TRUE, this will instead be a list of the environment before and after executing the aforementioned stages. (This allows comparing what changes were made to the context during the execution of the stageRunner.)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
env <- new.env()
some_fn    <- function(e) e$x <- 1
other_fn   <- function(e) e$y <- 1
another_fn <- function(e) e$z <- 1
sr <- stagerunner(env, list(stage_one =
 stagerunner(env, list(substage_one = some_fn, substage_two = other_fn)),
 stage_two = another_fn))

# Here, the following all execute only substage_two:

sr$run(list(list(FALSE, TRUE), FALSE))
sr$run(list(list(1, 2)))
sr$run('stage_one/substage_two')
sr$run('one/two')
stopifnot(is.null(env$z), is.null(env$x), identical(env$y, 1))

# This will execute all but "stage_one" (i.e., only "stage_two")
sr$run(-1)
stopifnot(identical(env$z, 1))

syberia/stagerunner documentation built on May 30, 2019, 10:41 p.m.