Skip to content

Commit 1c81fc0

Browse files
sbryngelsonclaude
andcommitted
ci: submit-job.sh always submits fresh, cancels any stale SLURM job first
On rerun, the intent is to cancel the old job and run a fresh one — not to reuse an existing running job. Remove the early-exit that skipped resubmission for RUNNING/PENDING jobs; instead scancel any live job as a safety net (in case the 'Cancel SLURM Jobs' step did not fire due to SIGKILL), then always fall through to a fresh sbatch submission. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 07c4ab0 commit 1c81fc0

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

.github/workflows/phoenix/submit-job.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2-$3"
6565
output_file="$job_slug.out"
6666
id_file="${job_slug}.slurm_job_id"
6767

68-
# Idempotency: if a live job already exists for this slug, skip resubmission.
69-
# Only RUNNING/PENDING jobs are reused — a COMPLETED/FAILED job means we should
70-
# run fresh (e.g. new commit pushed) or the monitor step will verify it separately.
68+
# On rerun, cancel any existing job for this slug and submit a fresh one.
69+
# If the job is still live (RUNNING/PENDING), scancel it first as a safety net
70+
# in case the "Cancel SLURM Jobs" step did not fire (e.g. runner was SIGKILL'd).
7171
if [ -f "$id_file" ]; then
7272
existing_id=$(cat "$id_file")
7373
state=$(sacct -j "$existing_id" -n -X -P -o State 2>/dev/null | head -n1 | cut -d'|' -f1 | tr -d ' ' || true)
7474
case "${state:-UNKNOWN}" in
7575
RUNNING|PENDING|REQUEUED|COMPLETING)
76-
echo "Reusing existing SLURM job $existing_id (state=$state) — skipping resubmission"
77-
exit 0
76+
echo "Cancelling stale SLURM job $existing_id (state=$state) before resubmission"
77+
scancel "$existing_id" 2>/dev/null || true
7878
;;
7979
*)
80-
echo "Stale job $existing_id (state=${state:-UNKNOWN}) — resubmitting"
81-
rm -f "$id_file"
80+
echo "Stale job $existing_id (state=${state:-UNKNOWN}) — submitting fresh"
8281
;;
8382
esac
83+
rm -f "$id_file"
8484
fi
8585

8686
submit_output=$(sbatch <<EOT

0 commit comments

Comments
 (0)