R Under development (unstable) (2025-06-05 r88281 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > source("incl/start,load-only.R") > > message("*** plan() ...") *** plan() ... > > message("*** future::plan(future.batchtools::batchtools_local)") *** future::plan(future.batchtools::batchtools_local) > oplan <- future::plan(future.batchtools::batchtools_local) > print(future::plan()) batchtools_local: - args: function (..., envir = parent.frame(), workers = "") - tweaked: FALSE - call: future::plan(future.batchtools::batchtools_local) > future::plan(oplan) > print(future::plan()) batchtools_local: - args: function (..., envir = parent.frame(), workers = "") - tweaked: FALSE - call: future::plan(future.batchtools::batchtools_local) > > > library("future.batchtools") Loading required package: parallelly Loading required package: future > > for (type in c("batchtools_interactive", "batchtools_local")) { + mprintf("*** plan('%s') ...\n", type) + + plan(type) + stopifnot(inherits(plan("next"), "batchtools")) + + a <- 0 + f <- future({ + b <- 3 + c <- 2 + a * b * c + }) + a <- 7 ## Make sure globals are frozen + v <- value(f) + print(v) + stopifnot(v == 0) + + + ## Customize the 'work.dir' of the batchtools registries + normalize_path <- function(path) { + if (!utils::file_test("-d", path)) stop("No such path: ", path) + opwd <- getwd() + on.exit(setwd(opwd)) + setwd(normalizePath(path)) + getwd() + } + plan(type, registry = list(work.dir = NULL)) + f <- future(42, lazy = TRUE) + ## In future releases, lazy futures may stay vanilla Future objects + if (inherits(f, "BatchtoolsFuture")) { + if (!is.null(f$config$reg)) { + utils::str(list( + normalize_path(f$config$reg$work.dir), + getwd = getwd() + )) + stopifnot(normalize_path(f$config$reg$work.dir) == getwd()) + } + } + + path <- tempdir() + plan(type, registry = list(work.dir = path)) + f <- future(42, lazy = TRUE) + ## In future releases, lazy futures may stay vanilla Future objects + if (inherits(f, "BatchtoolsFuture")) { + if (!is.null(f$config$reg)) { + utils::str(list( + normalize_path(f$config$reg$work.dir), + path = normalize_path(path) + )) + stopifnot(normalize_path(f$config$reg$work.dir) == normalize_path(path)) + } + } + + mprintf("*** plan('%s') ... DONE\n", type) + } # for (type ...) *** plan('batchtools_interactive') ... [04:39:23.952] Launched future #1 [1] 0 Warning: Detected 1 unknown future arguments: 'registry' Warning: Detected 1 unknown future arguments: 'registry' *** plan('batchtools_interactive') ... DONE *** plan('batchtools_local') ... [04:39:25.428] Launched future #1 [1] 0 Warning: Detected 1 unknown future arguments: 'registry' Warning: Detected 1 unknown future arguments: 'registry' *** plan('batchtools_local') ... DONE > > > message("*** Assert that default backend can be overridden ...") *** Assert that default backend can be overridden ... > > mpid <- Sys.getpid() > print(mpid) [1] 186724 > > plan(batchtools_interactive) > pid %<-% { Sys.getpid() } [04:39:26.195] Launched future #1 > print(pid) [1] 186724 > stopifnot(pid == mpid) > > plan(batchtools_local) > pid %<-% { Sys.getpid() } [04:39:27.590] Launched future #1 > print(pid) [1] 134644 > stopifnot(pid != mpid) > > > message("*** plan() ... DONE") *** plan() ... DONE > > source("incl/end.R") > > proc.time() user system elapsed 1.95 0.37 5.53