From e53efd8ce40e2903ac723d7130942f84a71dd8dc Mon Sep 17 00:00:00 2001 From: Toni Harzendorf Date: Wed, 11 Mar 2026 11:06:42 +0100 Subject: [PATCH] fix loading of array-master job when it already finished - also add tests - add a missing @property --- pyslurm/core/job/step.pyx | 8 ++++++++ tests/integration/test_job_steps.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/pyslurm/core/job/step.pyx b/pyslurm/core/job/step.pyx index fcf459fc..a9208241 100644 --- a/pyslurm/core/job/step.pyx +++ b/pyslurm/core/job/step.pyx @@ -100,6 +100,13 @@ cdef class JobSteps(dict): msg = f"Failed to load step info for Job {job.id}." raise RPCError(msg=msg) + if job.id not in data: + # slurm_get_job_steps returns all running steps for the whole array + # job when using the Master Array ID. So we still have data when + # other Jobs of the Array-Job are still running, but just not for + # Master anymore. Just return empty then, since this Task is already done + return steps + steps.update(data[job.id]) return steps @@ -443,6 +450,7 @@ cdef class JobStep: def container_id(self): return cstr.to_unicode(self.ptr.container_id) + @property def array_id(self): return u32_parse(self.ptr.array_job_id) diff --git a/tests/integration/test_job_steps.py b/tests/integration/test_job_steps.py index 9c67b069..b49f12ea 100644 --- a/tests/integration/test_job_steps.py +++ b/tests/integration/test_job_steps.py @@ -175,3 +175,13 @@ def test_parse_all(submit_job): job = submit_job() util.wait() JobStep.load(job, "batch").to_dict() + + +def test_ignore_array_master(submit_job): + job = submit_job(array="1-3") + util.wait() + + assert JobSteps.load(job) + job.cancel() + util.wait(2) + assert not JobSteps.load(job)