Skip to content

Use machine-readable Slurm CLI output #7554

Description

@agoscinski

I wonder why this hasn't been a problem so far yet. But our parsing seems to not use the more stable CLI commands with the more stable output API for parsing.

Quick agentic summary

A job named `test^^^run` can break AiiDA's `squeue` parser because `^^^` is also used as the field separator. Likewise, AiiDA expects `sbatch` to print the human-readable English text `Submitted batch job <id>`.

Slurm has machine-readable options such as `sbatch --parsable`, `sacct --parsable2`, and, in newer versions, `--json`. We should use these where supported, with fallbacks for older supported Slurm versions.

Affected functions in `src/aiida/schedulers/plugins/slurm.py`:

- `SlurmScheduler._get_joblist_command`
- `SlurmScheduler._parse_joblist_output`
- `SlurmScheduler._get_detailed_job_info_command`
- `SlurmScheduler._get_submit_command`
- `SlurmScheduler._parse_submit_output`

Suggested changes:

- use `sbatch --parsable` and parse `job_id[;cluster]`;
- use an explicit `sacct --parsable2 --noheader --format=...` field list;
- investigate JSON or another escaped format for `squeue`;
- retain compatibility fallbacks and add tests for delimiters and unusual job names.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions