Options controlling resources, scheduling and evaluation of futures
Source:R/futurize_options.R
futurize_options.RdSome futures require specific resources and capabilities (e.g., RNG, packages, and globals) in order to be evaluated. These can be declared via this function. In addition, this function can control how futures are evaluated, including what is collected from futures (e.g., standard output and conditions). It can also control how future are scheduled, including how a set of futures are partitioned (e.g. chunking).
Usage
futurize_options(
rng = FALSE,
seed = FALSE,
globals = TRUE,
packages = NULL,
stdout = TRUE,
conditions = "condition",
scheduling = 1,
chunk_size = NULL,
...
)Arguments
- rng
(resources) If TRUE, parallel-safe random number generation (RNG) is set up such that each element is processed with its own, statistically sound RNG stream. This is needed whenever the code uses random numbers, e.g. via
rnorm()orsample(). The results are reproducible given a fixedset.seed(), regardless of how and where the elements are processed. Currently, the L'Ecuyer-CMRG RNG is used for this. If FALSE (default), then no RNG streams are set up, and you will be warned if random numbers are still generated. If NA, then no RNG streams are set up, and there is no check for random numbers being generated. This can be used to silence false-positive RNG warnings, e.g. when the code uses random numbers in a way that does not affect the results. If in doubt, userng = TRUE, which is always statistically sound. Currently, onlyTRUE,FALSE, andNAare supported; other types of values are reserved for future extensions. Ifrngis specified, thenseedmust not be specified.- seed
(resources) Superseded by
rng, but kept for backward compatibility.seed = TRUE,seed = FALSE, andseed = NULLare equivalent torng = TRUE,rng = FALSE, andrng = NA. For other values, see theseedargument offuture::future().- globals
(resource; optional) a logical, a character vector, or a named list to control how globals are handled. For details, see section 'Globals used by future expressions' in the help for
future().- packages
(resource; optional) a character vector specifying packages to be attached in the R environment evaluating the future, in addition to packages required by global variables specified or identified via argument
globals.- stdout
(evaluation) If TRUE (default), then the standard output is captured, and re-outputted when
value()is called. If FALSE, any output is silenced (by sinking it to the null device as it is outputted). Usingstdout = structure(TRUE, drop = TRUE)causes the captured standard output to be dropped from the future object as soon as it has been relayed. This can help decrease the overall memory consumed by captured output across futures. Usingstdout = NAfully avoids intercepting the standard output; behavior of such unhandled standard output depends on the future backend.- conditions
(evaluation) A character string of condition classes to be captured and relayed. The default is to relay all conditions, including messages and warnings. To drop all conditions, use
conditions = character(0). Errors are always relayed. Attributeexcludecan be used to ignore specific classes, e.g.conditions = structure("condition", exclude = "message")will capture allconditionclasses except those that inherit from themessageclass. Usingconditions = structure(..., drop = TRUE)causes any captured conditions to be dropped from the future object as soon as they have been relayed, e.g. byvalue(f). This can help decrease the overall memory consumed by captured conditions across futures. Usingconditions = NULL(not recommended) avoids intercepting conditions, except from errors; behavior of such unhandled conditions depends on the future backend and the environment from which R runs.- scheduling
(scheduling) Average number of futures ("chunks") per worker. If
0.0, then a single future is used to process all elements. If1.0orTRUE, then one future per worker is used. If2.0, then each worker will process two futures (if there are enough elements). IfInforFALSE, then one future per element is used. Only used ifchunk_sizeisNULL.- chunk_size
(scheduling) The average number of elements per future ("chunk"). If
Inf, then all elements are processed in a single future. IfNULL, then argumentschedulingis used.- ...
Additional named options.
Value
A named list of future options.
Attribute specified is a character vector of future options
that were explicitly specified.
Examples
# Default futurize options
str(futurize_options())
#> List of 7
#> $ seed : logi FALSE
#> $ globals : logi TRUE
#> $ packages : NULL
#> $ stdout : logi TRUE
#> $ conditions: chr "condition"
#> $ scheduling: num 1
#> $ chunk_size: NULL
#> - attr(*, "specified")= chr(0)
# Declare that parallel random number generation is needed
str(futurize_options(rng = TRUE))
#> List of 7
#> $ seed : logi TRUE
#> $ globals : logi TRUE
#> $ packages : NULL
#> $ stdout : logi TRUE
#> $ conditions: chr "condition"
#> $ scheduling: num 1
#> $ chunk_size: NULL
#> - attr(*, "specified")= chr "seed"