A batchtools backend that resolves futures sequentially in transient background R sessions
Source:R/batchtools_local.R
batchtools_local.RdThe batchtools local backend is useful for verifying parts of your batchtools setup locally, before using a more advanced backend such as the job-scheduler backends.
Arguments
- fs.latency
[
numeric(1)]
Expected maximum latency of the file system, in seconds. Set to a positive number for network file systems like NFS which enables more robust (but also more expensive) mechanisms to access files and directories. Usually safe to set to0to disable the heuristic, e.g. if you are working on a local file system.- delete
Controls if and when the batchtools job registry folder is deleted. If
"on-success"(default), it is deleted if the future was resolved successfully and the expression did not produce an error. If"never", then it is never deleted. If"always", then it is always deleted.- 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.- finalize
If TRUE, a future's batchtools Registry is automatically deleted when the future is garbage collected, otherwise not.
- ...
Not used.
Details
Batchtools local futures use batchtools cluster functions
created by batchtools::makeClusterFunctionsInteractive() with
external = TRUE.
The batchtools local backend is synchronous, that is, the main R process
blocks while a job is running. This means that nothing can be relayed from
a job 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.
An alternative to the batchtools local backend is to use
plan(future::cluster, workers = I(1)).
Examples
library(future)
plan(future.batchtools::batchtools_local)
message("Main process ID: ", Sys.getpid())
#> Main process ID: 2148124
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)
#> hostname os cores pid
#> 1 hb-x1-2023 Linux 8 2148409
#> modules
#> 1 CBI:cmake/4.3.3:r/4.6.2:pandoc/3.12:quarto/1.10.20:port4me/0.7.1:bat/0.26.1:glow/2.1.2:fzf/0.74.4:htop/3.5.1:github-cli/2.102.0:git-flow/1.12.3:git-extras/7.5.0:gitleaks/8.30.1:tea/0.16.0:ripgrep/15.2.0:shellcheck/0.11.0:node/26.0.0:markdownlint-cli/0.49.1:rclone/1.74.4:himalaya/2.2.1:rust/1.97.1:difftastic/0.69.0:osgrep/0.5.16:opencode/1.15.12:bash-startup/0.5.0:restic/0.19.1:deno/2.9.7