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.R") Loading required package: parallelly Loading required package: future > library("batchtools") > library("listenv") > > message("*** batchtools_custom() ...") *** batchtools_custom() ... > > message("*** batchtools_custom() w/ 'conf.file' on R_BATCHTOOLS_SEARCH_PATH") *** batchtools_custom() w/ 'conf.file' on R_BATCHTOOLS_SEARCH_PATH > > f <- batchtools_custom({ + 42L + }) [04:37:06.872] Launched future #1 > print(f) BatchtoolsCustomFuture: Label: Expression: { 42L } Globals: Packages: L'Ecuyer-CMRG RNG seed: (seed = FALSE) Capture standard output: TRUE Capture condition classes: 'condition' (excluding '') Immediate condition classes: 'immediateCondition' Lazy evaluation: FALSE Local evaluation: TRUE Asynchronous evaluation: TRUE Early signaling: FALSE Environment: R_GlobalEnv State: 'running' Resolved: TRUE Unique identifier: 6e4e041b10eebac09d1fd9a3cad71818-1 Owner process: 6e4e041b10eebac09d1fd9a3cad71818 Class: 'BatchtoolsCustomFuture', 'BatchtoolsFuture', 'Future', 'environment' Value: Conditions captured: batchtools configuration file: 'D:/RCompile/CRANincoming/R-devel/lib/future.batchtools/templates-for-R_CMD_check/batchtools.conf.R' (82 bytes; 1 lines) batchtools cluster functions: 'Interactive' batchtools cluster functions template: batchtools status: 'defined', 'finished', 'started', 'submitted' batchtools Registry: File dir exists: TRUE Work dir exists: TRUE Job Registry Backend : Interactive File dir : D:/temp/2025_06_06_04_35_16_24916/RtmpOo6m8k/.future/20250606_043704-Oo6m8k/batchtools_47042380 Work dir : D:/RCompile/CRANincoming/R-devel/future.batchtools.Rcheck/tests Jobs : 1 Seed : 5691 Writeable: TRUE > stopifnot(inherits(f, "BatchtoolsFuture")) > v <- value(f) > print(v) [1] 42 > stopifnot(v == 42L) > > > message("*** batchtools_custom() w/ 'cluster.functions' without globals") *** batchtools_custom() w/ 'cluster.functions' without globals > > cf <- makeClusterFunctionsInteractive(external = TRUE) > str(cf) List of 11 $ name : chr "Interactive" $ submitJob :function (reg, jc) $ killJob : NULL $ listJobsQueued : NULL $ listJobsRunning : NULL $ array.var : chr NA $ store.job.collection: logi TRUE $ store.job.files : logi FALSE $ scheduler.latency : num 0 $ fs.latency : num 0 $ hooks : list() - attr(*, "class")= chr "ClusterFunctions" > > f <- batchtools_custom({ + 42L + }, cluster.functions = cf) [04:37:08.340] Launched future #1 > stopifnot(inherits(f, "BatchtoolsFuture")) > > ## Check whether a batchtools_custom future is resolved > ## or not will force evaluation > print(is_resolved <- resolved(f)) [1] TRUE > stopifnot(is_resolved) > > y <- value(f) > print(y) [1] 42 > stopifnot(y == 42L) > > > message("*** batchtools_custom() w/ 'cluster.functions' with globals") *** batchtools_custom() w/ 'cluster.functions' with globals > ## A global variable > a <- 0 > f <- batchtools_custom({ + b <- 3 + c <- 2 + a * b * c + }, cluster.functions = cf) [04:37:10.024] Launched future #1 > print(f) BatchtoolsCustomFuture: Label: Expression: { b <- 3 c <- 2 a * b * c } Globals: 1 objects totaling 306 bytes (numeric 'a' of 39 bytes) Packages: L'Ecuyer-CMRG RNG seed: (seed = FALSE) Capture standard output: TRUE Capture condition classes: 'condition' (excluding '') Immediate condition classes: 'immediateCondition' Lazy evaluation: FALSE Local evaluation: TRUE Asynchronous evaluation: TRUE Early signaling: FALSE Environment: R_GlobalEnv State: 'running' Resolved: TRUE Unique identifier: 6e4e041b10eebac09d1fd9a3cad71818-3 Owner process: 6e4e041b10eebac09d1fd9a3cad71818 Class: 'BatchtoolsCustomFuture', 'BatchtoolsFuture', 'Future', 'environment' Value: Conditions captured: batchtools configuration file: 'D:/RCompile/CRANincoming/R-devel/lib/future.batchtools/templates-for-R_CMD_check/batchtools.conf.R' (82 bytes; 1 lines) batchtools cluster functions: 'Interactive' batchtools cluster functions template: batchtools status: 'defined', 'finished', 'started', 'submitted' batchtools Registry: File dir exists: TRUE Work dir exists: TRUE Job Registry Backend : Interactive File dir : D:/temp/2025_06_06_04_35_16_24916/RtmpOo6m8k/.future/20250606_043704-Oo6m8k/batchtools_876635847 Work dir : D:/RCompile/CRANincoming/R-devel/future.batchtools.Rcheck/tests Jobs : 1 Seed : 29898 Writeable: TRUE > > ## Although 'f' is a batchtools_custom future and therefore > ## resolved/evaluates the future expression only > ## when the value is requested, any global variables > ## identified in the expression (here 'a') are > ## "frozen" at the time point when the future is > ## created. Because of this, 'a' preserved the > ## zero value although we reassign it below > a <- 7 ## Make sure globals are frozen > v <- value(f) > print(v) [1] 0 > stopifnot(v == 0) > > > message("*** batchtools_custom() w/ 'cluster.functions' with globals (tricky)") *** batchtools_custom() w/ 'cluster.functions' with globals (tricky) > x <- listenv() > for (ii in 1:2) { + x[[ii]] <- batchtools_custom({ ii }, globals = TRUE, cluster.functions = cf) + } [04:37:11.321] Launched future #1 [04:37:12.647] Launched future #1 > v <- unlist(value(x)) > stopifnot(all(v == 1:2)) ## Make sure globals are frozen > > > message("*** batchtools_custom() w/ 'cluster.functions' and errors") *** batchtools_custom() w/ 'cluster.functions' and errors > f <- batchtools_custom({ + stop("Whoops!") + 1 + }, cluster.functions = cf) [04:37:13.947] Launched future #1 > v <- value(f, signal = FALSE) Warning in delete.BatchtoolsFuture(future) : Will not remove batchtools registry, because the status of the batchtools was 'error', 'defined', 'finished', 'started', 'submitted' and option 'future.delete' is FALSE or running in an interactive session: 'D:/temp/2025_06_06_04_35_16_24916/RtmpOo6m8k/.future/20250606_043704-Oo6m8k/batchtools_1610089823' > print(v) > stopifnot(inherits(v, "simpleError")) > > res <- try({ v <- value(f) }, silent = TRUE) > print(res) [1] "Error in eval(quote({ : Whoops!\n" attr(,"class") [1] "try-error" attr(,"condition") > stopifnot(inherits(res, "try-error")) > > ## Error is repeated > res <- try(value(f), silent = TRUE) > print(res) [1] "Error in eval(quote({ : Whoops!\n" attr(,"class") [1] "try-error" attr(,"condition") > stopifnot(inherits(res, "try-error")) > > message("*** batchtools_custom() ... DONE") *** batchtools_custom() ... DONE > > source("incl/end.R") > > proc.time() user system elapsed 1.79 0.54 10.31 Error : INTERNAL ERROR: Cannot remove from 'workers-BatchtoolsCustomFuture' registry. BatchtoolsCustomFuture not registered.