From bb3871c038b3e5d709269f7f705040abde51d51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Fri, 13 Oct 2023 15:47:39 +0200 Subject: [PATCH 1/2] fix codelabels in pucAggregate --- R/pucAggregate.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/pucAggregate.R b/R/pucAggregate.R index f7917f5c..1b8a7dc5 100644 --- a/R/pucAggregate.R +++ b/R/pucAggregate.R @@ -39,13 +39,15 @@ pucAggregate <- function(puc, regionmapping = getConfig("regionmapping"), ..., r puc <- normalizePath(puc) if (file.exists(regionmapping)) regionmapping <- normalizePath(regionmapping) - .aggregatePuc <- function(regionmapping, cfg, madratCfg, nestinglevel) { + .aggregatePuc <- function(regionmapping, cfg, madratCfg, madratCodelabels, nestinglevel) { # need to use `::` because this is run in another R session if (file.exists("puc/renv.lock")) { renv::init() renv::restore(lockfile = "puc/renv.lock", prompt = FALSE) } - withr::local_options(madrat_cfg = madratCfg, gdt_nestinglevel = nestinglevel) + withr::local_options(madrat_cfg = madratCfg, + madrat_codelabels = madratCodelabels, + gdt_nestinglevel = nestinglevel) madrat::localConfig(packages = "madrat", regionmapping = regionmapping, forcecache = TRUE, .verbose = FALSE) if (!is.null(cfg$package)) withr::local_package(cfg$package) @@ -67,6 +69,7 @@ pucAggregate <- function(puc, regionmapping = getConfig("regionmapping"), ..., r if (isTRUE(renv)) { out <- capture.output(r(.aggregatePuc, list(regionmapping = regionmapping, cfg = cfg, madratCfg = getOption("madrat_cfg"), + madratCodelabels = getOption("madrat_codelabels"), nestinglevel = getOption("gdt_nestinglevel")), spinner = FALSE, show = TRUE)) message(paste(out, "\n")) @@ -75,8 +78,7 @@ pucAggregate <- function(puc, regionmapping = getConfig("regionmapping"), ..., r if (!is.null(cfg$package) && !cfg$package %in% .packages()) { withr::local_package(cfg$package) } - localConfig(regionmapping = regionmapping, forcecache = TRUE, - .verbose = FALSE) + localConfig(regionmapping = regionmapping, forcecache = TRUE, .verbose = FALSE) do.call(retrieveData, c(cfg$args, list(renv = FALSE))) } }, tmpdir = madTempDir()) From c08de15e1bfd82643cb0dec6cce23e5cc3e3f1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Fri, 13 Oct 2023 15:59:21 +0200 Subject: [PATCH 2/2] rename to Sauer, build --- .buildlibrary | 2 +- CITATION.cff | 8 ++-- DESCRIPTION | 6 +-- R/compareMadratOutputs.R | 2 +- R/downloadSource.R | 2 +- R/fingerprint.R | 85 ++++++++++++++++++------------------- R/readSource.R | 2 +- R/robustOrder.R | 2 +- R/toolstartmessage.R | 2 +- README.md | 8 ++-- man/compareMadratOutputs.Rd | 2 +- man/downloadSource.Rd | 2 +- man/fingerprint.Rd | 2 +- man/readSource.Rd | 2 +- man/robustOrder.Rd | 2 +- man/toolstartmessage.Rd | 2 +- 16 files changed, 65 insertions(+), 66 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 4f294796..37f16703 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '7208614' +ValidationKey: '7228624' 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 e58bd8a9..5badb3ff 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.6.7 -date-released: '2023-10-12' +version: 3.6.8 +date-released: '2023-10-13' 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 @@ -38,9 +38,9 @@ authors: - family-names: Klein given-names: David email: dklein@pik-potsdam.de -- family-names: Führlich +- family-names: Sauer given-names: Pascal - email: pascal.fuehrlich@pik-potsdam.de + email: pascal.sauer@pik-potsdam.de license: BSD-2-Clause repository-code: https://github.com/pik-piam/madrat doi: 10.5281/zenodo.1115490 diff --git a/DESCRIPTION b/DESCRIPTION index 5ea52d39..c4466683 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: madrat Title: May All Data be Reproducible and Transparent (MADRaT) * -Version: 3.6.7 -Date: 2023-10-12 +Version: 3.6.8 +Date: 2023-10-13 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = "aut"), @@ -13,7 +13,7 @@ Authors@R: c( person("Debbora", "Leip", , "leip@pik-potsdam.de", role = "aut"), person("Ulrich", "Kreidenweis", , "kreidenweis@pik-potsdam.de", role = "aut"), person("David", "Klein", , "dklein@pik-potsdam.de", role = "aut"), - person("Pascal", "Führlich", , "pascal.fuehrlich@pik-potsdam.de", role = "aut") + person("Pascal", "Sauer", , "pascal.sauer@pik-potsdam.de", role = "aut") ) Description: Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as diff --git a/R/compareMadratOutputs.R b/R/compareMadratOutputs.R index f4663ae7..de8a6cca 100644 --- a/R/compareMadratOutputs.R +++ b/R/compareMadratOutputs.R @@ -26,7 +26,7 @@ #' compareMadratOutputs("madrat", "readTau", c("paper", "historical")) #' } #' -#' @author Pascal Führlich +#' @author Pascal Sauer #' #' @importFrom digest digest #' @importFrom magclass where diff --git a/R/downloadSource.R b/R/downloadSource.R index 5a4f3eab..d88f68be 100644 --- a/R/downloadSource.R +++ b/R/downloadSource.R @@ -35,7 +35,7 @@ #' } #' Besides the names above (user-provided and automatically derived) it is possible to add custom metadata entries by #' extending the return list with additional, named entries. -#' @author Jan Philipp Dietrich, David Klein, Pascal Führlich +#' @author Jan Philipp Dietrich, David Klein, Pascal Sauer #' @examples #' \dontrun{ #' a <- downloadSource("Tau", subtype = "historical") diff --git a/R/fingerprint.R b/R/fingerprint.R index 618ec874..f1b09714 100644 --- a/R/fingerprint.R +++ b/R/fingerprint.R @@ -27,7 +27,7 @@ #' @param ... Additional arguments for \code{\link{getMadratGraph}} in case #' that no graph is provided (otherwise ignored) #' @return A fingerprint (hash) of all provided sources, or "fingerprintError" -#' @author Jan Philipp Dietrich, Pascal Führlich +#' @author Jan Philipp Dietrich, Pascal Sauer #' @seealso \code{\link{readSource}} #' @examples #' madrat:::fingerprint("toolGetMapping", package = "madrat") @@ -36,52 +36,51 @@ fingerprint <- function(name, details = FALSE, graph = NULL, ...) { dependencies <- getDependencies(name, direction = "in", self = TRUE, graph = graph, ...) result <- tryCatch({ - fingerprintFunctions <- dependencies$hash[robustOrder(dependencies$call)] - names(fingerprintFunctions) <- dependencies$call[robustOrder(dependencies$call)] + fingerprintFunctions <- dependencies$hash[robustOrder(dependencies$call)] + names(fingerprintFunctions) <- dependencies$call[robustOrder(dependencies$call)] - # handle special requests via flags - .tmp <- function(x) { - return(robustSort(sub(":+", ":::", x))) - } - ignore <- .tmp(attr(dependencies, "flags")$ignore) - monitor <- .tmp(attr(dependencies, "flags")$monitor) - # if conflicting information is giving (monitor and ignore at the same time, - # prioritize monitor request) - ignore <- setdiff(ignore, monitor) - # add calls from the monitor list which are not already monitored - fingerprintMonitored <- fingerprintCall(setdiff(monitor, names(fingerprintFunctions))) - # ignore functions mentioned in the ignore list - fingerprintFunctions <- fingerprintFunctions[setdiff(names(fingerprintFunctions), ignore)] - sources <- substring(dependencies$func[dependencies$type == "read"], 5) - if (length(sources) > 0) { - sources <- paste0(getConfig("sourcefolder"), "/", robustSort(sources)) - } - fingerprintSources <- fingerprintFiles(sources) - fingerprintMappings <- fingerprintFiles(attr(dependencies, "mappings")) - fingerprint <- c(fingerprintFunctions, fingerprintSources, fingerprintMappings, fingerprintMonitored) - fingerprint <- fingerprint[robustOrder(basename(names(fingerprint)))] + # handle special requests via flags + .tmp <- function(x) { + return(robustSort(sub(":+", ":::", x))) + } + ignore <- .tmp(attr(dependencies, "flags")$ignore) + monitor <- .tmp(attr(dependencies, "flags")$monitor) + # if conflicting information is giving (monitor and ignore at the same time, + # prioritize monitor request) + ignore <- setdiff(ignore, monitor) + # add calls from the monitor list which are not already monitored + fingerprintMonitored <- fingerprintCall(setdiff(monitor, names(fingerprintFunctions))) + # ignore functions mentioned in the ignore list + fingerprintFunctions <- fingerprintFunctions[setdiff(names(fingerprintFunctions), ignore)] + sources <- substring(dependencies$func[dependencies$type == "read"], 5) + if (length(sources) > 0) { + sources <- paste0(getConfig("sourcefolder"), "/", robustSort(sources)) + } + fingerprintSources <- fingerprintFiles(sources) + fingerprintMappings <- fingerprintFiles(attr(dependencies, "mappings")) + fingerprint <- c(fingerprintFunctions, fingerprintSources, fingerprintMappings, fingerprintMonitored) + fingerprint <- fingerprint[robustOrder(basename(names(fingerprint)))] - # Cache files became incompatible when readSource was allowed to return non-magpie objects. - # Referring to madrat versions before this change as "old" and after this change as "new" here: - # Hashing the string "v2" leads to completely new hashes, and thus cache files with different names. - # Old madrat versions will never read/write these new cache files, and new madrat versions will never - # read/write cache files created with an old madrat version. - out <- digest(list("v2", unname(fingerprint)), algo = getConfig("hash")) + # Cache files became incompatible when readSource was allowed to return non-magpie objects. + # Referring to madrat versions before this change as "old" and after this change as "new" here: + # Hashing the string "v2" leads to completely new hashes, and thus cache files with different names. + # Old madrat versions will never read/write these new cache files, and new madrat versions will never + # read/write cache files created with an old madrat version. + out <- digest(list("v2", unname(fingerprint)), algo = getConfig("hash")) - if (details) { - attr(out, "details") <- fingerprint - vcat(3, "hash components (", out, "):", show_prefix = FALSE) - for (n in names(fingerprint)) { - vcat(3, " ", fingerprint[n], " | ", basename(n), " | ", n, show_prefix = FALSE) - } + if (details) { + attr(out, "details") <- fingerprint + vcat(3, "hash components (", out, "):", show_prefix = FALSE) + for (n in names(fingerprint)) { + vcat(3, " ", fingerprint[n], " | ", basename(n), " | ", n, show_prefix = FALSE) } - out - }, - error = function(error) { - vcat(2, paste(" - Fingerprinting failed:", error), show_prefix = FALSE) - return("fingerprintError") } - ) + out + }, + error = function(error) { + vcat(2, paste(" - Fingerprinting failed:", error), show_prefix = FALSE) + return("fingerprintError") + }) attr(result, "call") <- dependencies$call[dependencies$func == name] return(result) } @@ -135,7 +134,7 @@ fingerprintFiles <- function(paths) { # return file name for fileHash cache if the given path belongs to a source folder, # otherwise return NULL if (dir.exists(getConfig("sourcefolder")) && - startsWith(normalizePath(path), normalizePath(getConfig("sourcefolder")))) { + startsWith(normalizePath(path), normalizePath(getConfig("sourcefolder")))) { return(paste0(getConfig("cachefolder"), "/fileHashCache", basename(path), ".rds")) } else { return(NULL) diff --git a/R/readSource.R b/R/readSource.R index 6f041830..b7a82151 100644 --- a/R/readSource.R +++ b/R/readSource.R @@ -25,7 +25,7 @@ #' the data and metadata is returned instead. The temporal and data dimensionality #' should match the source data. The spatial dimension should either match the source data or, #' if the convert argument is set to TRUE, should be on ISO code country level. -#' @author Jan Philipp Dietrich, Anastasis Giannousakis, Lavinia Baumstark, Pascal Führlich +#' @author Jan Philipp Dietrich, Anastasis Giannousakis, Lavinia Baumstark, Pascal Sauer #' @seealso \code{\link{setConfig}}, \code{\link{downloadSource}}, \code{\link{readTau}} #' #' @note The underlying read-functions can return a magpie object or a list of information #' (preferred) back to \code{readSource}. In list format the object should have the following diff --git a/R/robustOrder.R b/R/robustOrder.R index 2b3a7b2e..412b768d 100644 --- a/R/robustOrder.R +++ b/R/robustOrder.R @@ -13,7 +13,7 @@ #' @param method Default is "radix", which is locale independent. The alternatives "auto" and "shell" should not be used #' in madrat because they are locale dependent. #' @seealso \code{\link[base]{order}} -#' @author Pascal Führlich +#' @author Pascal Sauer robustOrder <- function(..., na.last = TRUE, # nolint: object_name_linter decreasing = FALSE, method = "radix") { diff --git a/R/toolstartmessage.R b/R/toolstartmessage.R index 64413e71..6d0cfb89 100644 --- a/R/toolstartmessage.R +++ b/R/toolstartmessage.R @@ -9,7 +9,7 @@ #' next vcat executions. Currently this setting can have 4 states: NULL (nothing will be changed), 0 (reset #' hierarchies), "+" (increase hierarchy level by 1) and "-" (decrease hierarchy level by 1). #' @return A list containing diagnostic information required by \code{\link{toolendmessage}}. -#' @author Jan Philipp Dietrich, Pascal Führlich +#' @author Jan Philipp Dietrich, Pascal Sauer #' @seealso \code{\link{toolendmessage}}, \code{\link{vcat}} #' @importFrom utils str #' @examples diff --git a/README.md b/README.md index f8832371..7573c9c4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # May All Data be Reproducible and Transparent (MADRaT) * -R package **madrat**, version **3.6.7** +R package **madrat**, version **3.6.8** [![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,16 +55,16 @@ In case of questions / problems please contact Jan Philipp Dietrich . +Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Sauer P (2023). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi:10.5281/zenodo.1115490 , R package version 3.6.8, . A BibTeX entry for LaTeX users is ```latex @Manual{, 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 Führlich}, + 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 = {2023}, - note = {R package version 3.6.7}, + note = {R package version 3.6.8}, doi = {10.5281/zenodo.1115490}, url = {https://github.com/pik-piam/madrat}, } diff --git a/man/compareMadratOutputs.Rd b/man/compareMadratOutputs.Rd index a8e74efa..0484c8b9 100644 --- a/man/compareMadratOutputs.Rd +++ b/man/compareMadratOutputs.Rd @@ -42,5 +42,5 @@ compareMadratOutputs("madrat", "readTau", c("paper", "historical")) } \author{ -Pascal Führlich +Pascal Sauer } diff --git a/man/downloadSource.Rd b/man/downloadSource.Rd index 9f658833..a1c465e8 100644 --- a/man/downloadSource.Rd +++ b/man/downloadSource.Rd @@ -58,5 +58,5 @@ a <- downloadSource("Tau", subtype = "historical") \code{\link{setConfig}}, \code{\link{readSource}} } \author{ -Jan Philipp Dietrich, David Klein, Pascal Führlich +Jan Philipp Dietrich, David Klein, Pascal Sauer } diff --git a/man/fingerprint.Rd b/man/fingerprint.Rd index 71f0ed0a..c541ff5a 100644 --- a/man/fingerprint.Rd +++ b/man/fingerprint.Rd @@ -49,5 +49,5 @@ madrat:::fingerprint("toolGetMapping", package = "madrat") \code{\link{readSource}} } \author{ -Jan Philipp Dietrich, Pascal Führlich +Jan Philipp Dietrich, Pascal Sauer } diff --git a/man/readSource.Rd b/man/readSource.Rd index 406c03a4..ace78d57 100644 --- a/man/readSource.Rd +++ b/man/readSource.Rd @@ -73,5 +73,5 @@ will corrupt the PUC file. Use with care. } } \author{ -Jan Philipp Dietrich, Anastasis Giannousakis, Lavinia Baumstark, Pascal Führlich +Jan Philipp Dietrich, Anastasis Giannousakis, Lavinia Baumstark, Pascal Sauer } diff --git a/man/robustOrder.Rd b/man/robustOrder.Rd index f7dbfe73..1f768370 100644 --- a/man/robustOrder.Rd +++ b/man/robustOrder.Rd @@ -28,5 +28,5 @@ same encoding as the input although internally character vectors are converted t \code{\link[base]{order}} } \author{ -Pascal Führlich +Pascal Sauer } diff --git a/man/toolstartmessage.Rd b/man/toolstartmessage.Rd index b573acac..bba8e6cb 100644 --- a/man/toolstartmessage.Rd +++ b/man/toolstartmessage.Rd @@ -41,5 +41,5 @@ outerFunction() \code{\link{toolendmessage}}, \code{\link{vcat}} } \author{ -Jan Philipp Dietrich, Pascal Führlich +Jan Philipp Dietrich, Pascal Sauer }