runtraj.execution.slurm.wait#

runtraj.execution.slurm.wait(job_id, poll=30.0, *, cluster=None)[source]#

Wait until every task of a Slurm job array has ended, and return how each ended.

Polls sacct every poll seconds. A task that ended other than complete, or with failed simulations (exit 1) or interrupted ones (exit 3), is logged with its state; its simulations stay pending in the status table. When sacct gives no answer, as on a cluster without Slurm’s accounting database, it asks squeue: while that lists a task it goes on waiting, and when it lists none the job has ended and this returns {}, the status table saying what finished. When neither answers for SILENT_SCHEDULER_SECONDS it stops waiting with an error; the job itself runs on.

Parameters:
  • job_id (str) – The job array’s id.

  • poll (float) – Seconds between sacct calls.

  • cluster (str | None) – The Slurm cluster the job is on, when it is not the default one (clusters in the Slurm options).

Returns:

{task: (state, exit code)} as sacct gives them, such as {"123_0": ("COMPLETED", "0:0")}; empty when only squeue answered.

Return type:

dict[str, tuple[str, str]]

Raises:

SchedulerError – If neither sacct nor squeue gave an answer about the job for SILENT_SCHEDULER_SECONDS.