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.
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.
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