From aebe8d238663baef92f6c0b8af15847651add7c4 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 15 May 2024 17:31:55 +0200 Subject: [PATCH 1/2] pucAggregate no forced cache note --- R/cacheName.R | 13 +++++++++---- R/isWrapperActive.R | 1 + R/pucAggregate.R | 3 +++ tests/testthat/test-puc.R | 40 +++++++++++++++++++-------------------- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/R/cacheName.R b/R/cacheName.R index c1ba9609..bb7b8550 100644 --- a/R/cacheName.R +++ b/R/cacheName.R @@ -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) } diff --git a/R/isWrapperActive.R b/R/isWrapperActive.R index c362ae6e..2d81241f 100644 --- a/R/isWrapperActive.R +++ b/R/isWrapperActive.R @@ -30,6 +30,7 @@ setWrapperInactive <- function(name) { readSource = FALSE, calcOutput = FALSE, retrieveData = FALSE, + pucAggregate = FALSE, saveCache = FALSE, callingHandler = FALSE, vcat = FALSE, diff --git a/R/pucAggregate.R b/R/pucAggregate.R index 1b8a7dc5..4ba387fc 100644 --- a/R/pucAggregate.R +++ b/R/pucAggregate.R @@ -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) diff --git a/tests/testthat/test-puc.R b/tests/testthat/test-puc.R index 7a3a4af1..cda95d04 100644 --- a/tests/testthat/test-puc.R +++ b/tests/testthat/test-puc.R @@ -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"))) }) From db6b57b21b8e058841ea1d422c92664b201af3bc Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 15 May 2024 17:37:59 +0200 Subject: [PATCH 2/2] build --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 05a27366..b394ac13 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '61756461' +ValidationKey: '61798096' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 172aa905..32454ee8 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'madrat: May All Data be Reproducible and Transparent (MADRaT) *' -version: 3.11.1 -date-released: '2024-05-08' +version: 3.11.2 +date-released: '2024-05-15' abstract: Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as automatic meta data creation and management, rudimentary quality management, data caching, work-flow management diff --git a/DESCRIPTION b/DESCRIPTION index 9b688d26..29dc1d31 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: madrat Title: May All Data be Reproducible and Transparent (MADRaT) * -Version: 3.11.1 -Date: 2024-05-08 +Version: 3.11.2 +Date: 2024-05-15 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = "aut"), diff --git a/README.md b/README.md index c7ad94b2..8ea96999 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # May All Data be Reproducible and Transparent (MADRaT) * -R package **madrat**, version **3.11.1** +R package **madrat**, version **3.11.2** [![CRAN status](https://www.r-pkg.org/badges/version/madrat)](https://cran.r-project.org/package=madrat) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1115490.svg)](https://doi.org/10.5281/zenodo.1115490) [![R build status](https://github.com/pik-piam/madrat/workflows/check/badge.svg)](https://github.com/pik-piam/madrat/actions) [![codecov](https://codecov.io/gh/pik-piam/madrat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/madrat) [![r-universe](https://pik-piam.r-universe.dev/badges/madrat)](https://pik-piam.r-universe.dev/builds) @@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , R package version 3.11.1, . +Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Sauer P (2024). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi:10.5281/zenodo.1115490 , R package version 3.11.2, . A BibTeX entry for LaTeX users is @@ -64,7 +64,7 @@ A BibTeX entry for LaTeX users is title = {madrat: May All Data be Reproducible and Transparent (MADRaT)}, author = {Jan Philipp Dietrich and Lavinia Baumstark and Stephen Wirth and Anastasis Giannousakis and Renato Rodrigues and Benjamin Leon Bodirsky and Debbora Leip and Ulrich Kreidenweis and David Klein and Pascal Sauer}, year = {2024}, - note = {R package version 3.11.1}, + note = {R package version 3.11.2}, url = {https://github.com/pik-piam/madrat}, doi = {10.5281/zenodo.1115490}, }