-
Notifications
You must be signed in to change notification settings - Fork 129
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
run all output scripts on one slurm, improve logging #1340
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,7 @@ if (comp %in% c("comparison", "export")) { | |
if (! exists("source_include")) { | ||
# for selected output scripts, only slurm configurations matching these regex are available | ||
slurmExceptions <- if ("reporting" %in% output) "--mem=[0-9]*[0-9]{3}" else NULL | ||
if (all(output %in% outputUsingDirect)) slurmConfig <- "direct" | ||
if (any(output %in% outputUsingDirect)) slurmConfig <- "direct" | ||
# if this script is not being sourced by another script but called from the command line via Rscript let the user | ||
# choose the slurm options | ||
if (!exists("slurmConfig")) { | ||
|
@@ -257,38 +257,38 @@ if (comp %in% c("comparison", "export")) { | |
message("\nNo output generation, as output was set to NA, as for example for --testOneRegi or --quick.") | ||
} else { | ||
message("\nStarting output generation for ", outputdir, "\n") | ||
for (rout in output) { | ||
name <- paste(rout, ".R", sep = "") | ||
if ("--test" %in% flags) { | ||
message("Test mode, not executing ", paste0("scripts/output/single/", name)) | ||
} else { | ||
if (file.exists(paste0("scripts/output/single/", name))) { | ||
if (slurmConfig == "direct" | rout %in% outputUsingDirect) { | ||
# execute output script directly (without sending it to slurm) | ||
message("Executing ", name) | ||
tmp.env <- new.env() | ||
tmp.error <- try(sys.source(paste0("scripts/output/single/", name), envir = tmp.env)) | ||
# rm(list=ls(tmp.env),envir=tmp.env) | ||
rm(tmp.env) | ||
gc() | ||
if (!is.null(tmp.error)) { | ||
warning("Script ", name, " was stopped by an error and not executed properly!") | ||
} | ||
} else { | ||
# send the output script to slurm | ||
logfile <- paste0(outputdir, "/log_", rout, ".txt") | ||
slurmcmd <- paste0("sbatch ", slurmConfig, " --job-name=", logfile, " --output=", logfile, | ||
" --mail-type=END --comment=", rout, " --wrap=\"Rscript scripts/output/single/", rout, | ||
".R outputdir=", outputdir, "\"") | ||
message("Sending to slurm: ", name, ". Find log in ", logfile) | ||
system(slurmcmd) | ||
Sys.sleep(1) | ||
name <- paste0(output, ".R") | ||
if ("--test" %in% flags) { | ||
message("Test mode, not executing scripts/output/single/", paste(name, collapse = ", ")) | ||
} else if (all(file.exists(paste0("scripts/output/single/", name)))) { | ||
if (slurmConfig == "direct") { | ||
# execute output script directly (without sending it to slurm) | ||
for (n in name) { | ||
message("Executing ", n) | ||
tmp.env <- new.env() | ||
tmp.error <- try(sys.source(paste0("scripts/output/single/", n), envir = tmp.env)) | ||
# rm(list=ls(tmp.env),envir=tmp.env) | ||
rm(tmp.env) | ||
gc() | ||
if (!is.null(tmp.error)) { | ||
warning("Script ", n, " was stopped by an error and not executed properly!") | ||
} | ||
} | ||
} else { | ||
# send the output script to slurm | ||
logfile <- file.path(outputdir, "log_output.txt") | ||
Rscripts <- paste0("Rscript scripts/output/single/", name, " outputdir=", outputdir, collapse = "; ") | ||
slurmcmd <- paste0("sbatch ", slurmConfig, " --job-name=", logfile, " --output=", logfile, | ||
" --mail-type=END --comment=output.R --wrap='", Rscripts, "'") | ||
message("Sending to slurm: ", paste(name, collapse = ", "), ". Find log in ", logfile) | ||
system(slurmcmd) | ||
} | ||
# finished | ||
message("\nFinished ", ifelse(slurmConfig == "direct", "", "starting job for "), "output generation for ", outputdir, "!\n") | ||
} else { | ||
warning("Skipping ", outputdir, " because some output script selected could not be found ", | ||
"in scripts/output/single: ", name[! name %in% dir("scripts/output/single")]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like your proposal to run more than one R-scripts in one slurm job to avoid mess |
||
} | ||
# finished | ||
message("\nFinished ", ifelse(slurmConfig == "direct", "", "starting jobs for "), "output generation for ", outputdir, "!\n") | ||
} | ||
|
||
rm(source_include) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll state to obvious (at least obvious to anyone who read the
R
man page):this deactivates the renv, making consistent results from REMIND runs a gamble once the versions of the packages required by
ecoGAINSAirpollutants.R
diverge between the renv library and whatever happens to be inR_LIBS_SITE
.