Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add note in RunStatus if conopt is probably stalled #114

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -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'
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.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
Expand Down
5 changes: 3 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.21.13
Date: 2024-06-25
Version: 0.21.14
Date: 2024-06-26
Authors@R: c(
person("Anastasis", "Giannousakis", email = "[email protected]", role = c("aut","cre")),
person("Oliver", "Richters", role = "aut")
Expand All @@ -16,6 +16,7 @@ Imports:
gtools,
lubridate,
lucode2,
piamutils,
utils,
gms,
withr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions R/getRunStatus.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions R/loopRuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ]
Expand Down Expand Up @@ -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") {
Expand All @@ -91,18 +91,22 @@ 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))) {
cat(red(out))
} 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)") {
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.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)

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.21.13, <https://github.com/pik-piam/modelstats>.
Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.21.14, <URL: 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.21.13},
note = {R package version 0.21.14},
url = {https://github.com/pik-piam/modelstats},
}
```