|
180 | 180 |
|
181 | 181 | export > env_base.env |
182 | 182 |
|
183 | | -# The 2-tag / alternative-reco setup below uses 'module save/purge/restore' to stash |
184 | | -# and swap the software environment. If the shell provides no 'module' function, build |
| 183 | +# The 2-tag / alternative-reco setup below uses 'module purge' to swap the software |
| 184 | +# environment inside a subshell. If the shell provides no 'module' function, build |
185 | 185 | # one on a 'modulecmd' binary. Its location varies by version, so resolve it flexibly |
186 | 186 | # (was hardwired to /usr/bin/modulecmd) and verify it supports saved collections. Fail |
187 | 187 | # hard -- but only when an alternative-reco tag is set, since single-tag jobs never call |
@@ -237,61 +237,61 @@ if [ ! "${MODULEPATH}" ]; then |
237 | 237 | fi |
238 | 238 |
|
239 | 239 | #<----- START OF part that should run under a clean alternative software environment if this was given ------ |
240 | | -if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then |
241 | | - if [ "${LOADEDMODULES}" ]; then |
242 | | - printenv > env_before_stashing.printenv |
243 | | - echo "Stashing initial modules" |
244 | | - module save initial_modules.list # we stash the current modules environment |
245 | | - module list --no-pager |
246 | | - module purge --no-pager |
247 | | - printenv > env_after_stashing.printenv |
248 | | - echo "Modules after purge" |
249 | | - module list --no-pager |
| 240 | +# It runs in a subshell, so the MC software environment of this shell stays untouched |
| 241 | +# and does not need to be restored afterwards. |
| 242 | +( |
| 243 | + if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then |
| 244 | + if [ "${LOADEDMODULES}" ]; then |
| 245 | + echo "Unloading initial modules" |
| 246 | + module purge --no-pager |
| 247 | + fi |
| 248 | + echo_info "Using tag ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG} to setup anchored MC" |
| 249 | + /cvmfs/alice.cern.ch/bin/alienv printenv "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" &> async_environment.env |
| 250 | + source async_environment.env |
| 251 | + export > env_async.env |
250 | 252 | fi |
251 | | - echo_info "Using tag ${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG} to setup anchored MC" |
252 | | - /cvmfs/alice.cern.ch/bin/alienv printenv "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" &> async_environment.env |
253 | | - source async_environment.env |
254 | | - export > env_async.env |
255 | | -fi |
256 | 253 |
|
257 | | -# default async_pass.sh script |
258 | | -DPGRECO=$O2DPG_ROOT/DATA/production/configurations/asyncReco/async_pass.sh |
259 | | -# default destenv_extra.sh script |
260 | | -DPGSETENV=$O2DPG_ROOT/DATA/production/configurations/asyncReco/setenv_extra.sh |
| 254 | + # default async_pass.sh script |
| 255 | + DPGRECO=$O2DPG_ROOT/DATA/production/configurations/asyncReco/async_pass.sh |
| 256 | + # default destenv_extra.sh script |
| 257 | + DPGSETENV=$O2DPG_ROOT/DATA/production/configurations/asyncReco/setenv_extra.sh |
261 | 258 |
|
262 | | -# a specific async_pass.sh script is in the current directory, assume that one should be used |
263 | | -if [[ -f async_pass.sh ]]; then |
264 | | - # the default is executable, however, this may not be, so make it so |
265 | | - chmod +x async_pass.sh |
266 | | - DPGRECO=./async_pass.sh |
267 | | -else |
268 | | - cp -v $DPGRECO . |
269 | | -fi |
| 259 | + # a specific async_pass.sh script is in the current directory, assume that one should be used |
| 260 | + if [[ -f async_pass.sh ]]; then |
| 261 | + # the default is executable, however, this may not be, so make it so |
| 262 | + chmod +x async_pass.sh |
| 263 | + DPGRECO=./async_pass.sh |
| 264 | + else |
| 265 | + cp -v $DPGRECO . |
| 266 | + fi |
270 | 267 |
|
271 | | -# if there is no setenv_extra.sh in this directory (so no special version is "shipped" with this rpodcution), copy the default one |
272 | | -if [[ ! -f setenv_extra.sh ]] ; then |
273 | | - cp ${DPGSETENV} . |
274 | | - echo_info "Use default setenv_extra.sh from ${DPGSETENV}." |
275 | | -else |
276 | | - echo_info "setenv_extra.sh was found in the current working directory, use it." |
277 | | -fi |
| 268 | + # if there is no setenv_extra.sh in this directory (so no special version is "shipped" with this rpodcution), copy the default one |
| 269 | + if [[ ! -f setenv_extra.sh ]] ; then |
| 270 | + cp ${DPGSETENV} . |
| 271 | + echo_info "Use default setenv_extra.sh from ${DPGSETENV}." |
| 272 | + else |
| 273 | + echo_info "setenv_extra.sh was found in the current working directory, use it." |
| 274 | + fi |
278 | 275 |
|
279 | | -chmod u+x setenv_extra.sh |
| 276 | + chmod u+x setenv_extra.sh |
280 | 277 |
|
281 | | -echo_info "Setting up DPGRECO to ${DPGRECO}" |
| 278 | + echo_info "Setting up DPGRECO to ${DPGRECO}" |
282 | 279 |
|
283 | | -# take out line running the workflow (if we don't have data input) |
284 | | -[ ${CTF_TEST_FILE} ] || sed -i '/WORKFLOWMODE=run/d' async_pass.sh |
| 280 | + # take out line running the workflow (if we don't have data input) |
| 281 | + [ ${CTF_TEST_FILE} ] || sed -i '/WORKFLOWMODE=run/d' async_pass.sh |
285 | 282 |
|
286 | | -# create workflow ---> creates the file that can be parsed |
287 | | -export IGNORE_EXISTING_SHMFILES=1 |
288 | | -touch list.list |
| 283 | + # create workflow ---> creates the file that can be parsed |
| 284 | + export IGNORE_EXISTING_SHMFILES=1 |
| 285 | + touch list.list |
289 | 286 |
|
290 | | -# run the async_pass.sh and store output to log file for later inspection and extraction of information |
291 | | -./async_pass.sh ${CTF_TEST_FILE:-""} 2&> async_pass_log.log |
292 | | -RECO_RC=$? |
| 287 | + # run the async_pass.sh and store output to log file for later inspection and extraction of information |
| 288 | + ./async_pass.sh ${CTF_TEST_FILE:-""} 2&> async_pass_log.log |
| 289 | + RECO_RC=$? |
293 | 290 |
|
294 | | -echo_info "async_pass.sh finished with ${RECO_RC}" |
| 291 | + echo_info "async_pass.sh finished with ${RECO_RC}" |
| 292 | + exit ${RECO_RC} |
| 293 | +) |
| 294 | +RECO_RC=$? |
295 | 295 |
|
296 | 296 | if [[ "${RECO_RC}" != "0" ]] ; then |
297 | 297 | exit ${RECO_RC} |
|
305 | 305 |
|
306 | 306 | export ALIEN_JDL_LPMPRODUCTIONTAG=$ALIEN_JDL_LPMPRODUCTIONTAG_KEEP |
307 | 307 | echo_info "Setting back ALIEN_JDL_LPMPRODUCTIONTAG to $ALIEN_JDL_LPMPRODUCTIONTAG" |
308 | | - |
309 | | -# get rid of the temporary software environment |
310 | | -if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then |
311 | | - module purge --no-pager |
312 | | - # restore the initial software environment |
313 | | - echo "Restoring initial environment" |
314 | | - module --no-pager restore initial_modules.list |
315 | | - module saverm initial_modules.list |
316 | | - |
317 | | - # Restore overwritten O2DPG variables set by modules but changed by user |
318 | | - # (in particular custom O2DPG_ROOT and O2DPG_MC_CONFIG_ROOT) |
319 | | - # We must avoid piping into a while loop (otherwise the internal export is executed in sub-shell) |
320 | | - printenv > env_after_restore.printenv |
321 | | - while read -r var; do |
322 | | - b=$(grep "^$var=" env_before_stashing.printenv | cut -d= -f2-) |
323 | | - a=$(grep "^$var=" env_after_restore.printenv | cut -d= -f2-) |
324 | | - [[ "$b" != "$a" ]] && export "$var=$b" && echo "Reapplied: $var to ${b}" |
325 | | - done < <( |
326 | | - comm -12 \ |
327 | | - <(grep '^O2DPG' env_before_stashing.printenv | cut -d= -f1 | sort) \ |
328 | | - <(grep '^O2DPG' env_after_restore.printenv | cut -d= -f1 | sort)) |
329 | | - |
330 | | -fi |
331 | 308 | #<----- END OF part that should run under a clean alternative software environment if this was given ------ |
332 | 309 |
|
333 | 310 | # now create the local MC config file --> config-json.json |
|
0 commit comments