Skip to content

Commit a4a2fd7

Browse files
committed
improvements to grid_submit
* use TMPDIR if available * improvements to early exit condition for job waiting
1 parent 617b5e8 commit a4a2fd7

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

GRID/utils/grid_submit.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pok "Set the job name by running $0 <scriptname> <jobname>"
272272
# Generate local workdir
273273
#
274274
if [[ "${ONGRID}" == "0" ]]; then
275-
GRID_SUBMIT_WORKDIR=${GRID_SUBMIT_WORKDIR:-/tmp/alien_work/$(basename "$MY_JOBWORKDIR")}
275+
GRID_SUBMIT_WORKDIR=${GRID_SUBMIT_WORKDIR:-${TMPDIR:-/tmp}/alien_work/$(basename "$MY_JOBWORKDIR")}
276276
echo "WORKDIR FOR THIS JOB IS ${GRID_SUBMIT_WORKDIR}"
277277
[ ! -d "${GRID_SUBMIT_WORKDIR}" ] && mkdir -p ${GRID_SUBMIT_WORKDIR}
278278
[ ! "${CONTINUE_WORKDIR}" ] && cp "${MY_JOBSCRIPT}" "${GRID_SUBMIT_WORKDIR}/alien_jobscript.sh"
@@ -443,9 +443,20 @@ EOF
443443
# this is the global job status (a D here means the production is done)
444444
JOBSTATUS=$(alien.py ps -j ${MY_JOBID} | awk '//{print $3}') # this is the global job status
445445
# in addition we may query individual splits
446-
if [ "${WAITFORANY}" ]; then
447-
if ALIENPY_JSON=true alien.py ps -a -m "${MY_JOBID}" | grep "status" | grep -q "DONE"; then
448-
JOBSTATUS="D" # a D here means == some job finished successfully
446+
if [ -n "${WAITFORALIENANY}" ]; then
447+
DETAILED_STATUS_JSON=$(ALIENPY_JSON=true alien.py ps -a -m "${MY_JOBID}")
448+
# check if any is already marked as DONE
449+
if jq -e '.results | any(.status == "DONE")' <<<"${DETAILED_STATUS_JSON}" >/dev/null; then
450+
JOBSTATUS="D"
451+
echo "At least one good job"
452+
else
453+
# check if there are still jobs running/waiting; if not also finish
454+
# this could happen when all jobs are zombies (in which case we also finish)
455+
if ! jq -e '.results | any(.status == "WAITING" or .status == "RUNNING" or .status == "SAVING" or .status == "INSERTING")' \
456+
<<<"${DETAILED_STATUS_JSON}" >/dev/null; then
457+
JOBSTATUS="D" # some job finished successfully
458+
echo "No remaining good job"
459+
fi
449460
fi
450461
fi
451462

0 commit comments

Comments
 (0)