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("listenv") > > message("*** nbrOfWorkers() ...") *** nbrOfWorkers() ... > > message("*** nbrOfWorkers() - local, interactive ...") *** nbrOfWorkers() - local, interactive ... > > n <- nbrOfWorkers(batchtools_local) > message("Number of workers: ", n) Number of workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(batchtools_local) > message("Number of free workers: ", n) Number of free workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(batchtools_local, background = TRUE) > message("Number of free background workers: ", n) Number of free background workers: 0 > stopifnot(n == 0L) > > n <- nbrOfWorkers(batchtools_interactive) > message("Number of workers: ", n) Number of workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(batchtools_interactive) > message("Number of free workers: ", n) Number of free workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(batchtools_interactive, background = TRUE) > message("Number of free background workers: ", n) Number of free background workers: 0 > stopifnot(n == 0L) > > > plan(batchtools_local) > n <- nbrOfWorkers() > message("Number of workers: ", n) Number of workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers() > message("Number of free workers: ", n) Number of free workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(background = TRUE) > message("Number of free background workers: ", n) Number of free background workers: 0 > stopifnot(n == 0L) > > plan(batchtools_interactive) > n <- nbrOfWorkers() > message("Number of workers: ", n) Number of workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers() > message("Number of free workers: ", n) Number of free workers: 1 > stopifnot(n == 1L) > > n <- nbrOfFreeWorkers(background = TRUE) > message("Number of free background workers: ", n) Number of free background workers: 0 > stopifnot(n == 0L) > > > message("*** nbrOfWorkers() - local, interactive ... DONE") *** nbrOfWorkers() - local, interactive ... DONE > > ncores <- availableCores("multicore") > if (ncores >= 2L) { + message("*** nbrOfWorkers() - multicore ...") + + n <- nbrOfWorkers(batchtools_multicore) + message("Number of workers: ", n) + stopifnot(n == ncores) + + n <- nbrOfFreeWorkers(batchtools_multicore) + message("Number of free workers: ", n) + stopifnot(n == ncores) + + n <- nbrOfFreeWorkers(batchtools_multicore, background = TRUE) + message("Number of free background workers: ", n) + stopifnot(n == ncores) + + plan(batchtools_multicore, workers = 2L) + n <- nbrOfWorkers() + message("Number of workers: ", n) + stopifnot(n == 2L) + + n <- nbrOfFreeWorkers() + message("Number of free workers: ", n) + stopifnot(n == 2L) + + n <- nbrOfFreeWorkers(background = TRUE) + message("Number of free background workers: ", n) + stopifnot(n == 2L) + + workers <- min(2L, ncores) + plan(batchtools_multicore, workers = workers) + n <- nbrOfWorkers() + message("Number of workers: ", n) + stopifnot(n == workers) + + message("*** nbrOfWorkers() - multicore ... DONE") + } ## if (ncores >= 2L) > > > message("*** nbrOfWorkers() - templates ...") *** nbrOfWorkers() - templates ... > > ## Test with +Inf workers > options(future.batchtools.workers = +Inf) > > n <- nbrOfWorkers(batchtools_lsf) > message("Number of workers: ", n) Number of workers: Inf > stopifnot(is.infinite(n)) > > n <- nbrOfWorkers(batchtools_openlava) > message("Number of workers: ", n) Number of workers: Inf > stopifnot(is.infinite(n)) > > n <- nbrOfWorkers(batchtools_sge) > message("Number of workers: ", n) Number of workers: Inf > stopifnot(is.infinite(n)) > > n <- nbrOfWorkers(batchtools_slurm) > message("Number of workers: ", n) Number of workers: Inf > stopifnot(is.infinite(n)) > > n <- nbrOfWorkers(batchtools_torque) > message("Number of workers: ", n) Number of workers: Inf > stopifnot(is.infinite(n)) > > message("*** nbrOfWorkers() - templates ... DONE") *** nbrOfWorkers() - templates ... DONE > > message("*** nbrOfWorkers() - custom ...") *** nbrOfWorkers() - custom ... > > cf <- batchtools::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" > > plan(batchtools_custom, cluster.functions = cf) > n <- nbrOfWorkers() > message("Number of workers: ", n) Number of workers: 1 > stopifnot(n == 1L) > > message("*** nbrOfWorkers() - custom ... DONE") *** nbrOfWorkers() - custom ... DONE > > message("*** nbrOfWorkers() ... DONE") *** nbrOfWorkers() ... DONE > > source("incl/end.R") > > proc.time() user system elapsed 0.92 0.25 1.15