Skip to content

Commit 65a6321

Browse files
authored
Update submit.sh
1 parent d7a0592 commit 65a6321

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/phoenix/submit.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,24 @@ echo "🚀 Submitted SLURM job $JOBID"
6565
# if this wrapper is killed/canceled, make sure SLURM job is cleaned up
6666
trap '[[ -n "${JOBID:-}" ]] && scancel "$JOBID" >/dev/null 2>&1 || :' EXIT
6767

68-
# poll until job finishes
69-
while true; do
70-
STATE=$(sacct -j "$JOBID" --noheader --format=State | head -1 | cut -d' ' -f1)
68+
# ────────── Poll until SLURM job finishes ──────────
69+
while :; do
70+
# First try sacct (may take a moment to appear)
71+
STATE=$(sacct -j "$JOBID" --format=State --noheader --parsable2 | head -n1)
72+
73+
# If sacct didn’t return anything yet, check squeue
74+
if [[ -z "$STATE" ]]; then
75+
STATE=$(squeue -j "$JOBID" -h -o "%T" || echo "")
76+
fi
77+
78+
# When both are empty, the job has left the queue
79+
if [[ -z "$STATE" ]]; then
80+
echo "✅ SLURM job $JOBID no longer in queue; assuming finished"
81+
break
82+
fi
83+
7184
echo "⏳ SLURM job $JOBID state: $STATE"
72-
case "$STATE" in
73-
COMPLETED|FAILED|CANCELLED|TIMEOUT) break ;;
74-
*) sleep 10 ;;
75-
esac
85+
sleep 10
7686
done
7787

7888
# show final report

0 commit comments

Comments
 (0)