From 8d0b4413d3675b69bb117613acdb0d936710d100 Mon Sep 17 00:00:00 2001 From: orichters Date: Wed, 26 Jun 2024 08:50:20 +0200 Subject: [PATCH] add note in RunStatus if conopt is probably hanging --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 5 +++-- NAMESPACE | 1 + R/getRunStatus.R | 6 ++++++ R/loopRuns.R | 10 +++++++--- README.md | 6 +++--- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index f6c5ee9..7b710b7 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '42046587' +ValidationKey: '42068600' 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 df1e191..c1496cd 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.21.13 -date-released: '2024-06-25' +version: 0.21.14 +date-released: '2024-06-26' abstract: A collection of tools to analyze model runs. authors: - family-names: Giannousakis diff --git a/DESCRIPTION b/DESCRIPTION index af6a1ac..d3163be 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: modelstats Type: Package Title: Run Analysis Tools -Version: 0.21.13 -Date: 2024-06-25 +Version: 0.21.14 +Date: 2024-06-26 Authors@R: c( person("Anastasis", "Giannousakis", email = "giannou@pik-potsdam.de", role = c("aut","cre")), person("Oliver", "Richters", role = "aut") @@ -16,6 +16,7 @@ Imports: gtools, lubridate, lucode2, + piamutils, utils, gms, withr, diff --git a/NAMESPACE b/NAMESPACE index 3bf0e14..57eae4a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ importFrom(gtools,mixedorder) importFrom(gtools,mixedsort) importFrom(lubridate,make_difftime) importFrom(lucode2,sendmail) +importFrom(piamutils,niceround) importFrom(rlang,.data) importFrom(utils,head) importFrom(utils,read.csv2) diff --git a/R/getRunStatus.R b/R/getRunStatus.R index 5589618..45e6559 100644 --- a/R/getRunStatus.R +++ b/R/getRunStatus.R @@ -16,6 +16,7 @@ #' @importFrom gdx readGDX #' @importFrom utils head tail #' @importFrom gms loadConfig +#' @importFrom piamutils niceround #' @export getRunStatus <- function(mydir = dir(), sort = "nf", user = NULL) { substrRight <- function(x, n) { @@ -178,6 +179,11 @@ getRunStatus <- function(mydir = dir(), sort = "nf", user = NULL) { } } else { out[i, "RunStatus"] <- "Run in progress" + gridfiles <- Sys.glob(file.path(ii, "225*", "grid*", "gmsgrid.log")) + if (length(gridfiles) > 0) { + conoptdelay <- round(difftime(Sys.time(), max(file.info(gridfiles)$mtime), units = "hours") - 0.049, 1) + if (conoptdelay > 0) out[i, "RunStatus"] <- paste0("conoptspy >", niceround(conoptdelay, 1), "h") + } } } else { if (out[i, "RunStatus"] == "NA") out[i, "RunStatus"] <- "Run interrupted" diff --git a/R/loopRuns.R b/R/loopRuns.R index 72c86c3..b4fc30a 100644 --- a/R/loopRuns.R +++ b/R/loopRuns.R @@ -27,7 +27,7 @@ loopRuns <- function(mydir, user = NULL, colors = TRUE, sortbytime = TRUE) { if (colors) { cat("# Color code: ", yellow("pending"), "/", yellow("startup"), ", ", cyan("running"), ", ", underline(green("converged")), ", ", blue("converged (had INFES)"), ", ", - green("finished"), ", ", red("error"), ".\n\n", sep = "") + green("finished"), ", ", magenta("conopt stalled?"), ", ", red("error"), ".\n\n", sep = "") } a <- file.info(mydir) a <- a[a[, "isdir"] == TRUE, ] @@ -79,7 +79,7 @@ loopRuns <- function(mydir, user = NULL, colors = TRUE, sortbytime = TRUE) { out <- trimws(printOutput(status, lenCols = lenCols, colSep = colSep), which = "right", whitespace = " ") status <- unlist(status) - if (grepl("^y[12]", status[["Iter"]]) || grepl("^nlp_", status[["RunType"]])) { + if (grepl("^y[12]", status[["Iter"]]) || grepl("^nlp_", status[["RunType"]])) { # MAgPIE if (isFALSE(colors)) { cat(out) } else if (status[["Runtime"]] %in% "pending") { @@ -91,6 +91,8 @@ loopRuns <- function(mydir, user = NULL, colors = TRUE, sortbytime = TRUE) { } else if ((grepl("222", status[["modelstat"]]) && ! grepl(".", status[["modelstat"]], fixed = TRUE)) || status[["modelstat"]] == "2: Locally Optimal") { cat(green(out)) + } else if (grepl("conoptspy >", out, fixed = TRUE)) { + cat(magenta(out)) } else if (grepl("Run in progress", out)) { cat(cyan(out)) } else if (all(grepl(" NA ", out) & grepl("FALSE", out))) { @@ -98,11 +100,13 @@ loopRuns <- function(mydir, user = NULL, colors = TRUE, sortbytime = TRUE) { } else { cat(out) } - } else { + } else { # REMIND if (isFALSE(colors)) { cat(out) } else if (status[["Runtime"]] %in% c("pending", "startup")) { cat(yellow(out)) + } else if (grepl("conoptspy >", out, fixed = TRUE)) { + cat(magenta(out)) } else if (! status[["jobInSLURM"]] == "no") { cat(cyan(out)) } else if (status[["Conv"]] == "converged (had INFES)") { diff --git a/README.md b/README.md index 817830f..c1dfa9d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Run Analysis Tools -R package **modelstats**, version **0.21.13** +R package **modelstats**, version **0.21.14** [![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.21.14, . 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.21.13}, + note = {R package version 0.21.14}, url = {https://github.com/pik-piam/modelstats}, } ```