Add --extra_slurm_options to srun_fastsurfer.sh for sbatch scheduling options - #853
Conversation
dkuegler
left a comment
There was a problem hiding this comment.
This PR looks nice. Thanks for the contribution.
I have a couple of feedback points, maybe you can rebase and address those issues?
Co-authored-by: dkuegler <12848082+dkuegler@users.noreply.github.com>
Signed-off-by: David Kügler <david.kuegler@dzne.de>
… options Co-authored-by: dkuegler <12848082+dkuegler@users.noreply.github.com>
Signed-off-by: David Kügler <david.kuegler@dzne.de>
6ed4be9 to
35ed9f1
Compare
dkuegler
left a comment
There was a problem hiding this comment.
Resolved comments. Probably squash-merge to drop the extra text script.
There was a problem hiding this comment.
🟡 Changes recommended
The segmentation sbatch argument order currently places --gpus-per-task=1 after the batch script path, so SLURM may not allocate GPUs as intended.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds support in srun_fastsurfer.sh for forwarding arbitrary user-provided sbatch scheduling flags to the segmentation and surface sbatch submissions, addressing the common case where unrecognized SLURM flags were previously forwarded into the container instead of affecting scheduling.
Changes:
- Introduces
--extra_slurm_options,--extra_slurm_options_seg, and--extra_slurm_options_surfand injects them into thesbatchargument lists. - Adjusts
--extra_singularity_options*parsing to allow multiple occurrences by accumulating values. - Adds logic to split extra SLURM options into argument arrays before composing
sbatchcommands.
File summaries
| File | Description |
|---|---|
| srun_fastsurfer.sh | Adds extra SLURM option forwarding and adjusts scheduling argument composition for seg/surf jobs. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: David Kügler <david.kuegler@dzne.de>
There was a problem hiding this comment.
🔵 Needs a closer look
The segmentation GPU request remains positioned after the batch-script path and is therefore not parsed by sbatch.
Review details
Suppressed comments (1)
srun_fastsurfer.sh:604
$seg_cmd_filenamestill precedes the subsequently appended--gpus-per-task=1. Becausesbatchtreats arguments after the script path as script arguments, GPU segmentation jobs will be submitted without requesting a GPU. Append the script path only after the conditional GPU option.
-o "$hpc_work/logs/seg_%A_%a.log" "${slurm_extra_seg[@]}" "$seg_cmd_filename")
if [[ "$cpu_only" == "true" ]] ; then debug "Schedule SLURM job without gpu"
else seg_slurm_sched+=(--gpus-per-task=1)
fi
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Failed to push commit :-/ |
There was a problem hiding this comment.
🟢 Approval recommended
The core forwarding and ordering logic looks correct and addresses the reported SLURM option-loss behavior, with only minor wording/maintainer-clarity nits noted.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This PR proposes
--extra_slurm_options,--extra_slurm_options_segand--extra_slurm_options_surfforsrun_fastsurfer.sh, so scheduling options such as--reservationactually reach thesbatchcalls of the segmentation and surface jobs (fixes #586).What was wrong
srun_fastsurfer.shforwards every option it does not recognize to FastSurfer itself (POSITIONAL_FASTSURFER), so a scheduling option is not rejected — it is silently moved into the FastSurfer call inside the container. Ondevatef190b9, asking for a reserved node produces jobs that are scheduled without the reservation and then abort inside the container:The
sbatchline carries no reservation, while--reservation gpu_nodesends up on thebrun_fastsurfer.shcommand line, whererun_fastsurfer.shstops withERROR: Flag '--reservation' unrecognized.for every case — after the jobs have already been submitted and started.What this changes
Following the suggestion in #586 to generalize this in the style of
--extra_singularity_options, rather than adding a single--reservationflag, this adds three options tosrun_fastsurfer.sh:--extra_slurm_optionsfor both jobs, plus--extra_slurm_options_segand--extra_slurm_options_surffor one of them. Both the segmentation job and the surface job are covered, as requested in the issue. The options are inserted in front of the batch script path, becausesbatchstops parsing options at the batch script and passes everything after it to the script instead. Option strings are split at whitespace, so several options can be given at once (documented in--help, whichdoc/scripts/SLURM.mdrenders). The cleanup and copy helper jobs are deliberately left alone, matching how--partitionbehaves today.How it was verified
We ran
srun_fastsurfer.sh --dryin a temporary directory and inspected thesbatchcommands it prints — no SLURM, singularity or image data needed, and it skips itself off Linux since the script needs GNU coreutils. Six of our seven tests fail againstdevatef190b9and pass with this change; the seventh asserts that the generatedsbatchcommands are byte-for-byte what they are today when none of the new options are given, and passes both before and after, which is the backward-compatibility check.