Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13 changed options() are not passed to future when not using plan("sequential") #14

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Description: Tools to do simulation experiments within the SpaDES ecosystem.
URL:
https://spades-experiment.predictiveecology.org/,
https://github.com/PredictiveEcology/SpaDES.experiment
Date: 2021-08-19
Version: 0.0.2.9003
Date: 2022-09-10
Version: 0.0.2.9004
Authors@R: c(
person("Eliot J B", "McIntire", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")),
Expand Down
10 changes: 8 additions & 2 deletions R/experiment2.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ setGeneric(
})

#' @importFrom future.apply future_lapply future_mapply
#' @importFrom future nbrOfWorkers
#' @importFrom googledrive drive_auth
#' @importFrom SpaDES.core packages
#' @rdname experiment2
Expand Down Expand Up @@ -127,6 +128,7 @@ setMethod(
staggersInSecs <- cumsum(c(0, rnorm(length(nbrOfWorkers())-1, mean = meanStaggerIntervalInSecs,
sd = meanStaggerIntervalInSecs/10)))

allOpts <- options()
out <- future_mapply(
name = namsExpanded,
simName = simNames,
Expand All @@ -136,6 +138,7 @@ setMethod(
createUniquePaths = createUniquePaths,
useCache = useCache,
.spades = .spades,
allOpts = allOpts,
debug = debug,
drive_auth_account = drive_auth_account),
FUN = experiment2Inner,
Expand All @@ -151,7 +154,7 @@ setMethod(
#' @importFrom SpaDES.core outputPath outputPath<- envir
#' @importFrom reproducible Cache
experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths,
simName, name, useCache = FALSE,
simName, name, useCache = FALSE, allOpts,
debug = getOption("spades.debug"), drive_auth_account,
...) {
message(paste0("Sleeping ", round(staggerInSecs, 1), " seconds"))
Expand All @@ -161,8 +164,10 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths,
if (!is.null(drive_auth_account))
drive_auth(drive_auth_account)

options(allOpts)
s <- Cache(.spades, sim, useCache = useCache, simName,
debug = debug, clearSimEnv = clearSimEnv, ..., omitArgs = "debug")
debug = debug, clearSimEnv = clearSimEnv,
..., omitArgs = "debug")
s
}

Expand All @@ -178,6 +183,7 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths,
b <- Sys.time()
message(format(b - a), " to Copy")
}

s <- spades(sim, debug = debug, ...)
if (isTRUE(clearSimEnv))
rm(list = ls(s, all.names = TRUE), envir = envir(s))
Expand Down