Skip to content

Commit

Permalink
pucAggregate no forced cache note
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-sauer committed May 15, 2024
1 parent 197e6cb commit aebe8d2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
13 changes: 9 additions & 4 deletions R/cacheName.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ cacheName <- function(prefix, type, args = NULL, graph = NULL, mode = "put", pa
vcat(3, " - Search pattern ", basename(.fname(prefix, type, "-F*", args)), show_prefix = FALSE)
return(NULL)
}
if (length(files) == 1) file <- files
else file <- files[robustOrder(paste(file.mtime(files), basename(files)), decreasing = TRUE)][1]
vcat(1, " - forced cache does not match fingerprint ", fp,
fill = 300, show_prefix = FALSE)
if (length(files) == 1) {
file <- files
} else {
file <- files[robustOrder(paste(file.mtime(files), basename(files)), decreasing = TRUE)][1]
}
if (!isWrapperActive("pucAggregate")) {
vcat(1, " - forced cache does not match fingerprint ", fp,
fill = 300, show_prefix = FALSE)
}
return(file)
}
1 change: 1 addition & 0 deletions R/isWrapperActive.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ setWrapperInactive <- function(name) {
readSource = FALSE,
calcOutput = FALSE,
retrieveData = FALSE,
pucAggregate = FALSE,
saveCache = FALSE,
callingHandler = FALSE,
vcat = FALSE,
Expand Down
3 changes: 3 additions & 0 deletions R/pucAggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#' @export
pucAggregate <- function(puc, regionmapping = getConfig("regionmapping"), ..., renv = TRUE, strict = FALSE) {
argumentValues <- c(as.list(environment()), list(...)) # capture arguments for logging

setWrapperActive("pucAggregate")

extraArgs <- list(...)
startinfo <- toolstartmessage("pucAggregate", argumentValues, "+")
puc <- normalizePath(puc)
Expand Down
40 changes: 20 additions & 20 deletions tests/testthat/test-puc.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
test_that("puc creation works", {
skip_on_cran()
retrieveData("example", rev = 42, extra = "test1")
expect_true(dir.exists(getConfig("pucfolder")))
withr::local_dir(getConfig("pucfolder"))
expect_true(file.exists("rev42_extra_example_tag.puc"))
untar("rev42_extra_example_tag.puc")
expect_true(length(Sys.glob("calcTauTotal*.rds")) == 1)
cfg <- readRDS("config.rds")
expect_identical(cfg$package, "madrat")
expect_identical(cfg$pucArguments, "extra")
expect_identical(cfg$args, list(model = "example", rev = 42, dev = "", cachetype = "def",
puc = TRUE, strict = FALSE, extra = "test1"))
expect_error(pucAggregate("rev42_extra_example_tag.puc", bla = "blub"), "cannot be changed in the given puc")
expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv",
renv = FALSE), "Run calcOutput")
expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv",
renv = FALSE), "already available")
expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_7a5441e5_example_customizable_tag.tgz")))
expect_message(retrieveData("example", rev = 42, extra = "test2", renv = FALSE), "Run pucAggregate")
expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_5f3d77a0_example_customizable_tag.tgz")))
skip_on_cran()
retrieveData("example", rev = 42, extra = "test1")
expect_true(dir.exists(getConfig("pucfolder")))
withr::local_dir(getConfig("pucfolder"))
expect_true(file.exists("rev42_extra_example_tag.puc"))
untar("rev42_extra_example_tag.puc")
expect_true(length(Sys.glob("calcTauTotal*.rds")) == 1)
cfg <- readRDS("config.rds")
expect_identical(cfg$package, "madrat")
expect_identical(cfg$pucArguments, "extra")
expect_identical(cfg$args, list(model = "example", rev = 42, dev = "", cachetype = "def",
puc = TRUE, strict = FALSE, extra = "test1"))
expect_error(pucAggregate("rev42_extra_example_tag.puc", bla = "blub"), "cannot be changed in the given puc")
expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv",
renv = FALSE), "Run calcOutput")
expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv",
renv = FALSE), "already available")
expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_7a5441e5_example_customizable_tag.tgz")))
expect_message(retrieveData("example", rev = 42, extra = "test2", renv = FALSE), "Run pucAggregate")
expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_5f3d77a0_example_customizable_tag.tgz")))
})

0 comments on commit aebe8d2

Please sign in to comment.