From 6831e2d1b4dee64dc3c1ff689d375a2faa58fda5 Mon Sep 17 00:00:00 2001 From: Derek Feichtinger Date: Fri, 19 Jun 2026 18:01:26 +0200 Subject: [PATCH] first fix to be able and handle CANCELED jobs which lack some values --- slurm-eff-tool.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slurm-eff-tool.py b/slurm-eff-tool.py index 3953dca..c6cbc5f 100755 --- a/slurm-eff-tool.py +++ b/slurm-eff-tool.py @@ -616,7 +616,10 @@ def build_job_records(rows: list[dict[str, str]], # *.interactive or *.0 steps used_tres = [UsedTresStruct.from_tres_string(r.get("TRESUsageInTot","")) \ for r in rss_source_rows] - mem_used_tres = max(r.mem for r in used_tres if r.mem is not None) + tmp_used_tres_mem = [r.mem for r in used_tres if r.mem is not None] + if len(tmp_used_tres_mem) == 0: + continue + mem_used_tres = max(tmp_used_tres_mem) mem_used_tres_gb = None if mem_used_tres is not None: mem_used_tres_gb = mem_used_tres / (1024**3) @@ -627,6 +630,10 @@ def build_job_records(rows: list[dict[str, str]], req_ntasks = req_tres.cpu alloc_cpus = int(float(top.get("AllocCPUS") or 0)) + # If no CPU was ever allocated, this is a job that never was + # scheduled to run. We exclude it + if alloc_cpus == 0: + continue nodes = int(float(top.get("NNodes") or 0)) elapsed = int(float(top.get("ElapsedRaw") or 0))