Skip to content

Commit

Permalink
Merge pull request #14 from CeresBarros/13-changed-options-are-not-pa…
Browse files Browse the repository at this point in the history
…ssed-to-fut

13 changed `options()` are not passed to `future` when not using `plan("sequential")`
  • Loading branch information
eliotmcintire authored Jul 29, 2023
2 parents c6b79d9 + f1a71d5 commit a681fb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit a681fb5

Please sign in to comment.