From e9777ccd4bdf08ef61b92cfa7a53637ffe0dc164 Mon Sep 17 00:00:00 2001 From: David Hoetten Date: Mon, 13 May 2024 17:33:45 +0200 Subject: [PATCH 1/3] added file extension option --- R/benchmark.R | 2 +- R/package_settings.R | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/R/benchmark.R b/R/benchmark.R index d3fad85..e976a59 100644 --- a/R/benchmark.R +++ b/R/benchmark.R @@ -177,7 +177,7 @@ benchmark <- list( baseline_dir = baseline_dir, under_test_dirs = under_test_dirs, - suffix = ".bin.json" + suffix = getOption("lpjmlstats.file_extension", default = ".bin.json") ) sim_table <- create_simulation_table(paths) diff --git a/R/package_settings.R b/R/package_settings.R index f37c8a0..ad1e38c 100644 --- a/R/package_settings.R +++ b/R/package_settings.R @@ -26,6 +26,9 @@ #' \item \code{metric_at_start}: A string to be matched against the #' names of the metrics. The matched metrics will be run first #' and displayed at the beginning of the report. +#' +#' \item \code{file_extension}: A string indicating the file extension +#' to be used by read_io. #' } #' #' @@ -76,6 +79,11 @@ set_lpjmlstats_settings <- function(...) { stop("metrics_at_start must be a character string") options(lpjmlstats.metrics_at_start = option_value) # nolint }, + "file_extension" = { + if (!(is.character(option_value) | is.null(option_value))) + stop("file_extension must be a character string") + options(lpjmlstats.file_extension = option_value) # nolint + }, stop(paste("Invalid option:", option_name)) ) } From f2ced1a9fff3551e14c93111e35a672f1627905b Mon Sep 17 00:00:00 2001 From: David Hoetten Date: Mon, 13 May 2024 17:38:18 +0200 Subject: [PATCH 2/3] build library --- .buildlibrary | 2 +- .github/workflows/check.yaml | 13 ++++++++++--- .pre-commit-config.yaml | 4 ++-- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/package_settings.R | 2 +- README.md | 8 ++++---- man/set_lpjmlstats_settings.Rd | 3 +++ 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 7f19ad1..a835741 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '337246' +ValidationKey: '397120' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 7d564a1..f6ea5d4 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -35,7 +35,7 @@ jobs: # 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 + - uses: actions/setup-python@v5 with: python-version: 3.9 @@ -48,6 +48,11 @@ jobs: shell: Rscript {0} run: lucode2:::validkey(stopIfInvalid = TRUE) + - name: Verify that lucode2::buildLibrary was successful + if: github.event_name == 'pull_request' + shell: Rscript {0} + run: lucode2:::isVersionUpdated() + - name: Checks shell: Rscript {0} run: | @@ -56,6 +61,8 @@ jobs: - name: Test coverage shell: Rscript {0} - run: covr::codecov(quiet = FALSE) + run: | + nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) + if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) env: NOT_CRAN: "true" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d2e4ca..62f13da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: '^tests/testthat/_snaps/.*$' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0 hooks: - id: check-case-conflict - id: check-json @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9019 + rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index af420e8..7166a0b 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: 'lpjmlstats: Statistical tools for LPJmL data analysis' -version: 0.1.7 -date-released: '2024-04-25' +version: 0.2.0 +date-released: '2024-05-13' abstract: This package provides statistical tools for LPJmL data analysis to be used for benchmarking LPJmL outputs. authors: diff --git a/DESCRIPTION b/DESCRIPTION index effefec..783c7d1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: lpjmlstats Title: Statistical tools for LPJmL data analysis -Version: 0.1.7 +Version: 0.2.0 Authors@R: c(person("David","Hötten", email = "davidho@pik-potsdam.de", role = c("aut", "cre")), person("Jannes","Breier", email = "jannes.breier@pik-potsdam.de", role = c("aut"))) Description: This package provides statistical tools for LPJmL data analysis @@ -38,4 +38,4 @@ Config/testthat/edition: 3 VignetteBuilder: knitr Depends: R (>= 3.5.0) -Date: 2024-04-25 +Date: 2024-05-13 diff --git a/R/package_settings.R b/R/package_settings.R index ad1e38c..e228500 100644 --- a/R/package_settings.R +++ b/R/package_settings.R @@ -26,7 +26,7 @@ #' \item \code{metric_at_start}: A string to be matched against the #' names of the metrics. The matched metrics will be run first #' and displayed at the beginning of the report. -#' +#' #' \item \code{file_extension}: A string indicating the file extension #' to be used by read_io. #' } diff --git a/README.md b/README.md index f7fd7ab..18d1def 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Statistical tools for LPJmL data analysis -R package **lpjmlstats**, version **0.1.7** +R package **lpjmlstats**, version **0.2.0** -[![CRAN status](https://www.r-pkg.org/badges/version/lpjmlstats)](https://cran.r-project.org/package=lpjmlstats) [![R build status](https://github.com/PIK-LPJmL/lpjmlstats//workflows/check/badge.svg)](https://github.com/PIK-LPJmL/lpjmlstats//actions) [![codecov](https://codecov.io/gh/PIK-LPJmL/lpjmlstats//branch/master/graph/badge.svg)](https://app.codecov.io/gh/PIK-LPJmL/lpjmlstats/) [![r-universe](https://pik-piam.r-universe.dev/badges/lpjmlstats)](https://pik-piam.r-universe.dev/builds) +[![CRAN status](https://www.r-pkg.org/badges/version/lpjmlstats)](https://cran.r-project.org/package=lpjmlstats) [![R build status](https://gitlab.pik-potsdam.de/lpjml/lpjmlstats/workflows/check/badge.svg)](https://gitlab.pik-potsdam.de/lpjml/lpjmlstats/actions) [![codecov](https://codecov.io/gh/lpjml/lpjmlstats/branch/master/graph/badge.svg)](https://app.codecov.io/gh/lpjml/lpjmlstats) [![r-universe](https://pik-piam.r-universe.dev/badges/lpjmlstats)](https://pik-piam.r-universe.dev/builds) ## Purpose and Functionality @@ -48,7 +48,7 @@ In case of questions / problems please contact David Hötten Date: Mon, 13 May 2024 18:30:07 +0200 Subject: [PATCH 3/3] added setting check, corrected create_simulation_table meta retrieve --- R/benchmark.R | 6 +++--- R/package_settings.R | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/benchmark.R b/R/benchmark.R index e976a59..fa6efcb 100644 --- a/R/benchmark.R +++ b/R/benchmark.R @@ -285,11 +285,11 @@ create_simulation_table <- function(paths) { lpjml_version <- c() for (path in sim_paths) { - # read any file with a .bin.json extension in the directory + # read any file with the correct file extension in the directory # and extract the meta data - # get filename of any file with .bin.json extension in the directory - file <- list.files(path, pattern = ".bin.json", full.names = TRUE)[1] + # get filename of any fitting file + file <- list.files(path, pattern = paths$suffix, full.names = TRUE)[1] # get relevant meta information from that file meta <- lpjmlkit::read_meta(file) diff --git a/R/package_settings.R b/R/package_settings.R index e228500..3991fc6 100644 --- a/R/package_settings.R +++ b/R/package_settings.R @@ -80,7 +80,7 @@ set_lpjmlstats_settings <- function(...) { options(lpjmlstats.metrics_at_start = option_value) # nolint }, "file_extension" = { - if (!(is.character(option_value) | is.null(option_value))) + if (!(is.character(option_value) | is.null(option_value)) | length(option_value) != 1) stop("file_extension must be a character string") options(lpjmlstats.file_extension = option_value) # nolint },