lstautorta.utils.slurm
Functions:
| Name | Description |
|---|---|
job_statistics_from_squeue_output |
Parse job statistics from |
parse_JOBID_in_squeue_CSV_output |
Parse the output of a squeue command, formatted as CSV to retrieve the JOB ID of listed jobs. |
parse_nodes_in_scontrol_show_res_output |
Parse a string containing |
parse_reservation_state |
Parse the state of a reservation from |
parse_slurm_job_ID |
Run |
parse_slurm_nodes |
Run |
job_statistics_from_squeue_output
Parse job statistics from squeue -u lstrta --format="%T,%R".
Warnings
The output of squeue is parsed using a CSV reader, so the format specification must be respected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
squeue_output
|
str
|
Output of squeue |
required |
Source code in src/lstautorta/utils/slurm.py
parse_JOBID_in_squeue_CSV_output
Parse the output of a squeue command, formatted as CSV to retrieve the JOB ID of listed jobs.
Warnings
The output is expected to be CSV (comma separated values), which is obtained with squeue by
specifying the format with a , separator, for instance: "squeue --format="%i,%j" will give a
CSV output with 2 columns job ID and job name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
squeue_output
|
str
|
output of squeue --format="%i,%j" (querying for job ID and job name) |
required |
filter_dict
|
Dict[str, Callable[[str], bool]] or None
|
Filtering function dictionary. Keys are the fields in the output of squeue, eg "JOBID" Values are functions to evaluate on a value of this field, returning true or false. If the output of the function is not True, the entry in squeue output is ignored. Optional, default is None in which case not filtering is applied. |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List of job ID. |
Source code in src/lstautorta/utils/slurm.py
parse_nodes_in_scontrol_show_res_output
Parse a string containing scontrol show res output to find nodes names.
Search for the substring "Nodes" then parses the nodes ID string, and then the nodes numerical ID, which can be a number, list of number, a list of ranges, or a list of the combination of all of that. Examples of strings: ...Nodes=cp[12,34-47] ... ...Nodes=tcs12 ... ...Nodes=lsfj[32-36]
Raises:
| Type | Description |
|---|---|
ValueError
|
If the node's names could not be parsed from the string |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of node names in the reservations |
Source code in src/lstautorta/utils/slurm.py
parse_reservation_state
Parse the state of a reservation from scontrol show res a_reservation output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scontrol_output
|
str
|
Output of `scontrol show res a_reservation |
required |
Returns:
| Type | Description |
|---|---|
str
|
State of the reservation, eg INACTIVE, ACTIVE |
Source code in src/lstautorta/utils/slurm.py
parse_slurm_job_ID
Run squeue to parse job IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slurm_reservations
|
List[str]
|
List of slurm reservation where to query jobs |
required |
slurm_account
|
str
|
Slurm account of the jobs to find |
required |
r0_dl1_job_name
|
str
|
Name of the r0_dl1 jobs in the configuration |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List of job IDs. |
Source code in src/lstautorta/utils/slurm.py
parse_slurm_nodes
Run scontrol show res -uslurm_account` and to get the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slurm_reservations
|
List[str]
|
List of slurm reservation that RTA will use (all nodes in the reservation used) |
required |
slurm_account
|
str
|
slurm account of the RTA, to use the slurm reservations |
required |
Notes
The nodes belonging to reservation which state is not "ACTIVE" are discarded !
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
List of slurm nodes available for RTA, per reservation. |