| 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. |
| Authors: | Toby Hocking [aut, cre] |
| Maintainer: | Toby Hocking <[email protected]> |
| License: | GPL-3 |
| Version: | 2026.3.20 |
| Built: | 2026-05-20 09:59:29 UTC |
| Source: | https://github.com/tdhock/slurm |
User-friendly wrappers for SLURM commands.
Toby Dylan Hocking
Match one or more digits and convert to integer.
"int.pattern""int.pattern"
Convert empty string to zero and use as.integer otherwise.
na.as.zero(int.or.empty)na.as.zero(int.or.empty)
int.or.empty |
int.or.empty |
Integer vector.
Toby Hocking <[email protected]> [aut, cre]
Run sacct_lines then sacct_tasks.
sacct(...)sacct(...)
... |
... |
Same as result of sacct_tasks.
Toby Hocking <[email protected]> [aut, cre]
Get current fields from sacct.
sacct_fields(cmd = "sacct -e")sacct_fields(cmd = "sacct -e")
cmd |
command to run and capture output, default "sacct -e" to query slurm, can be changed to cat a file for testing. |
character vector, items that can be used as format.fields argument to sacct_lines
Toby Hocking <[email protected]> [aut, cre]
Run fread on the output of sacct.
sacct_fread(...)sacct_fread(...)
... |
... |
Data table with the same number of rows as the output of the sacct
command, and additional columns that result from parsing the
columns with sacct.pattern.list. This table typically has more
than one row per task, so typically this table is used as input to
sacct_tasks.
Toby Hocking <[email protected]> [aut, cre]
library(slurm) sacct_fread(text="JobID|ExitCode|State|MaxRSS|Elapsed 18473217_1|0:0|RUNNING||00:03:47 18473217_1.extern|0:0|RUNNING||00:03:47")library(slurm) sacct_fread(text="JobID|ExitCode|State|MaxRSS|Elapsed 18473217_1|0:0|RUNNING||00:03:47 18473217_1.extern|0:0|RUNNING||00:03:47")
Run sacct with args and parse output as a data.table
sacct_lines(args, format.fields = c("JobID", "ExitCode", "State", "MaxRSS", "Elapsed"), delimiter = "\t", out_file = getOption("slurm.sacct_lines.out_file"))sacct_lines(args, format.fields = c("JobID", "ExitCode", "State", "MaxRSS", "Elapsed"), delimiter = "\t", out_file = getOption("slurm.sacct_lines.out_file"))
args |
character string passed to |
format.fields |
character vector of field names to pass to |
delimiter |
passed as –delimiter. |
out_file |
out_file |
Same as sacct_fread.
Toby Hocking <[email protected]> [aut, cre]
Use output of sacct_fread to compute a table with one row per task.
sacct_tasks(task.dt)sacct_tasks(task.dt)
task.dt |
task.dt |
data.table with one row per job/task, typically used as input to
sjob_dt.
Toby Hocking <[email protected]> [aut, cre]
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() } }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() } }
The data come from running sacct on a SLURM system.
This "csv" file results from sacct -P which uses the vertical bar | as the separator. There are five columns and six rows (including header).
The data come from running sacct on a SLURM system.
This "csv" file results from sacct -P which uses the vertical bar | as the separator. There are five columns and 709 rows (including header).
The data come from running sacct on a SLURM system.
This "csv" file results from sacct -P which uses the vertical bar | as the separator. There are five columns and six rows (including header).
Named list of patterns for parsing sacct fields.
"sacct.pattern.list""sacct.pattern.list"
Run sacct and summarize State/ExitCode values for given job IDS
sjob(job.id = sq.jobs(), tasks.width = 11, ...)sjob(job.id = sq.jobs(), tasks.width = 11, ...)
job.id |
job.id |
tasks.width |
tasks.width |
... |
... |
Data table from sjob_dt.
Toby Hocking <[email protected]> [aut, cre]
Summarize task table from sacct_tasks.
sjob_dt(time.dt, tasks.width = 11)sjob_dt(time.dt, tasks.width = 11)
time.dt |
time.dt |
tasks.width |
tasks.width |
data.table with one row per unique value of job/State/ExitCode (and keyed on these columns).
Toby Hocking <[email protected]> [aut, cre]
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)) }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)) }
get currently running jobs
sq.jobs(args = "-u $USER")sq.jobs(args = "-u $USER")
args |
args |
character scalar: job1,job2,etc
Toby Hocking <[email protected]> [aut, cre]