Skip to content

Commit f017a33

Browse files
FIX: When calling a future constructor via do.call(), we must use quote = TRUE; otherwise 'expr' is resolved
1 parent 34ff960 commit f017a33

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

R/BatchtoolsSSHFuture-class.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ BatchtoolsSSHFuture <- function(expr = NULL, substitute = TRUE, envir = parent.f
2525
cluster.functions = cluster.functions
2626
)
2727
if (length(dotdotdot) > 0) args <- c(args, dotdotdot)
28-
future <- do.call(BatchtoolsCustomFuture, args = args)
28+
29+
future <- do.call(BatchtoolsCustomFuture, args = args, quote = TRUE)
30+
2931
future <- structure(future, class = c("BatchtoolsSSHFuture", class(future)))
3032

3133
future$workers <- workers

R/BatchtoolsSSHRegistry.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ BatchtoolsSSHRegistry <- local({
5050
ncpus <- table(workers)
5151

5252
mapply(names(ncpus), ncpus, FUN = function(hostname, ncpus) {
53-
Worker$new(hostname, ncpus = ncpus)
53+
Worker$new(hostname, ncpus = ncpus, max.load = Inf)
5454
})
5555
}

R/batchtools_template.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ batchtools_by_template <- function(expr, envir = parent.frame(),
221221
workers = workers
222222
)
223223
if (length(dotdotdot) > 0) args <- c(args, dotdotdot)
224-
future <- do.call(constructor, args = args)
224+
future <- do.call(constructor, args = args, quote = TRUE)
225225

226226
if (!future$lazy) future <- run(future)
227227

tests/batchtools_ssh.R

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
source("incl/start.R")
2+
library("listenv")
3+
4+
message("*** batchtools_ssh() ...")
5+
6+
plan(batchtools_ssh, workers = 2L)
7+
supports_ssh <- tryCatch({
8+
f <- future(42L)
9+
v <- value(f)
10+
identical(v, 42L)
11+
}, error = function(e) FALSE)
12+
message("Supports batchtools_ssh: ", supports_ssh)
13+
14+
if (supports_ssh) {
15+
message("future(a) ...")
16+
a0 <- a <- 42
17+
f <- future(a)
18+
stopifnot(identical(f$globals$a, a0))
19+
v <- value(f)
20+
stopifnot(identical(v, a0))
21+
22+
message("future(a, lazy = TRUE) ...")
23+
a0 <- a <- 42
24+
f <- future(a, lazy = TRUE)
25+
rm(list = "a")
26+
stopifnot(identical(f$globals$a, a0))
27+
v <- value(f)
28+
stopifnot(identical(v, a0))
29+
} ## if (supports_ssh)
30+
31+
message("*** batchtools_ssh() ... DONE")
32+
33+
source("incl/end.R")

0 commit comments

Comments
 (0)