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.
Attributes
| Name | Description |
|---|---|
SALLOC_OPTIONS | No description. |
Functions
| Name | Description |
|---|---|
build_command | Build the salloc command for a batch script. |
main | Entry point for the slurm-alloc command-line tool. |
pragma_to_salloc_arg | Render a pragma as a single salloc command-line argument. |
salloc_args | Split a script's pragmas into salloc arguments and dropped options. |
script_body | Extract the commands of a batch script, dropping shebang and pragmas. |
SALLOC_OPTIONSattributemodule attribute#
SALLOC_OPTIONS = frozenset(
{
'--account',
'--acctg-freq',
'--bb',
'--bbf',
'--begin',
'--bell',
'--chdir',
'--cluster-constraint',
'--clusters',
'--comment',
'--consolidate-segments',
'--constraint',
'--container',
'--container-id',
'--container-type',
'--contiguous',
'--core-spec',
'--cores-per-socket',
'--cpu-freq',
'--cpus-per-gpu',
'--cpus-per-task',
'--deadline',
'--delay-boot',
'--dependency',
'--distribution',
'--exclude',
'--exclusive',
'--extra',
'--extra-node-info',
'--gpu-bind',
'--gpu-freq',
'--gpus',
'--gpus-per-node',
'--gpus-per-socket',
'--gpus-per-task',
'--gres',
'--gres-flags',
'--hint',
'--hold',
'--immediate',
'--job-name',
'--kill-command',
'--licenses',
'--mail-type',
'--mail-user',
'--mcs-label',
'--mem',
'--mem-bind',
'--mem-per-cpu',
'--mem-per-gpu',
'--mem-update',
'--mincpus',
'--network',
'--nice',
'--no-bell',
'--no-kill',
'--no-shell',
'--nodefile',
'--nodelist',
'--nodes',
'--ntasks',
'--ntasks-per-core',
'--ntasks-per-gpu',
'--ntasks-per-node',
'--ntasks-per-socket',
'--oom-kill-step',
'--overcommit',
'--oversubscribe',
'--partition',
'--prefer',
'--priority',
'--profile',
'--qos',
'--quiet',
'--reboot',
'--reservation',
'--resources',
'--resv-ports',
'--segment',
'--signal',
'--sockets-per-node',
'--spread-job',
'--spread-segments',
'--stepmgr',
'--switches',
'--thread-spec',
'--threads-per-core',
'--time',
'--time-min',
'--tmp',
'--tres-bind',
'--tres-per-task',
'--use-min-nodes',
'--verbose',
'--wait-all-nodes',
'--wckey',
'--x11'
}
)build_commandfunction#
def build_command(path: str, run: bool = False, extra_args: List[str] | None = None) -> Tuple[List[str], str | None]Build the salloc command for a batch script.
Parameters
mainfunction#
def main(argv: List[str] | None = None) -> intEntry point for the slurm-alloc command-line tool.
Parameters
Returns
int- The exit code of salloc.
pragma_to_salloc_argfunction#
def pragma_to_salloc_arg(pragma: Pragma) -> strRender a pragma as a single salloc command-line argument.
Parameters
| Name | Type | Description |
|---|---|---|
pragma | Pragma | The pragma to render. |
Returns
str- Either
"--flag"for a valueless switch or"--flag=value".
salloc_argsfunction#
def salloc_args(script: SlurmScript) -> Tuple[List[str], List[str]]Split a script’s pragmas into salloc arguments and dropped options.
Parameters
| Name | Type | Description |
|---|---|---|
script | SlurmScript | The parsed batch script. |
script_bodyfunction#
def script_body(text: str) -> strExtract 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
| Name | Type | Description |
|---|---|---|
text | str | The full text of the batch script. |
Returns
str- The remaining lines, with leading and trailing blank lines removed.