1562 def _writeAthenaWrapper(
1568 self._originalCmd = self._cmd
1569 self._asetup = asetup
1570 self._dbsetup = dbsetup
1571 self._containerSetup = ossetup
1572 self._workdir = os.getcwd()
1573 self._alreadyInContainer = self._workdir.startswith(
"/srv")
1574 self._wrapperFile =
'runwrapper.{name}.sh'.
format(name = self._name)
1575 self._setupFile =
'setup.{name}.sh'.
format(name = self._name)
1578 setupATLAS =
'my_setupATLAS.sh'
1579 with open(setupATLAS,
'w')
as f:
1580 print(
"#!/bin/bash", file=f)
1582 if [ -z $ATLAS_LOCAL_ROOT_BASE ]; then
1583 export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
1585 source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"""
1587 os.chmod(setupATLAS, 0o755)
1590 'Preparing wrapper file {wrapperFileName} with '
1591 'asetup={asetupStatus} and dbsetup={dbsetupStatus}'.
format(
1592 wrapperFileName = self._wrapperFile,
1593 asetupStatus = self._asetup,
1594 dbsetupStatus = self._dbsetup
1598 container_cmd =
None
1600 with open(self._wrapperFile,
'w')
as wrapper:
1601 print(
'#!/bin/sh', file=wrapper)
1602 if self._containerSetup
is not None:
1603 container_cmd = [ os.path.abspath(setupATLAS),
1605 self._containerSetup,
1609 os.path.join(
'.', self._setupFile),
1611 print(
'echo "This wrapper is executed within a container! For a local re-run, do:"', file=wrapper)
1612 print(
'echo " '+
" ".
join([
'setupATLAS'] + container_cmd[1:] + [path.join(
'.', self._wrapperFile)]) +
'"', file=wrapper)
1613 print(
'echo "N.B.: if launching a nested container, navigate to /srv before running the above command"',
1615 print(
'echo " and use --pwd workdir, where workdir is the transform running directory within /srv"',
1617 print(
'echo', file=wrapper)
1624 if self._containerSetup
is not None:
1625 asetupFile =
open(self._setupFile,
'w')
1627 print(f
'source ./{setupATLAS} -q', file=wfile)
1628 print(f
'asetup {asetup}', file=wfile)
1629 print(
'if [ ${?} != "0" ]; then exit 255; fi', file=wfile)
1631 dbroot = path.dirname(dbsetup)
1632 dbversion = path.basename(dbroot)
1633 print(
"# DBRelease setup", file=wrapper)
1634 print(
'echo Setting up DBRelease {dbroot} environment'.
format(dbroot = dbroot), file=wrapper)
1635 print(
'export DBRELEASE={dbversion}'.
format(dbversion = dbversion), file=wrapper)
1636 print(
'export CORAL_AUTH_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1637 print(
'export CORAL_DBLOOKUP_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1638 print(
'export TNS_ADMIN={directory}'.
format(directory = path.join(dbroot,
'oracle-admin')), file=wrapper)
1639 print(
'DATAPATH={dbroot}:$DATAPATH'.
format(dbroot = dbroot), file=wrapper)
1641 print(
"# AthenaMT explicitly disabled for this executor", file=wrapper)
1643 print(
"# AthenaMP explicitly disabled for this executor", file=wrapper)
1644 if self._envUpdate.len > 0:
1645 for envSetting
in self._envUpdate.values:
1646 if not envSetting.startswith(
'LD_PRELOAD'):
1647 print(
"export", envSetting, file=wrapper)
1651 if 'valgrind' in self.conf._argdict
and self.conf._argdict[
'valgrind'].value
is True:
1652 msg.info(
'Valgrind engaged')
1655 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1659 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1660 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1663 if 'valgrindDefaultOpts' in self.conf._argdict:
1664 defaultOptions = self.conf._argdict[
'valgrindDefaultOpts'].value
1666 defaultOptions =
True
1667 if 'valgrindExtraOpts' in self.conf._argdict:
1668 extraOptionsList = self.conf._argdict[
'valgrindExtraOpts'].value
1670 extraOptionsList =
None
1671 msg.debug(
"requested Valgrind command basic options: {options}".
format(options = defaultOptions))
1672 msg.debug(
"requested Valgrind command extra options: {options}".
format(options = extraOptionsList))
1674 defaultOptions = defaultOptions,
1675 extraOptionsList = extraOptionsList,
1676 AthenaSerialisedConfigurationFile = \
1677 AthenaSerialisedConfigurationFile
1679 msg.debug(
"Valgrind command: {command}".
format(command = command))
1680 print(command, file=wrapper)
1684 elif 'vtune' in self.conf._argdict
and self.conf._argdict[
'vtune'].value
is True:
1685 msg.info(
'VTune engaged')
1688 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1692 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1693 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1696 if 'vtuneDefaultOpts' in self.conf._argdict:
1697 defaultOptions = self.conf._argdict[
'vtuneDefaultOpts'].value
1699 defaultOptions =
True
1700 if 'vtuneExtraOpts' in self.conf._argdict:
1701 extraOptionsList = self.conf._argdict[
'vtuneExtraOpts'].value
1703 extraOptionsList =
None
1704 msg.debug(
"requested VTune command basic options: {options}".
format(options = defaultOptions))
1705 msg.debug(
"requested VTune command extra options: {options}".
format(options = extraOptionsList))
1707 defaultOptions = defaultOptions,
1708 extraOptionsList = extraOptionsList,
1709 AthenaSerialisedConfigurationFile = \
1710 AthenaSerialisedConfigurationFile
1712 msg.debug(
"VTune command: {command}".
format(command = command))
1713 print(command, file=wrapper)
1715 msg.info(
'Valgrind/VTune not engaged')
1717 print(
' '.
join(self._cmd), file=wrapper)
1718 os.chmod(self._wrapperFile, 0o755)
1719 except OSError
as e:
1720 errMsg =
'error writing athena wrapper {fileName}: {error}'.
format(
1721 fileName = self._wrapperFile,
1725 raise trfExceptions.TransformExecutionException(
1726 trfExit.nameToCode(
'TRF_EXEC_SETUP_WRAPPER'),
1729 self._cmd = [ path.join(
'.', self._wrapperFile) ]
1730 if self._containerSetup
is not None:
1732 self._cmd = container_cmd + self._cmd