Add SLURM gres extraction from resources

This commit is contained in:
Benoît Seignovert 2024-02-20 11:16:53 +01:00
parent 21935f15f5
commit 05be86da07
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
2 changed files with 23 additions and 0 deletions

View file

@ -181,3 +181,15 @@ def sinfo_from_file(fname, with_states=('idle', 'mixed')) -> dict:
def sinfo(username: str = None, with_states=('idle', 'mixed')) -> dict:
"""SLURM SINFO resources available for a given user."""
return sinfo_filter(sinfo_reader(sinfo_run(username=username)), with_states=with_states)
def gres(resources: dict) -> list:
"""List SLURM GPU resources."""
return sorted(
{
node.gpu.name
for cluster in resources.values()
for partition in cluster
for node in partition
}
)