slurm_script_generator.salloc#
Turn a batch script into an interactive allocation.
slurm-alloc job.sh reads the #SBATCH pragmas out of a script and starts
salloc with the same resource request, so the job can be debugged
interactively on the nodes it would have run on. With --run the body of the
script is executed inside the allocation instead of dropping into a shell.
Functions
|
Build the salloc command for a batch script. |
|
Entry point for the |
|
Render a pragma as a single salloc command-line argument. |
|
Split a script's pragmas into salloc arguments and dropped options. |
|
Extract the commands of a batch script, dropping shebang and pragmas. |
- slurm_script_generator.salloc.build_command(path: str, run: bool = False, extra_args: List[str] | None = None) Tuple[List[str], str | None][source]#
Build the salloc command for a batch script.
- Parameters:
path – Path to the batch script.
run – Whether to execute the script’s commands in the allocation instead of starting an interactive shell.
extra_args – Additional arguments to append to the salloc invocation.
- Returns:
A tuple of (command as an argument list, the body to run or None).
- slurm_script_generator.salloc.main(argv: List[str] | None = None) int[source]#
Entry point for the
slurm-alloccommand-line tool.- Parameters:
argv – Arguments to parse, defaulting to the process arguments.
- Returns:
The exit code of salloc.
- slurm_script_generator.salloc.pragma_to_salloc_arg(pragma: Pragma) str[source]#
Render a pragma as a single salloc command-line argument.
- Parameters:
pragma – The pragma to render.
- Returns:
Either
"--flag"for a valueless switch or"--flag=value".
- slurm_script_generator.salloc.salloc_args(script: SlurmScript) Tuple[List[str], List[str]][source]#
Split a script’s pragmas into salloc arguments and dropped options.
- Parameters:
script – The parsed batch script.
- Returns:
A tuple of (arguments to pass to salloc, flags salloc does not accept).
- slurm_script_generator.salloc.script_body(text: str) str[source]#
Extract the commands of a batch script, dropping shebang and pragmas.
The body is taken verbatim rather than rebuilt from the parsed script, so that comments, quoting and here-documents survive untouched.
- Parameters:
text – The full text of the batch script.
- Returns:
The remaining lines, with leading and trailing blank lines removed.