slurm_available {slurmR}R Documentation

R wrappers for Slurm commands

Description

The functions sbatch, scancel, squeue, sacct, and slurm.conf are wrappers of calls to Slurm functions via system2.

Usage

slurm_available()

squeue(x = NULL, ...)

## Default S3 method:
squeue(x = NULL, ...)

## S3 method for class 'slurm_job'
squeue(x, ...)

scancel(x = NULL, ...)

## Default S3 method:
scancel(x = NULL, ...)

## S3 method for class 'slurm_job'
scancel(x = NULL, ...)

sacct(x, ...)

## Default S3 method:
sacct(x = NULL, brief = TRUE, parsable = TRUE, allocations = TRUE, ...)

## S3 method for class 'slurm_job'
sacct(x, ...)

slurm.conf()

SchedulerParameters()

sacct_(x = NULL, ..., no_sacct = FALSE)

sbatch(x, wait = FALSE, submit = TRUE, ...)

## S3 method for class 'slurm_job'
sbatch(x, wait = FALSE, submit = TRUE, ...)

## S3 method for class 'character'
sbatch(x, wait = FALSE, submit = TRUE, ...)

Arguments

x

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.

brief, parsable, allocations

Logical. When TRUE, these are passed as flags directly to the command line function sacct.

no_sacct

Logical. Skip sacct directly (for internal use only.)

wait

Logical scalar. When TRUE the function will pass the --wait flag to Slurm and set wait = TRUE in the system2 call.

submit

Logical, when TRUE calls sbatch to submit the job to slurm.

Details

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.

Value

In the case of sbatch, depends on what x is:

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.

Examples

# Are we under a Slurm Cluster?
slurm_available()


## Not run: 
# What is the maximum number of jobs (array size) that the system
# allows?
sconfig <- slurm.conf() # We first retrieve the info.
sconfig["MaxArraySize"]

## End(Not run)

## Not run: 
# 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


## End(Not run)

[Package slurmR version 0.5-4 Index]