Skip to content

Commit

Permalink
Merge pull request #181 from tscheypidi/master
Browse files Browse the repository at this point in the history
bugfix in retrieveData
  • Loading branch information
pfuehrlich-pik authored Sep 4, 2023
2 parents 2af1b57 + d549de1 commit acfd6a9
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '7101369'
ValidationKey: '7131488'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
92 changes: 21 additions & 71 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Run CI for R using https://eddelbuettel.github.io/r-ci/

name: check

on:
Expand All @@ -8,92 +6,44 @@ on:
pull_request:
branches: [main, master]

env:
USE_BSPM: "true"
_R_CHECK_FORCE_SUGGESTS_: "false"
NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")'

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Bootstrap
run: |
sudo chown runner -R .
sudo locale-gen en_US.UTF-8
sudo add-apt-repository -y ppa:ubuntugis/ppa
curl -OLs https://eddelbuettel.github.io/r-ci/run.sh
chmod 0755 run.sh
./run.sh bootstrap
rm -f bspm_*.tar.gz
- name: Enable r-universe repo, modify bspm integration
run: |
# install packages from https://pik-piam.r-universe.dev and CRAN
echo '
options(repos = c(universe = "https://pik-piam.r-universe.dev",
CRAN = "https://cloud.r-project.org"))
' >> .Rprofile
cat .Rprofile
# modify bspm integration to never install binary builds of PIK CRAN packages
sudo sed -i '/bspm::enable()/d' /etc/R/Rprofile.site
# need double % because of printf, %s is replaced with "$NO_BINARY_INSTALL_R_PACKAGES" (see "env:" above)
printf '
local({
expr <- quote({
if (!is.null(repos)) {
noBinaryInstallRPackages <- %s
pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]),
pkgs[pkgs %%in%% noBinaryInstallRPackages])
}
type <- "source"
})
trace(utils::install.packages, expr, print = FALSE)
})
' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null
cat /etc/R/Rprofile.site
- name: Set up Pandoc
uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-pandoc@v2

- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: r-lib/actions/setup-r@v2
with:
python-version: 3.9
use-public-rspm: true
extra-repositories: "https://rse.pik-potsdam.de/r/packages"

- name: Cache R libraries
if: ${{ !env.ACT }} # skip when running locally via nektos/act
uses: pat-s/always-upload-cache@v3
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: /usr/local/lib/R/
key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }}
restore-keys: |
3-${{ runner.os }}-usr-local-lib-R-
- name: Restore R library permissions
run: |
sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library
- name: Install dependencies
run: |
./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev
./run.sh install_all
./run.sh install_r_binary covr rstudioapi
./run.sh install_r lucode2
extra-packages: |
any::lucode2
any::covr
any::madrat
any::magclass
any::citation
any::gms
any::goxygen
any::GDPuc
# piam packages also available on CRAN (madrat, magclass, citation,
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest version

- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install python dependencies if applicable
run: |
[ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true
[ -f requirements.txt ] && pip install -r requirements.txt || true
- name: Remove bspm integration # to get rid of error when running install.packages
run: |
sudo sed -i '/ trace(utils::install.packages, expr, print = FALSE)/d' /etc/R/Rprofile.site
cat /etc/R/Rprofile.site
- name: Verify validation key
shell: Rscript {0}
run: lucode2:::validkey(stopIfInvalid = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9013
rev: v0.3.2.9019
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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.3
date-released: '2023-07-25'
version: 3.6.4
date-released: '2023-08-23'
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
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: madrat
Title: May All Data be Reproducible and Transparent (MADRaT) *
Version: 3.6.3
Date: 2023-07-25
Version: 3.6.4
Date: 2023-08-23
Authors@R: c(
person("Jan Philipp", "Dietrich", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", , "[email protected]", role = "aut"),
Expand Down
4 changes: 2 additions & 2 deletions R/fullEXAMPLE.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#' retrieveData("example", rev = "2.1.2", dev = "test", regionmapping = "regionmappingH12.csv")
#' }
#'
fullEXAMPLE <- function(rev = 0, dev = "", extra = "Example argument") {
fullEXAMPLE <- function(rev = as.numeric_version("0"), dev = "", extra = "Example argument") {
# ATTENTION: name of the model in function name must be in capital letters!

"!# @pucArguments extra"

writeLines(extra, "test.txt")

if (rev >= 1) {
if (rev >= "1") {
calcOutput("TauTotal", years = 1995, round = 2, file = "fm_tau1995.cs4")
}
if (dev == "test") {
Expand Down
9 changes: 4 additions & 5 deletions R/retrieveData.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ retrieveData <- function(model, rev = 0, dev = "", cachetype = "def", puc = iden
stop("Unknown cachetype \"", cachetype, "\"!")
}

rev <- numeric_version(rev)
rev <- numeric_version(as.character(rev))

# check and structure settings
cfg <- .prepConfig(model, rev, dev, ...)
Expand Down Expand Up @@ -255,9 +255,8 @@ retrieveData <- function(model, rev = 0, dev = "", cachetype = "def", puc = iden
# are arguments used in both - setConfig and the fullFunction? -> warning
tmp <- intersect(formalArgs(setConfig), names(cfg$fullDefault))
if (length(tmp) > 0) {
warning(
"Overlapping arguments between setConfig and retrieve function (\"",
paste(tmp, collapse = '", "'), '")')
warning("Overlapping arguments between setConfig and retrieve function (\"",
paste(tmp, collapse = '", "'), '")')
}

# create argument hash
Expand Down Expand Up @@ -295,7 +294,7 @@ retrieveData <- function(model, rev = 0, dev = "", cachetype = "def", puc = iden
extraArgs <- paste0(paste(cfg$pucArguments, collapse = "_"), "_")
}
cfg$pucName <- paste0("rev", rev, dev, "_", extraArgs, .argsHash(cfg$formalsPUC, useLabels),
tolower(model), ifelse(getConfig("debug") == TRUE, "_debug", ""))
tolower(model), ifelse(getConfig("debug") == TRUE, "_debug", ""))

return(cfg)
}
Expand Down
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.6.3**
R package **madrat**, version **3.6.4**

[![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, Führlich P (2023). _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.6.3, <https://github.com/pik-piam/madrat>.
Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Führlich P (2023). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi: 10.5281/zenodo.1115490 (URL: https://doi.org/10.5281/zenodo.1115490), R package version 3.6.4, <URL: 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 Führlich},
year = {2023},
note = {R package version 3.6.3},
note = {R package version 3.6.4},
doi = {10.5281/zenodo.1115490},
url = {https://github.com/pik-piam/madrat},
}
Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## CHANGES
* fixed msentropy-related error currently showing up on r-revel machines on CRAN
* fixed numeric_version-related error currently showing up on r-devel machines on CRAN

## Test environments
* local R installation, R 4.1.2
Expand Down
6 changes: 5 additions & 1 deletion man/fullEXAMPLE.Rd

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

0 comments on commit acfd6a9

Please sign in to comment.