Not a user-side function. Do not call directly.
Arguments
- command
Language object with R code to run.
- name
Character of length 1, name of the task.
- data
Named list of local data objects in the evaluation environment.
- globals
Named list of objects to temporarily assign to the global environment for the task.
- seed
Integer of length 1 with the pseudo-random number generator seed to set for the evaluation of the task. Passed to the
seedargument ofset.seed()if notNULL. Ifalgorithmandseedare bothNULL, then the random number generator defaults to the recommended widely spaced worker-specific L'Ecuyer streams as supported bymirai::nextstream(). Seevignette("parallel", package = "parallel")for details.- algorithm
Integer of length 1 with the pseudo-random number generator algorithm to set for the evaluation of the task. Passed to the
kindargument ofRNGkind()if notNULL. Ifalgorithmandseedare bothNULL, then the random number generator defaults to the recommended widely spaced worker-specific L'Ecuyer streams as supported bymirai::nextstream(). Seevignette("parallel", package = "parallel")for details.- packages
Character vector of packages to load for the task.
- library
Library path to load the packages. See the
lib.locargument ofrequire().- reset_globals
TRUEto reset global environment variables between tasks,FALSEto leave them alone.- reset_packages
TRUEto detach any packages loaded during a task (runs between each task),FALSEto leave packages alone. In either case, the namespaces are not detached.- reset_options
TRUEto reset global options to their original state between each task,FALSEotherwise. It is recommended to only setreset_options = TRUEifreset_packagesis alsoTRUEbecause packages sometimes rely on options they set at loading time. for this and other reasons,reset_optionsonly resets options that were nonempty at the beginning of the task. If your task sets an entirely new option not already inoptions(), thenreset_options = TRUEdoes not delete the option.- garbage_collection
TRUEto run garbage collection after each task task,FALSEto skip.
Details
The crew_eval() function evaluates an R expression
in an encapsulated environment and returns a monad with the results,
including warnings and error messages if applicable.
The random number generator seed, globals, and global options
are restored to their original values on exit.
See also
Other utility:
crew_assert(),
crew_clean(),
crew_deprecate(),
crew_random_name(),
crew_retry(),
crew_terminate_process(),
crew_terminate_signal(),
crew_worker()
Examples
crew_eval(quote(1 + 1), name = "task_name")
#> # A tibble: 1 × 12
#> name command result status error code trace warnings seconds seed algorithm
#> <chr> <chr> <list> <chr> <chr> <int> <chr> <chr> <dbl> <int> <chr>
#> 1 task… 1 + 1 <dbl> succe… NA 0 NA NA 0 NA NA
#> # ℹ 1 more variable: controller <chr>