The functions sbatch
, scancel
, squeue
, sacct
, and slurm.conf
are
wrappers of calls to Slurm functions via system2.
slurm_available()
squeue(x = NULL, ...)
# S3 method for default
squeue(x = NULL, ...)
# S3 method for slurm_job
squeue(x, ...)
scancel(x = NULL, ...)
# S3 method for default
scancel(x = NULL, ...)
# S3 method for slurm_job
scancel(x = NULL, ...)
sacct(x, ...)
# S3 method for default
sacct(x = NULL, brief = TRUE, parsable = TRUE, allocations = TRUE, ...)
# S3 method for slurm_job
sacct(x, ...)
slurm.conf()
SchedulerParameters()
sacct_(x = NULL, ..., no_sacct = FALSE)
sbatch(x, wait = FALSE, submit = TRUE, ...)
# S3 method for slurm_job
sbatch(x, wait = FALSE, submit = TRUE, ...)
# S3 method for character
sbatch(x, wait = FALSE, submit = TRUE, ...)
Either an object of class slurm_job
, or, in some cases, an
integer as a Slurm jobid. Note that some functions allow passing no arguments.
Further flags passed to the command line function.
Logical. When TRUE
, these are passed as flags directly
to the command line function sacct
.
Logical. Skip sacct
directly (for internal use only.)
Logical scalar. When TRUE
the function will pass the --wait
flag to Slurm
and set wait = TRUE
in the system2 call.
Logical, when TRUE
calls sbatch to submit the job to slurm.
In the case of sbatch
, depends on what x
is:
If x
is of class slurm_job, then it returns the same object including
the Slurm job ID (if the job was submitted to the queue).
If x
is a file path (e.g. a bash script), an integer with the jobid number
(again, if the job was submitted to Slurm).
The functions squeue
and sacct
return a data frame with the information
returned by the command line utilities. The function scancel
returns NULL.
slurm_available()
returns a logical scalar equal to TRUE
if Slurm is
available.
slurm.conf()
and SchedulerParameters()
return information about the
Slurm cluster, if available.
The function slurm_available
checks whether Slurm is available in
the system or not. It is usually called before calling any bash wrapper.
If available, the function will return TRUE
, otherwise FALSE
.
The wrapper of squeue includes the flag -o%all
which returns all
available fields separated by a vertical bar. This cannot be changed since it
is the easiest way of processing the information in R.
The function slurm.conf
is a wrapper of the function scontrol
that
returns configuration info about Slurm, in particular, the underlying command
that is called is scontrol show conf
. This returns a named character vector
with configuration info about the cluster. The name of this function matches
the name of the file that holds this information.
The function SchedulerParameters
is just a wrapper of slurm.conf.
It processes the field "SchedulerParameters" included in the configuration
file and has information relevant for the scheduler.
sacct.
is an alternative that works around when sacct
fails due to
lack of accounting on. This function is not intended for direct call.
In the case of sbatch
, function takes an object of class slurm_job
and
submits it to the queue. In debug mode the job will be submitted via sh
instead.
The method for character scalars is used to submit jobs using a slurm script.
# Are we under a Slurm Cluster?
slurm_available()
#> sbatch
#> FALSE
if (FALSE) {
# What is the maximum number of jobs (array size) that the system
# allows?
sconfig <- slurm.conf() # We first retrieve the info.
sconfig["MaxArraySize"]
}
if (FALSE) {
# Submitting a simple job
job <- Slurm_EvalQ(slurmR::WhoAmI(), njobs = 4L, plan = "submit")
# Checking the status of the job (we can simply print)
job
status(job) # or use the state function
sacct(job) # or get more info with the sactt wrapper.
# Suppose one of the jobs is taking too long to complete (say #4)
# we can stop it and resubmit the job as follows:
scancel(job)
# Resubmitting only 4
sbatch(job, array = 4) # A new jobid will be assigned
}