Skip to content

Commit

Permalink
evalFuture(): Replace arguments 'stdout' and 'conditionClasses' with …
Browse files Browse the repository at this point in the history
…'capture'
  • Loading branch information
HenrikBengtsson committed Dec 31, 2024
1 parent 0bc80e1 commit 7a055e2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: future
Version: 1.34.0-9103
Version: 1.34.0-9104
Title: Unified Parallel and Distributed Processing in R for Everyone
Imports:
digest,
Expand Down
14 changes: 9 additions & 5 deletions R/Future-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,15 @@ getExpression <- function(future, ...) UseMethod("getExpression")
getExpression.Future <- local({
tmpl_expr_evaluate2 <- bquote_compile({
## Evaluate future
future:::evalFuture(core = .(core), local = .(local), stdout = .(stdout), conditionClasses = .(conditionClasses), split = .(split), immediateConditionClasses = .(immediateConditionClasses), strategiesR = .(strategiesR), forwardOptions = .(forwardOptions), threads = .(threads), cleanup = .(cleanup))
future:::evalFuture(core = .(core), capture = .(capture), local = .(local), split = .(split), immediateConditionClasses = .(immediateConditionClasses), strategiesR = .(strategiesR), forwardOptions = .(forwardOptions), threads = .(threads), cleanup = .(cleanup))
})

function(future, expr = future$expr, immediateConditions = FALSE, mc.cores = NULL, threads = NA_integer_, cleanup = TRUE, ...) {
debug <- getOption("future.debug", FALSE)
## mdebug("getExpression() ...")

local <- future$local
stdout <- future$stdout
split <- future$split
conditionClasses <- future$conditions

if (is.null(split)) split <- FALSE
stop_if_not(is.logical(split), length(split) == 1L, !is.na(split))
Expand Down Expand Up @@ -725,7 +723,8 @@ getExpression.Future <- local({
} else {
immediateConditionClasses <- character(0L)
}


conditionClasses <- future$conditions
if (length(immediateConditionClasses) > 0 && !is.null(conditionClasses)) {
exclude <- attr(conditionClasses, "exclude", exact = TRUE)
muffleInclude <- attr(conditionClasses, "muffleInclude", exact = TRUE)
Expand All @@ -734,7 +733,12 @@ getExpression.Future <- local({
attr(conditionClasses, "exclude") <- exclude
attr(conditionClasses, "muffleInclude") <- muffleInclude
}


capture <- list(
stdout = future$stdout,
conditionClasses = conditionClasses
)

forwardOptions <- list(
## Assert globals when future is created (or at run time)?
future.globals.onMissing = getOption("future.globals.onMissing"),
Expand Down
24 changes: 23 additions & 1 deletion R/expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@ FutureEvalError <- function(...) {
ex
}

evalFuture <- function(core, local = FALSE, stdout = TRUE, conditionClasses = character(0L), split = FALSE, immediateConditionClasses = character(0L), forwardOptions = NULL, strategiesR = NULL, threads = NA_integer_, envir = parent.frame(), cleanup = TRUE) {
evalFuture <- function(
core = list(
expr = NULL,
globals = list(),
packages = character(0L),
seed = NULL
),
capture = list(
stdout = TRUE,
conditionClasses = character(0L)
),
local = FALSE,
split = FALSE,
immediateConditionClasses = character(0L),
forwardOptions = NULL,
strategiesR = NULL,
threads = NA_integer_,
envir = parent.frame(),
cleanup = TRUE) {
expr <- core$expr
globals <- core$globals
packages <- core$packages
seed <- core$seed

stdout <- capture$stdout
if (is.null(stdout)) stdout <- TRUE
conditionClasses <- capture$conditionClasses

stop_if_not(
length(local) == 1L && is.logical(local) && !is.na(local),
length(stdout) == 1L && is.logical(stdout),
Expand Down

0 comments on commit 7a055e2

Please sign in to comment.