| Version: | 2025.4.9 |
| License: | GPL-3 |
| Title: | Running and Parsing Slurm Commands |
| Description: | User-friendly functions which parse output of command line programs used to query Slurm. Morris A. Jette and Tim Wickberg (2023) <doi:10.1007/978-3-031-43943-8_1> describe Slurm in detail. |
| Imports: | data.table (≥ 1.11.6), nc (≥ 2019.11.22) |
| SystemRequirements: | Slurm command line programs (sacct, squeue) |
| Suggests: | testthat, ggplot2, R.utils |
| NeedsCompilation: | no |
| Packaged: | 2025-04-09 09:25:44 UTC; hoct2726 |
| Author: | Toby Hocking [aut, cre] |
| Maintainer: | Toby Hocking <toby.hocking@r-project.org> |
| Repository: | CRAN |
| Date/Publication: | 2025-04-09 10:30:02 UTC |
Running and Parsing SLURM Commands
Description
User-friendly wrappers for SLURM commands.
Author(s)
Toby Dylan Hocking
int pattern
Description
Match one or more digits and convert to integer.
Usage
"int.pattern"na as zero
Description
Convert empty string to zero and use as.integer otherwise.
Usage
na.as.zero(int.or.empty)Arguments
int.or.empty | int.or.empty |
Value
Integer vector.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
sacct
Description
Runsacct_lines thensacct_tasks.
Usage
sacct(...)Arguments
... | ... |
Value
Same as result ofsacct_tasks.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
Output of sacct for thousands of jobs
Description
The data come from running sacct on a SLURM system.
Format
This "csv" file results from sacct -P which uses the vertical bar | asthe separator. There are five columns and six rows (including header).
Output of sacct for one job with several tasks
Description
The data come from running sacct on a SLURM system.
Format
This "csv" file results from sacct -P which uses the vertical bar | asthe separator. There are five columns and 709 rows (including header).
Output of sacct for three job with several tasks
Description
The data come from running sacct on a SLURM system.
Format
This "csv" file results from sacct -P which uses the vertical bar | asthe separator. There are five columns and six rows (including header).
sacct pattern list
Description
Named list of patterns for parsingsacct fields.
Usage
"sacct.pattern.list"sacct fields
Description
Get current fields fromsacct.
Usage
sacct_fields()Value
character vector.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
sacct fread
Description
Run fread on the output ofsacct.
Usage
sacct_fread(...)Arguments
... | ... |
Value
Data table with the same number of rows as the output of thesacctcommand, and additional columns that result from parsing thecolumns withsacct.pattern.list.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
Examples
library(slurm) sacct_fread(text="JobID|ExitCode|State|MaxRSS|Elapsed18473217_1|0:0|RUNNING||00:03:4718473217_1.extern|0:0|RUNNING||00:03:47")sacct lines
Description
Runsacct withargs and parse output as a data.table
Usage
sacct_lines(args, format.fields = c("JobID", "ExitCode", "State", "MaxRSS", "Elapsed"), delimiter = "\t")Arguments
args | character string passed to |
format.fields | character vector of field names to pass to |
delimiter | passed as –delimiter. |
Value
Same assacct_fread.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
sacct tasks
Description
Summarize output fromsacct_fread.
Usage
sacct_tasks(match.dt)Arguments
match.dt | match.dt |
Value
data.table with one row per job/task.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
Examples
library(slurm)sacct.csv.gz <- system.file( "data", "sacct-job13936577.csv.gz", package="slurm", mustWork=TRUE)if(requireNamespace("R.utils")){ sacct.dt <- sacct_fread(sacct.csv.gz) task.dt <- sacct_tasks(sacct.dt) print(task.dt[State_batch != "COMPLETED"]) if(require(ggplot2)){ ggplot()+ geom_point(aes( hours, megabytes, fill=State_batch), shape=21, data=task.dt)+ scale_fill_manual(values=c( COMPLETED=NA, FAILED="red"))+ scale_x_log10()+ scale_y_log10() }}sjob
Description
Runsacct and summarize State/ExitCode values for given job IDS
Usage
sjob(job.id = sq.jobs(), tasks.width = 11)Arguments
job.id | job.id |
tasks.width | tasks.width |
Value
Data table fromsjob_dt.
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
sjob dt
Description
Get summary dt fromsacct dt.
Usage
sjob_dt(time.dt, tasks.width = 11)Arguments
time.dt | time.dt |
tasks.width | tasks.width |
Value
data.table summarizing State/ExitCode distribution over jobs
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
Examples
library(slurm)sacct.csv.gz <- system.file( "data", "sacct-job13936577.csv.gz", package="slurm", mustWork=TRUE)if(requireNamespace("R.utils")){ task.dt <- sacct_fread(sacct.csv.gz) print(summary.dt <- sjob_dt(task.dt))}sq jobs
Description
get currently running jobs
Usage
sq.jobs(args = "-u $USER")Arguments
args | args |
Value
character scalar: job1,job2,etc
Author(s)
Toby Hocking <toby.hocking@r-project.org> [aut, cre]
task pattern
Description
Pattern for either one task or a range.
Usage
"task.pattern"