View source: R/BatchtoolsFutureBackend-class.R
| BatchtoolsFutureBackend | R Documentation |
A batchtools local future is a synchronous uniprocess future that will be evaluated in a background R session. A batchtools interactive future is a synchronous uniprocess future that will be evaluated in the current R session (and variables will be assigned to the calling environment rather than to a local one). Both types of futures will block until the futures are resolved.
A batchtools SSH future is an asynchronous multiprocess
future that will be evaluated in a background R session.
We highly recommend using future::multisession
(sic!) futures of the future package instead of
SSH batchtools futures.
BatchtoolsFutureBackend(
workers = 1L,
resources = list(),
finalize = getOption("future.finalize", TRUE),
cluster.functions = NULL,
registry = list(),
conf.file = findConfFile(),
interrupts = TRUE,
delete = getOption("future.batchtools.delete", "on-success"),
...
)
BatchtoolsCustomFutureBackend(...)
BatchtoolsInteractiveFutureBackend(fs.latency = 0, ...)
BatchtoolsLocalFutureBackend(fs.latency = 0, ...)
BatchtoolsSSHFutureBackend(workers = availableWorkers(), fs.latency = 65, ...)
workers |
(optional) The maximum number of workers the batchtools
backend may use at any time. Interactive and "local" backends can only
process one future at the time ( |
resources |
(optional) A named list passed to the batchtools
job-script template as variable
|
finalize |
If TRUE, a future's batchtools Registry is automatically deleted when the future is garbage collected, otherwise not. |
cluster.functions |
(optional) Assigned as-is to the each future's batchtools Registry. |
registry |
(optional) A named list of settings applied to each
future's batchtools Registry.
This is a more convenient alternative to using argument |
conf.file |
(optional) A "batchtools-configuration" R script, which
is sourced when each future's batchtools
Registry is created. Any variables
created by this script is assigned to the registry.
The default file is the one found by |
interrupts |
If FALSE, attempts to interrupt futures will not take place on this backend, even if the backend supports it. This is useful when, for instance, it takes a long time to interrupt a future. |
delete |
Controls if and when the batchtools job registry folder is
deleted.
If |
fs.latency |
[ |
... |
Additional arguments passed to |
Batchtools local futures rely on the batchtools backend set up by
batchtools::makeClusterFunctionsInteractive(external = TRUE)
and batchtools interactive futures on the one set up by
batchtools::makeClusterFunctionsInteractive().
These are supported by all operating systems.
Batchtools local and interactive futures are synchronous, that is, the
main R process blocks while a job is running. Since a batchtools local
job is evaluated in a separate R session, nothing can be relayed from it
until it is done. For example, immediate conditions, such as progress
updates signaled by the progressr package, are relayed first when
the job has finished. To get them as soon as possible, use an
asynchronous backend, e.g. batchtools_multicore() with two or more
workers, or a job scheduler. A batchtools interactive job is evaluated
in the current R session, so immediate conditions are relayed as soon as
they are signaled, just as for sequential futures.
An alternative to batchtools local futures is to use
cluster futures of the future
package with a single local background session, i.e.
plan(cluster, workers = "localhost").
An alternative to batchtools interactive futures is to use
plan(sequential, split = TRUE) futures of the future package.
Batchtools SSH futures rely on the batchtools backend set
up by batchtools::makeClusterFunctionsSSH().
The batchtools SSH backend only works on operating systems
supporting the ssh and ps command-line tool, e.g. Linux and macOS.
A future::FutureBackend object of class BatchtoolsFutureBackend
An object of class BatchtoolsFuture.
An object of class BatchtoolsUniprocessFuture.
library(future)
## Create custom cluster functions (here same as "local")
cf <- batchtools::makeClusterFunctionsInteractive(external = TRUE)
print(cf)
str(cf)
# Use custom batchtools backend
plan(future.batchtools::batchtools_custom, cluster.functions = cf)
print(plan())
message("Main process ID: ", Sys.getpid())
f <- future({
data.frame(
hostname = Sys.info()[["nodename"]],
os = Sys.info()[["sysname"]],
cores = unname(parallelly::availableCores()),
pid = Sys.getpid(),
modules = Sys.getenv("LOADEDMODULES")
)
})
info <- value(f)
print(info)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.