Skip to content

Commit 43060e0

Browse files
sawenzelclaude
andcommitted
grid_submit: wait until no subjob is active
This fixes a problem in the --wait and --wait-any modes of grid_submit.sh. - AliEn can briefly report a masterjob as DONE while one of its subjobs in ERROR_A is put back to WAITING. - --wait read only the masterjob status and returned at that moment, although the job was then retried. - Both modes now finish only when no subjob is still active, with ERROR_A counted as active. - A failed or empty status query also counts as active. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0567fe5 commit 43060e0

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎GRID/utils/grid_submit.sh‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,13 @@ EOF
454454
fi
455455

456456

457+
# true while a subjob is not final; ERROR_A (resubmitted) and a failed query count as active
458+
subjobs_active() {
459+
jq -e '(.results | length) == 0 or (.results | any(.status | IN("INSERTING", "SPLITTING", "WAITING", "ASSIGNED", "STARTED", "RUNNING", "SAVING", "SAVED", "ERROR_A")))' \
460+
<<<"$1" >/dev/null
461+
[ $? -ne 1 ]
462+
}
463+
457464
# wait here until all ALIEN jobs have returned
458465
spin[3]="-"
459466
spin[2]="/"
@@ -488,12 +495,16 @@ EOF
488495
else
489496
# check if there are still jobs running/waiting; if not also finish
490497
# this could happen when all jobs are zombies (in which case we also finish)
491-
if ! jq -e '.results | any(.status == "WAITING" or .status == "RUNNING" or .status == "SAVING" or .status == "INSERTING")' \
492-
<<<"${DETAILED_STATUS_JSON}" >/dev/null; then
498+
if ! subjobs_active "${DETAILED_STATUS_JSON}"; then
493499
JOBSTATUS="D" # some job finished successfully
494500
echo "No remaining good job"
495501
fi
496502
fi
503+
elif [ "${JOBSTATUS}" == "D" ]; then
504+
# the masterjob can briefly show DONE while an ERROR_A subjob is resubmitted
505+
if subjobs_active "$(ALIENPY_JSON=true alien.py ps -a -m "${MY_JOBID}")"; then
506+
JOBSTATUS="S"
507+
fi
497508
fi
498509

499510
if [ "${JOBSTATUS}" == "D" ]; then

0 commit comments

Comments
 (0)