From 4fd680c73c2baf0c33141f2aa26bf63cc61dc52f Mon Sep 17 00:00:00 2001 From: David Klein Date: Fri, 8 Mar 2024 15:44:25 +0100 Subject: [PATCH 1/3] REMIND: Check if summation checks revealed gaps and append to summary. --- R/getRunStatus.R | 11 +++++++++-- R/loopRuns.R | 4 ++-- R/modeltests.R | 11 +++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/R/getRunStatus.R b/R/getRunStatus.R index f9f758e..9df33ed 100644 --- a/R/getRunStatus.R +++ b/R/getRunStatus.R @@ -126,8 +126,15 @@ getRunStatus <- function(mydir = dir(), sort = "nf", user = NULL) { miffile <- paste0(ii, "/validation.mif") out[i, "Mif"] <- if (file.exists(miffile) && file.info(miffile)[["size"]] > 99999) "yes" else "no" } else { - miffile <- paste0(ii, "/REMIND_generic_", cfg[["title"]], ".mif") - out[i, "Mif"] <- if (file.exists(miffile) && file.info(miffile)[["size"]] > 3899999) "yes" else "no" + miffile <- paste0(ii, "/REMIND_generic_", cfg[["title"]], ".mif") + sumErrFile <- paste0(ii, "/REMIND_generic_", cfg[["title"]], "_summation_errors.csv") + if (file.exists(sumErrFile)){ + out[i, "Mif"] <- "sumErr" + } else if (file.exists(miffile)){ + out[i, "Mif"] <- "yes" + } else { + out[i, "Mif"] <- "no" + } } } diff --git a/R/loopRuns.R b/R/loopRuns.R index c26c61e..72c86c3 100644 --- a/R/loopRuns.R +++ b/R/loopRuns.R @@ -43,11 +43,11 @@ loopRuns <- function(mydir, user = NULL, colors = TRUE, sortbytime = TRUE) { if (file.exists("/p")) { coltitles <- c(paste0("Folder", paste(rep(" ", len - 6), collapse = "")), "Runtime ", "inSlurm ", "RunType ", "RunStatus ", "Iter ", - "Conv ", "modelstat ", "Mif", "AppResults") + "Conv ", "modelstat ", "Mif ", "AppResults") lenCols <- c(nchar(coltitles)[-length(coltitles)], 3) } else { coltitles <- c(paste0("Folder", paste(rep(" ", len - 6), collapse = "")), - "Runtime ", "RunType ", "RunStatus ", "Mif", + "Runtime ", "RunType ", "RunStatus ", "Mif ", "Conv ", "Iter ", "modelstat ") lenCols <- nchar(coltitles) } diff --git a/R/modeltests.R b/R/modeltests.R index 6f84c1f..fb01fb0 100644 --- a/R/modeltests.R +++ b/R/modeltests.R @@ -267,7 +267,7 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken colSep <- " " coltitles <- c( "Run ", "Runtime ", "", "RunType ", "RunStatus ", - "Iter ", "Conv ", "modelstat ", "Mif", "AppResults" + "Iter ", "Conv ", "modelstat ", "Mif ", "AppResults" ) write(paste(coltitles, collapse = colSep), myfile, append = TRUE) lenCols <- c(nchar(coltitles)[-length(coltitles)], 3) @@ -289,6 +289,9 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken if (grepl("testOneRegi", grsi[, "RunType"]) && grsi[, "modelstat"] != "2: Locally Optimal") { errorList <- c(errorList, "testOneRegi does not return an optimal solution") } + if (grsi[, "Mif"] == "sumErr") { + errorList <- c(errorList, "Summation checks for some run(s) revealed some gaps") + } } else if (model == "MAgPIE") { if (paste0(unique(unlist(strsplit(gsub("[^0-9]", "", grsi[, "modelstat"]), split = ""))), collapse = "") != "2") { errorList <- c(errorList, "Some run(s) did not converge") @@ -305,7 +308,7 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken # Doesn't this check exclude runs that have 'converged (had INFES)' and # wouldn't it be useful to also produce compareScenarios for these? The existence of the mif file only # matters later on after the runtime check when it comes to compareScenarios. So why testing for it here? - if (any(grepl(basename(getwd()), rownames(filter(gRS, .data$Conv == "converged", .data$Mif == "yes"))))) { + if (any(grepl(basename(getwd()), rownames(filter(gRS, .data$Conv == "converged", .data$Mif %in% c("yes", "sumErr")))))) { load("config.Rdata") } else { setwd("../") @@ -313,7 +316,7 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken next } sameRuns <- gRS %>% filter(.data$Conv %in% c("converged", "converged (had INFES)"), # runs have to be converged - .data$Mif == "yes", # need to have mifs + .data$Mif %in% c("yes", "sumErr"), # need to have mifs grepl(cfg$title, rownames(gRS)), # must be the same scenario ! rownames(gRS) %in% basename(cfg$results_folder)) %>% # but not the current run rownames() @@ -403,7 +406,7 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken } } } - write(paste0("The IAMC check of these runs can be found in /p/projects/remind/modeltests/output/iamccheck-", + write(paste0("The IAMC check of these runs can be found in /p/projects/remind/modeltests/remind/output/iamccheck-", commitTested, ".rds", "\n"), myfile, append = TRUE) } From e1025b355dbcc18704113351751b3af7b9cb877d Mon Sep 17 00:00:00 2001 From: David Klein Date: Fri, 8 Mar 2024 15:51:05 +0100 Subject: [PATCH 2/3] 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 c642c4c..edc004b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '3581447' +ValidationKey: '3760100' 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 0336187..e89b9a0 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: 'modelstats: Run Analysis Tools' -version: 0.18.1 -date-released: '2024-03-05' +version: 0.19.0 +date-released: '2024-03-08' abstract: A collection of tools to analyze model runs. authors: - family-names: Giannousakis diff --git a/DESCRIPTION b/DESCRIPTION index 2653835..5f69006 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: modelstats Type: Package Title: Run Analysis Tools -Version: 0.18.1 -Date: 2024-03-05 +Version: 0.19.0 +Date: 2024-03-08 Authors@R: c( person("Anastasis", "Giannousakis", email = "giannou@pik-potsdam.de", role = c("aut","cre")), person("Oliver", "Richters", role = "aut") diff --git a/README.md b/README.md index 99b5008..e43791e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Run Analysis Tools -R package **modelstats**, version **0.18.1** +R package **modelstats**, version **0.19.0** [![CRAN status](https://www.r-pkg.org/badges/version/modelstats)](https://cran.r-project.org/package=modelstats) [![R build status](https://github.com/pik-piam/modelstats/workflows/check/badge.svg)](https://github.com/pik-piam/modelstats/actions) [![codecov](https://codecov.io/gh/pik-piam/modelstats/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/modelstats) [![r-universe](https://pik-piam.r-universe.dev/badges/modelstats)](https://pik-piam.r-universe.dev/builds) @@ -47,7 +47,7 @@ In case of questions / problems please contact Anastasis Giannousakis . +Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.19.0, . A BibTeX entry for LaTeX users is @@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is title = {modelstats: Run Analysis Tools}, author = {Anastasis Giannousakis and Oliver Richters}, year = {2024}, - note = {R package version 0.18.1}, + note = {R package version 0.19.0}, url = {https://github.com/pik-piam/modelstats}, } ``` From 1cd44622dd64e62f299975b7348760fe6f2458ee Mon Sep 17 00:00:00 2001 From: David Klein Date: Fri, 8 Mar 2024 16:23:37 +0100 Subject: [PATCH 3/3] Fix: Reorder conditions, since it is possible that sumErrFile exists, but no reporting mif. --- R/getRunStatus.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/getRunStatus.R b/R/getRunStatus.R index 9df33ed..785c484 100644 --- a/R/getRunStatus.R +++ b/R/getRunStatus.R @@ -128,12 +128,12 @@ getRunStatus <- function(mydir = dir(), sort = "nf", user = NULL) { } else { miffile <- paste0(ii, "/REMIND_generic_", cfg[["title"]], ".mif") sumErrFile <- paste0(ii, "/REMIND_generic_", cfg[["title"]], "_summation_errors.csv") - if (file.exists(sumErrFile)){ + if (! file.exists(miffile)){ + out[i, "Mif"] <- "no" + } else if (file.exists(sumErrFile)){ out[i, "Mif"] <- "sumErr" - } else if (file.exists(miffile)){ - out[i, "Mif"] <- "yes" } else { - out[i, "Mif"] <- "no" + out[i, "Mif"] <- "yes" } } }