Skip to content

Commit

Permalink
Merge pull request #94 from dklein-pik/master
Browse files Browse the repository at this point in the history
REMIND: Check for summation errors and report in already existing `Mif` column of `getRunStatus`
  • Loading branch information
dklein-pik authored Mar 8, 2024
2 parents 4bea29e + 1cd4462 commit cbe65c2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -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'
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: '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
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut","cre")),
person("Oliver", "Richters", role = "aut")
Expand Down
11 changes: 9 additions & 2 deletions R/getRunStatus.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(miffile)){
out[i, "Mif"] <- "no"
} else if (file.exists(sumErrFile)){
out[i, "Mif"] <- "sumErr"
} else {
out[i, "Mif"] <- "yes"
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions R/loopRuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 7 additions & 4 deletions R/modeltests.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -305,15 +308,15 @@ 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("../")
message("Skipping ", i, " and changed back to ", normalizePath("."))
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()
Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -47,7 +47,7 @@ In case of questions / problems please contact Anastasis Giannousakis <giannou@p

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

Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.18.1, <https://github.com/pik-piam/modelstats>.
Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.19.0, <https://github.com/pik-piam/modelstats>.

A BibTeX entry for LaTeX users is

Expand All @@ -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},
}
```

0 comments on commit cbe65c2

Please sign in to comment.