Skip to content

Commit

Permalink
Convert spades.cachePath to reproducible.cachePath
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotmcintire committed Nov 24, 2018
1 parent 8c0d470 commit 7e82ccf
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ setMethod(
sim <- get("sim", envir = sys.frame(doEventFrameNum))
cacheRepo <- sim@paths$cachePath
} else {
cacheRepo <- .getOption("spades.cachePath")
cacheRepo <- .getOption("reproducible.cachePath")
#checkPath(cacheRepo, create = TRUE) #SpaDES dependency
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/misc-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ setMethod(
#' \code{Paths$cachePath} for example instead of \code{getPaths()$cachePath}
#'
#' @param cachePath The default local directory in which to cache simulation outputs.
#' If not specified, defaults to \code{getOption("spades.cachePath")}.
#' If not specified, defaults to \code{getOption("reproducible.cachePath")}.
#'
#' @param inputPath The default local directory in which to look for simulation inputs
#' If not specified, defaults to \code{getOption("spades.inputPath")}.
Expand Down Expand Up @@ -613,7 +613,7 @@ setMethod(
#'
.paths <- function() {
list(
cachePath = .getOption("spades.cachePath"),
cachePath = .getOption("reproducible.cachePath"),
inputPath = getOption("spades.inputPath"),
modulePath = getOption("spades.modulePath"),
outputPath = getOption("spades.outputPath")
Expand Down
2 changes: 1 addition & 1 deletion R/simList-accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ setReplaceMethod(
#' If no paths are specified, the defaults are as follows:
#'
#' \itemize{
#' \item \code{cachePath}: \code{getOption("spades.cachePath")};
#' \item \code{cachePath}: \code{getOption("reproducible.cachePath")};
#'
#' \item \code{inputPath}: \code{getOption("spades.modulePath")};
#'
Expand Down
2 changes: 1 addition & 1 deletion R/simulation-simInit.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (getRversion() >= "3.1.0") {
#' the defaults are as follows:
#'
#' \itemize{
#' \item \code{cachePath}: \code{getOption("spades.cachePath")};
#' \item \code{cachePath}: \code{getOption("reproducible.cachePath")};
#'
#' \item \code{inputPath}: \code{getOption("spades.modulePath")};
#'
Expand Down
2 changes: 1 addition & 1 deletion R/spades-core-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
#' first time makes the error, the second time has \code{debugonce} and the third time
#' is after the error is addressed. \code{TRUE} is likely somewhat slower.
#'
#' \item \code{spades.cachePath}: The default local directory in which to
#' \item \code{reproducible.cachePath}: The default local directory in which to
#' cache simulation outputs.
#' Default is a temporary directory (typically \code{/tmp/RtmpXXX/SpaDES/cache}).
#'
Expand Down
2 changes: 1 addition & 1 deletion man/SpaDES.core-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/setPaths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/simInit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/simList-accessors-paths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-multipleModulePaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test_that("simulation runs with simInit and spades", {
init = {
sim$dp <- dataPath(sim)
sim$cachePath <- cachePath(sim)
sim$optionsCachePath <- getOption("spades.cachePath")
sim$optionsCachePath <- getOption("reproducible.cachePath")
#sim <- scheduleEvent(sim, sim@simtimes$current+1, "test", "event1")
},
event1 = {
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-paths.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("paths file does not work correctly", {
testInitOut <- testInit(setPaths = FALSE)

on.exit({
testOnExit(testInitOut)
}, add = TRUE)
Expand Down Expand Up @@ -57,6 +58,20 @@ test_that("paths file does not work correctly", {
modulePath = modulePath(mySim),
outputPath = outputPath(mySim)), normPath))

# missing paths
oldPaths <- getPaths()
do.call(setPaths, paths)
on.exit({do.call(setPaths, paths)}, add = TRUE)
mySim1 <- simInit(times, params, modules, objects = list())
expect_equal(lapply(paths(mySim), normPath),
lapply(paths(mySim1), normPath))

# setting paths via setPaths works for changing the paths in the simInit & therefore simList
setPaths(cachePath = oldPaths$cachePath)
mySim2 <- simInit(times, params, modules, objects = list())
expect_false(identical(lapply(paths(mySim), normPath),
lapply(paths(mySim2), normPath)))

inputPath(mySim) <- tmpdir
expect_equal(inputPath(mySim), tmpdir)

Expand All @@ -68,4 +83,6 @@ test_that("paths file does not work correctly", {

cachePath(mySim) <- tmpdir
expect_equal(cachePath(mySim), tmpdir)


})

0 comments on commit 7e82ccf

Please sign in to comment.