Skip to content

Commit 791ee96

Browse files
committed
grid-submit: Possibility for singularity containerization
1 parent 0129de1 commit 791ee96

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

GRID/utils/grid_submit.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export JOBUTILS_JOB_ENDHOOK=checkpoint_hook_ttlbased
175175
ONGRID=0
176176
[ "${JALIEN_TOKEN_CERT}" ] && ONGRID=1
177177

178-
179178
JOBTTL=82000
180179
CPUCORES=8
181180
# this tells us to continue an existing job --> in this case we don't create a new workdir
@@ -196,6 +195,7 @@ while [ $# -gt 0 ] ; do
196195
--mattermost) MATTERMOSTHOOK=$2; shift 2 ;; # if given, status and metric information about the job will be sent to this hook
197196
--controlserver) CONTROLSERVER=$2; shift 2 ;; # allows to give a SERVER ADDRESS/IP which can act as controller for GRID jobs
198197
--prodsplit) PRODSPLIT=$2; shift 2 ;; # allows to set JDL production split level (useful to easily replicate workflows)
198+
--singularity) SINGULARITY=ON; shift 1 ;; # run everything inside singularity
199199
-h) Usage ; exit ;;
200200
*) break ;;
201201
esac
@@ -275,7 +275,8 @@ Executable = "${MY_BINDIR}/${MY_JOBNAMEDATE}.sh";
275275
Arguments = "${CONTINUE_WORKDIR:+"-c ${CONTINUE_WORKDIR}"} --local ${O2TAG:+--o2tag ${O2TAG}} --ttl ${JOBTTL} --label ${JOBLABEL:-label} ${MATTERMOSTHOOK:+--mattermost ${MATTERMOSTHOOK}} ${CONTROLSERVER:+--controlserver ${CONTROLSERVER}}";
276276
InputFile = "LF:${MY_JOBWORKDIR}/alien_jobscript.sh";
277277
Output = {
278-
"logs*.zip@disk=2"
278+
"logs*.zip@disk=2",
279+
"AO2D.root@disk=1"
279280
};
280281
${PRODSPLIT:+Split = ${QUOT}production:1-${PRODSPLIT}${QUOT};}
281282
OutputDir = "${MY_JOBWORKDIR}/${PRODSPLIT:+#alien_counter_03i#}";
@@ -324,22 +325,35 @@ EOF
324325
fi
325326

326327
exit 0
327-
fi
328+
fi # <---- end if ALIEN_JOB_SUBMITTER
328329

329330
####################################################################################################
330331
# The following part is executed on the worker node or locally
331332
####################################################################################################
333+
if [[ ${SINGULARITY} ]]; then
334+
# if singularity was asked we restart this script within a container
335+
# it's actually much like the GRID mode --> which is why we set JALIEN_TOKEN_CERT
336+
set -x
337+
cp $0 ${WORKDIR}
338+
singularity exec -C -B /cvmfs:/cvmfs,${WORKDIR}:/workdir --env JALIEN_TOKEN_CERT="foo" --pwd /workdir /cvmfs/alice.cern.ch/containers/fs/singularity/centos7 $0 \
339+
${CONTINUE_WORKDIR:+"-c ${CONTINUE_WORKDIR}"} --local ${O2TAG:+--o2tag ${O2TAG}} --ttl ${JOBTTL} --label ${JOBLABEL:-label} ${MATTERMOSTHOOK:+--mattermost ${MATTERMOSTHOOK}} ${CONTROLSERVER:+--controlserver ${CONTROLSERVER}}
340+
set +x
341+
exit $?
342+
fi
343+
332344
if [[ "${ONGRID}" == 0 ]]; then
333345
banner "Executing job in directory ${WORKDIR}"
334346
cd "${WORKDIR}" 2> /dev/null
335347
fi
336348

337-
# All is redirected to log.txt but kept on stdout as well
338-
#if [[ $ALIEN_PROC_ID ]]; then
339-
exec &> >(tee -a alien_log_${ALIEN_PROC_ID:-0}.txt)
340-
#fi
349+
exec &> >(tee -a alien_log_${ALIEN_PROC_ID:-0}.txt)
341350

342351
# ----------- START JOB PREAMBLE -----------------------------
352+
env | grep "SINGULARITY" &> /dev/null
353+
if [ "$?" = "0" ]; then
354+
echo "Singularity containerized execution detected"
355+
fi
356+
343357
banner "Environment"
344358
env
345359

0 commit comments

Comments
 (0)