Skip to content

Commit a2d52fd

Browse files
luccabbluccab user
andauthored
getting max gpus, cpus out of sinfo output (#143)
Co-authored-by: luccab user <luccab@luccab-login-0.luccab-login.tenant-slurm.svc.cluster.local>
1 parent 862ace2 commit a2d52fd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

clusterscope/slurm/partition.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ def get_partition_resources(partition: str) -> dict:
3030
],
3131
)
3232

33-
stdout = result.strip().split("\n")[0]
34-
gres, cpus = stdout.split(",")
33+
max_gpus = 0
34+
max_cpus = 0
35+
36+
for line in result.strip().split("\n"):
37+
if not line:
38+
continue
39+
gres, cpus = line.split(",")
40+
gpus = parse_gres(gres)
41+
42+
max_gpus = max(max_gpus, gpus)
43+
max_cpus = max(max_cpus, int(cpus))
3544

3645
return {
37-
"max_gpus": parse_gres(gres),
38-
"max_cpus": int(cpus),
46+
"max_gpus": max_gpus,
47+
"max_cpus": max_cpus,
3948
}
4049

4150

0 commit comments

Comments
 (0)