Skip to content
Snippets Groups Projects
Commit 307fb372 authored by David Klein's avatar David Klein
Browse files

Refactoring start scripts: - moved the definition of the slurm strings from ...

Refactoring start scripts: - moved the definition of the slurm strings from  submit() in submit.R to choose_submit() in start.R
- renamed the function choose_submit() to choose_slurmConfig() and moved it to the new file choose_slurmConfig.R
parent 5192d4b0
No related branches found
No related tags found
1 merge request!34Refactoring start scripts (yeah!)
#######################################################################
############### Select slurm partitiion ###############################
#######################################################################
get_line <- function(){
# gets characters (line) from the terminal or from a connection
# and returns it
if(interactive()){
s <- readline()
} else {
con <- file("stdin")
s <- readLines(con, 1, warn=FALSE)
on.exit(close(con))
}
return(s);
}
choose_slurmConfig <- function() {
slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE))
if (slurm) {
modes <- c("SLURM standby - task per node: 12 (nash H12) [recommended]",
"SLURM standby - task per node: 13 (nash H12 coupled)",
"SLURM standby - task per node: 16 (nash H12+)",
"SLURM standby - task per node: 1 (nash debug, test one regi)",
"SLURM priority - task per node: 12 (nash H12) [recommended]",
"SLURM priority - task per node: 13 (nash H12 coupled)",
"SLURM priority - task per node: 16 (nash H12+)",
"SLURM priority - task per node: 1 (nash debug, test one regi)",
"SLURM short - task per node: 12 (nash H12)",
"SLURM short - task per node: 16 (nash H12+)",
"SLURM short - task per node: 1 (nash debug, test one regi)",
"SLURM medium - task per node: 1 (negishi)",
"SLURM long - task per node: 1 (negishi)")
cat("\nCurrent cluster utilization:\n")
system("sclass")
cat("\n")
cat("\nPlease choose run submission type:\n")
cat(paste(1:length(modes), modes, sep=": " ),sep="\n")
cat("Number: ")
identifier <- get_line()
identifier <- as.numeric(strsplit(identifier,",")[[1]])
comp <- switch(identifier,
"1" = "--qos=standby --nodes=1 --tasks-per-node=12" , # SLURM standby - task per node: 12 (nash H12) [recommended]
"2" = "--qos=standby --nodes=1 --tasks-per-node=13" , # SLURM standby - task per node: 13 (nash H12 coupled)
"3" = "--qos=standby --nodes=1 --tasks-per-node=16" , # SLURM standby - task per node: 16 (nash H12+)
"4" = "--qos=standby --nodes=1 --tasks-per-node=1" , # SLURM standby - task per node: 1 (nash debug, test one regi)
"5" = "--qos=priority --nodes=1 --tasks-per-node=12" , # SLURM priority - task per node: 12 (nash H12) [recommended]
"6" = "--qos=priority --nodes=1 --tasks-per-node=13" , # SLURM priority - task per node: 13 (nash H12 coupled)
"7" = "--qos=priority --nodes=1 --tasks-per-node=16" , # SLURM priority - task per node: 16 (nash H12+)
"8" = "--qos=priority --nodes=1 --tasks-per-node=1" , # SLURM priority - task per node: 1 (nash debug, test one regi)
"9" = "--qos=short --nodes=1 --tasks-per-node=12" , # SLURM short - task per node: 12 (nash H12)
"10" = "--qos=short --nodes=1 --tasks-per-node=16" , # SLURM short - task per node: 16 (nash H12+)
"11" = "--qos=short --nodes=1 --tasks-per-node=1" , # SLURM short - task per node: 1 (nash debug, test one regi)
"12" = "--qos=medium --nodes=1 --tasks-per-node=1" , # SLURM medium - task per node: 1 (negishi)
"13" = "--qos=long --nodes=1 --tasks-per-node=1" ) # SLURM long - task per node: 1 (negishi)
if(is.null(comp)) stop("This type is invalid. Please choose a valid type")
} else {
comp <- "direct"
}
return(comp)
}
Gedchtnissttze fr die slurm-Varianten
# Replace load leveler-script with appropriate version
if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") {
if(length(unique(map$RegionCode)) <= 12) {
cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
"scripts/run_submit/submit_par.cmd"
} else { # use max amount of cores if regions number is greater than 12
cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
"scripts/run_submit/submit_par16.cmd"
}
} else if (cfg$gms$optimization == "testOneRegi") {
cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
"scripts/run_submit/submit_short.cmd"
}
# Call appropriate submit script
if (cfg$sendToSlurm) {
# send to slurm
if(cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") {
if(length(unique(map$RegionCode)) <= 12) {
system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par.cmd"))
system("sbatch submit_par.cmd")
} else { # use max amount of cores if regions number is greater than 12
system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par16.cmd"))
system("sbatch submit_par16.cmd")
}
} else if (cfg$gms$optimization == "testOneRegi") {
system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit_short.cmd"))
system("sbatch submit_short.cmd")
} else {
system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit.cmd"))
if (cfg$gms$cm_startyear > 2030) {
system("sbatch --partition=ram_gpu submit.cmd")
} else {
system("sbatch submit.cmd")
}
......@@ -54,62 +54,11 @@ submit <- function(cfg) {
sbatch_command <- paste0("sbatch --job-name=",cfg$title," --output=",cfg$title,".out --mail-type=END --comment=REMIND --wrap=\"Rscript prepare_and_run.R \"")
if(cfg$slurmConfig=="direct") {
log <- format(Sys.time(), paste0(cfg$title,"-%Y-%H-%M-%S-%OS3.log"))
system("Rscript prepare_and_run.R ",cfg$title, stderr = log, stdout = log, wait=FALSE)
} else if(cfg$slurmConfig=="priority") {
system(paste(sbatch_command,"--nodes=1 --tasks-per-node=12 --qos=priority"))
Sys.sleep(1)
} else if(cfg$slurmConfig=="standby") {
system(paste(sbatch_command,"--nodes=1 --tasks-per-node=12 --qos=standby"))
Sys.sleep(1)
} else if(cfg$slurmConfig=="short") {
system(paste(sbatch_command,"--qos=short"))
Sys.sleep(1)
} else if(cfg$slurmConfig=="medium") {
system(paste(sbatch_command,"--qos=medium"))
Sys.sleep(1)
} else if(cfg$slurmConfig=="long") {
system(paste(sbatch_command,"--qos=long"))
Sys.sleep(1)
system("Rscript prepare_and_run.R")
} else {
stop("Unknown submission type")
system(paste(sbatch_command,cfg$slurmConfig))
Sys.sleep(1)
}
# Gedchtnissttze fr die slurm-Varianten
## Replace load leveler-script with appropriate version
#if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") {
# if(length(unique(map$RegionCode)) <= 12) {
# cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
# "scripts/run_submit/submit_par.cmd"
# } else { # use max amount of cores if regions number is greater than 12
# cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
# "scripts/run_submit/submit_par16.cmd"
# }
#} else if (cfg$gms$optimization == "testOneRegi") {
# cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <-
# "scripts/run_submit/submit_short.cmd"
#}
# Call appropriate submit script
#if (cfg$sendToSlurm) {
# # send to slurm
# if(cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") {
# if(length(unique(map$RegionCode)) <= 12) {
# system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par.cmd"))
# system("sbatch submit_par.cmd")
# } else { # use max amount of cores if regions number is greater than 12
# system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par16.cmd"))
# system("sbatch submit_par16.cmd")
# }
# } else if (cfg$gms$optimization == "testOneRegi") {
# system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit_short.cmd"))
# system("sbatch submit_short.cmd")
# } else {
# system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit.cmd"))
# if (cfg$gms$cm_startyear > 2030) {
# system("sbatch --partition=ram_gpu submit.cmd")
# } else {
# system("sbatch submit.cmd")
# }
return(cfg$results_folder)
}
library(lucode)
source("scripts/start/submit.R")
#######################################################################
############### Select slurm partitiion ###############################
#######################################################################
get_line <- function(){
# gets characters (line) from the terminal or from a connection
# and returns it
if(interactive()){
s <- readline()
} else {
con <- file("stdin")
s <- readLines(con, 1, warn=FALSE)
on.exit(close(con))
}
return(s);
}
choose_submit <- function(title="Please choose run submission type") {
# xxx add REMIND specific combinations of qos and number of nodes
modes <- c("SLURM priority (recommended)",
"SLURM standby (recommended)",
"SLURM short",
"SLURM medium",
"SLURM long")
cat("\nCurrent cluster utilization:\n")
system("sclass")
cat("\n")
cat("\n",title,":\n", sep="")
cat(paste(1:length(modes), modes, sep=": " ),sep="\n")
cat("Number: ")
identifier <- get_line()
identifier <- as.numeric(strsplit(identifier,",")[[1]])
comp <- switch(identifier,
"1" = "priority",
"2" = "standby",
"3" = "short",
"4" = "medium",
"5" = "long")
if(is.null(comp)) stop("This type is invalid. Please choose a valid type")
return(comp)
}
source("scripts/start/choose_slurmConfig.R")
# Choose submission type
slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE))
if (slurm) {
slurmConfig <- choose_submit("Choose submission type")
} else {
slurmConfig <- "direct"
}
slurmConfig <- choose_slurmConfig()
#######################################################################
######################## Submit run ###################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment