Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init folder config from envvars #211

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '61926200'
ValidationKey: '62025600'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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.5
version: 3.12.0
date-released: '2024-06-06'
abstract: Provides a framework which should improve reproducibility and transparency
in data processing. It provides functionality such as automatic meta data creation
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: madrat
Title: May All Data be Reproducible and Transparent (MADRaT) *
Version: 3.11.5
Version: 3.12.0
Date: 2024-06-06
Authors@R: c(
person("Jan Philipp", "Dietrich", , "[email protected]", role = c("aut", "cre"),
Expand Down
27 changes: 16 additions & 11 deletions R/initializeConfig.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#' initializeConfig
#'
#' Checks whether configuration already has been set. If not, it will be initialized
#' with default settings or (if available) system settings.
#' with default settings or (if available) system settings. All madrat folders (see
#' \code{\link{setConfig}} for documentation which folders are available) will be set
#' to the system environment variables MADRAT_SOURCEFOLDER, MADRAT_CACHEFOLDER, etc.
#' if they exist, NA otherwise. NA means subfolders of the mainfolder are used.
#'
#' @param verbose boolean deciding whether status information/updates should be shown or not
#' @author Jan Philipp Dietrich
Expand All @@ -11,20 +14,22 @@ initializeConfig <- function(verbose = TRUE) {
# check whether config has not been initialized yet
# and initialize it (otherwise do nothing)
if (is.null(getOption("madrat_cfg"))) {
if (verbose) message("\nInitialize madrat config with default settings..")
if (verbose) {
message("\nInitializing madrat config with default settings")
}

cfg <- list(regionmapping = "regionmappingH12.csv",
extramappings = NULL,
packages = "madrat",
globalenv = FALSE,
verbosity = 1,
mainfolder = getMainfolder(verbose = verbose),
sourcefolder = NA,
cachefolder = NA,
mappingfolder = NA,
outputfolder = NA,
pucfolder = NA,
tmpfolder = NA,
sourcefolder = Sys.getenv("MADRAT_SOURCEFOLDER", unset = NA),
cachefolder = Sys.getenv("MADRAT_CACHEFOLDER", unset = NA),
mappingfolder = Sys.getenv("MADRAT_MAPPINGFOLDER", unset = NA),
outputfolder = Sys.getenv("MADRAT_OUTPUTFOLDER", unset = NA),
pucfolder = Sys.getenv("MADRAT_PUCFOLDER", unset = NA),
tmpfolder = Sys.getenv("MADRAT_TMPFOLDER", unset = NA),
nolabels = NULL,
forcecache = FALSE,
ignorecache = NULL,
Expand All @@ -33,10 +38,10 @@ initializeConfig <- function(verbose = TRUE) {
diagnostics = FALSE,
debug = FALSE,
maxLengthLogMessage = 200)
options(madrat_cfg = cfg) # nolint
if (verbose) {
options(madrat_cfg = cfg) # nolint
if (verbose) {
message(paste(paste0(" ", names(cfg)), cfg, sep = " = ", collapse = "\n"))
message("..done!\n")
}
}
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# May All Data be Reproducible and Transparent (MADRaT) *

R package **madrat**, version **3.11.5**
R package **madrat**, version **3.12.0**

[![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)

Expand Down Expand Up @@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **madrat** in publications use:

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 <https://doi.org/10.5281/zenodo.1115490>, R package version 3.11.5, <https://github.com/pik-piam/madrat>.
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 <https://doi.org/10.5281/zenodo.1115490>, R package version 3.12.0, <https://github.com/pik-piam/madrat>.

A BibTeX entry for LaTeX users is

Expand All @@ -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.5},
note = {R package version 3.12.0},
url = {https://github.com/pik-piam/madrat},
doi = {10.5281/zenodo.1115490},
}
Expand Down
5 changes: 4 additions & 1 deletion man/initializeConfig.Rd

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