From c594ea3b4ede1a8949307b4197909453762111ec Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Thu, 10 Mar 2022 16:29:25 -0800 Subject: [PATCH 1/5] bugfix: missing import of future::nbrOfWorkers --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/experiment2.R | 1 + man/simInitAnd.Rd | 5 ++++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 28ec6ac..8646ea2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -67,4 +67,4 @@ Collate: 'experiment2.R' 'simInitAndExperiment.R' 'spades-experiment-package.R' -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 diff --git a/NAMESPACE b/NAMESPACE index 9cc0fac..09feef1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,6 +41,7 @@ importFrom(data.table,set) importFrom(data.table,setDT) importFrom(data.table,setkeyv) importFrom(data.table,setnames) +importFrom(future,nbrOfWorkers) importFrom(future,plan) importFrom(future.apply,future_lapply) importFrom(future.apply,future_mapply) diff --git a/R/experiment2.R b/R/experiment2.R index 97af75f..aed26ec 100644 --- a/R/experiment2.R +++ b/R/experiment2.R @@ -77,6 +77,7 @@ setGeneric( }) #' @importFrom future.apply future_lapply future_mapply +#' @importFrom future nbrOfWorkers #' @importFrom googledrive drive_auth #' @importFrom SpaDES.core packages #' @rdname experiment2 diff --git a/man/simInitAnd.Rd b/man/simInitAnd.Rd index 3d311cc..50ceb08 100644 --- a/man/simInitAnd.Rd +++ b/man/simInitAnd.Rd @@ -26,7 +26,10 @@ simInitAndExperiment( } \arguments{ \item{times}{A named list of numeric simulation start and end times -(e.g., \code{times = list(start = 0.0, end = 10.0)}).} +(e.g., \code{times = list(start = 0.0, end = 10.0, timeunit = "year")}), +with the final optional element, \code{timeunit}, overriding the default +time unit used in the simulation which is the "smallest time unit" across all +modules. See examples.} \item{params}{A list of lists of the form \code{list(moduleName=list(param1=value, param2=value))}. See details.} From 247d6b6d38abb873d9301acd1b05aa8360c5dde2 Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Fri, 9 Sep 2022 12:17:40 -0700 Subject: [PATCH 2/5] new `spadesOption` arg to `options()` to`spades` --- R/experiment2.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/experiment2.R b/R/experiment2.R index 301eaab..4c076b3 100644 --- a/R/experiment2.R +++ b/R/experiment2.R @@ -137,6 +137,7 @@ setMethod( createUniquePaths = createUniquePaths, useCache = useCache, .spades = .spades, + spadesOptions = options(), debug = debug, drive_auth_account = drive_auth_account), FUN = experiment2Inner, @@ -152,7 +153,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, spadesOptions = options(), debug = getOption("spades.debug"), drive_auth_account, ...) { message(paste0("Sleeping ", round(staggerInSecs, 1), " seconds")) @@ -163,14 +164,15 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths, drive_auth(drive_auth_account) s <- Cache(.spades, sim, useCache = useCache, simName, - debug = debug, clearSimEnv = clearSimEnv, ..., omitArgs = "debug") + debug = debug, clearSimEnv = clearSimEnv, spadesOptions = spadesOptions, + ..., omitArgs = "debug") s } #' @importFrom future plan #' @importFrom reproducible Copy .spades <- function(sim, debug = getOption("spades.debug"), - clearSimEnv = FALSE, ...) { + clearSimEnv = FALSE, spadesOptions = options(), ...) { # don't make a copy if it is callr or multisession because future will make the copy if (!any(c("callr", "multisession") %in% attr(plan(), "class"))) { a <- Sys.time() @@ -179,6 +181,7 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths, b <- Sys.time() message(format(b - a), " to Copy") } + options(spadesOptions) s <- spades(sim, debug = debug, ...) if (isTRUE(clearSimEnv)) rm(list = ls(s, all.names = TRUE), envir = envir(s)) From b7026ec320d5da63391047e2ca64c2680d8a35ce Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Sat, 10 Sep 2022 13:41:26 -0700 Subject: [PATCH 3/5] rename spadesOptions -> allOpts & use variable --- R/experiment2.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/experiment2.R b/R/experiment2.R index 4c076b3..32dec41 100644 --- a/R/experiment2.R +++ b/R/experiment2.R @@ -128,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, @@ -137,7 +138,7 @@ setMethod( createUniquePaths = createUniquePaths, useCache = useCache, .spades = .spades, - spadesOptions = options(), + allOpts = allOpts, debug = debug, drive_auth_account = drive_auth_account), FUN = experiment2Inner, @@ -153,7 +154,7 @@ setMethod( #' @importFrom SpaDES.core outputPath outputPath<- envir #' @importFrom reproducible Cache experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths, - simName, name, useCache = FALSE, spadesOptions = options(), + simName, name, useCache = FALSE, allOpts, debug = getOption("spades.debug"), drive_auth_account, ...) { message(paste0("Sleeping ", round(staggerInSecs, 1), " seconds")) From 04f49cbee1dadddfec7cceac9b9853fc581132d0 Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Sat, 10 Sep 2022 13:42:07 -0700 Subject: [PATCH 4/5] set `options()` before `.spades` -- still not working --- R/experiment2.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/experiment2.R b/R/experiment2.R index 32dec41..ca5f1a7 100644 --- a/R/experiment2.R +++ b/R/experiment2.R @@ -164,8 +164,9 @@ 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, spadesOptions = spadesOptions, + debug = debug, clearSimEnv = clearSimEnv, ..., omitArgs = "debug") s } @@ -173,7 +174,7 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths, #' @importFrom future plan #' @importFrom reproducible Copy .spades <- function(sim, debug = getOption("spades.debug"), - clearSimEnv = FALSE, spadesOptions = options(), ...) { + clearSimEnv = FALSE, ...) { # don't make a copy if it is callr or multisession because future will make the copy if (!any(c("callr", "multisession") %in% attr(plan(), "class"))) { a <- Sys.time() @@ -182,7 +183,7 @@ experiment2Inner <- function(sim, clearSimEnv, staggerInSecs, createUniquePaths, b <- Sys.time() message(format(b - a), " to Copy") } - options(spadesOptions) + s <- spades(sim, debug = debug, ...) if (isTRUE(clearSimEnv)) rm(list = ls(s, all.names = TRUE), envir = envir(s)) From 82ffdb7cce912013e19a49d70da2572448605250 Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Fri, 30 Jun 2023 12:07:54 -0700 Subject: [PATCH 5/5] "retroactive" bump --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5d5cbc8..997a5ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "eliot.mcintire@canada.ca", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")),