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

Additional parameters for SLURM to work correctly on LRZ cluster #115

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 24 additions & 1 deletion R/clusterFunctionsSLURM.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@
#' @template arg_template
#' @template arg_list_jobs_cmd
#' @template ret_cf
#' @param list.job.line.skip [\code{integer(1)}]\cr
#' Change how many lines of the job list should be skipped. Can be useful if \code{squeue} is giving
#' additional output.
#' @param cluster.name [\code{character(1)}]\cr
#' If an additional cluster name has to be specified for listing or deleting jobs it can be
#' supplied with this argument. it will be added as \code{--clusters=cluster.name} for SLURM.
#' @family clusterFunctions
#' @export
makeClusterFunctionsSLURM = function(template.file, list.jobs.cmd = c("squeue", "-h", "-o %i", "-u $USER")) {
makeClusterFunctionsSLURM = function(template.file, list.jobs.cmd = c("squeue", "-h", "-o %i", "-u $USER"),
list.job.line.skip = 0L, cluster.name = NULL) {

if (!is.null(cluster.name)) {
assertString(cluster.name)
list.jobs.cmd = append(list.jobs.cmd, paste0("--clusters=", cluster.name))
}
assertCharacter(list.jobs.cmd, min.len = 1L, any.missing = FALSE)
assertCount(list.job.line.skip)
template = cfReadBrewTemplate(template.file)

submitJob = function(conf, reg, job.name, rscript, log.file, job.dir, resources, arrayjobs) {
Expand All @@ -45,12 +58,22 @@ makeClusterFunctionsSLURM = function(template.file, list.jobs.cmd = c("squeue",
}

killJob = function(conf, reg, batch.job.id) {


if (!is.null(cluster.name)) {
cfKillBatchJob("scancel",paste0("--clusters=", cluster.name, " ", batch.job.id))
}
cfKillBatchJob("scancel", batch.job.id)
}

listJobs = function(conf, reg) {
# Result is lines of fully quantified batch.job.ids
jids = runOSCommandLinux(list.jobs.cmd[1L], list.jobs.cmd[-1L])$output
# if squeue returns additional information (like cluster name), one or more
# lines can be omitted
if (list.job.line.skip > 0L) {
jids = jids[-seq_len(list.job.line.skip)]
}
stri_extract_first_regex(jids, "[0-9]+")
}

Expand Down
10 changes: 9 additions & 1 deletion man/makeClusterFunctionsSLURM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.