1566 def _writeAthenaWrapper(
1572 self._originalCmd = self._cmd
1573 self._asetup = asetup
1574 self._dbsetup = dbsetup
1575 self._containerSetup = ossetup
1576 self._workdir = os.getcwd()
1577 self._alreadyInContainer = self._workdir.startswith(
"/srv")
1578 self._wrapperFile =
'runwrapper.{name}.sh'.
format(name = self._name)
1579 self._setupFile =
'setup.{name}.sh'.
format(name = self._name)
1582 setupATLAS =
'my_setupATLAS.sh'
1583 with open(setupATLAS,
'w')
as f:
1584 print(
"#!/bin/bash", file=f)
1586 if [ -z $ATLAS_LOCAL_ROOT_BASE ]; then
1587 export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
1589 source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"""
1591 os.chmod(setupATLAS, 0o755)
1594 'Preparing wrapper file {wrapperFileName} with '
1595 'asetup={asetupStatus} and dbsetup={dbsetupStatus}'.
format(
1596 wrapperFileName = self._wrapperFile,
1597 asetupStatus = self._asetup,
1598 dbsetupStatus = self._dbsetup
1602 container_cmd =
None
1604 with open(self._wrapperFile,
'w')
as wrapper:
1605 print(
'#!/bin/sh', file=wrapper)
1606 if self._containerSetup
is not None:
1607 container_cmd = [ os.path.abspath(setupATLAS),
1609 self._containerSetup,
1613 os.path.join(
'.', self._setupFile),
1615 print(
'echo "This wrapper is executed within a container! For a local re-run, do:"', file=wrapper)
1616 print(
'echo " '+
" ".
join([
'setupATLAS'] + container_cmd[1:] + [path.join(
'.', self._wrapperFile)]) +
'"', file=wrapper)
1617 print(
'echo "N.B.: if launching a nested container, navigate to /srv before running the above command"',
1619 print(
'echo " and use --pwd workdir, where workdir is the transform running directory within /srv"',
1621 print(
'echo', file=wrapper)
1628 if self._containerSetup
is not None:
1629 asetupFile =
open(self._setupFile,
'w')
1631 print(f
'source ./{setupATLAS} -q', file=wfile)
1632 print(f
'asetup {asetup}', file=wfile)
1633 print(
'if [ ${?} != "0" ]; then exit 255; fi', file=wfile)
1635 dbroot = path.dirname(dbsetup)
1636 dbversion = path.basename(dbroot)
1637 print(
"# DBRelease setup", file=wrapper)
1638 print(
'echo Setting up DBRelease {dbroot} environment'.
format(dbroot = dbroot), file=wrapper)
1639 print(
'export DBRELEASE={dbversion}'.
format(dbversion = dbversion), file=wrapper)
1640 print(
'export CORAL_AUTH_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1641 print(
'export CORAL_DBLOOKUP_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1642 print(
'export TNS_ADMIN={directory}'.
format(directory = path.join(dbroot,
'oracle-admin')), file=wrapper)
1643 print(
'DATAPATH={dbroot}:$DATAPATH'.
format(dbroot = dbroot), file=wrapper)
1645 print(
"# AthenaMT explicitly disabled for this executor", file=wrapper)
1647 print(
"# AthenaMP explicitly disabled for this executor", file=wrapper)
1648 if self._envUpdate.len > 0:
1649 for envSetting
in self._envUpdate.values:
1650 if not envSetting.startswith(
'LD_PRELOAD'):
1651 print(
"export", envSetting, file=wrapper)
1655 if 'valgrind' in self.conf._argdict
and self.conf._argdict[
'valgrind'].value
is True:
1656 msg.info(
'Valgrind engaged')
1659 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1663 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1664 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1667 if 'valgrindDefaultOpts' in self.conf._argdict:
1668 defaultOptions = self.conf._argdict[
'valgrindDefaultOpts'].value
1670 defaultOptions =
True
1671 if 'valgrindExtraOpts' in self.conf._argdict:
1672 extraOptionsList = self.conf._argdict[
'valgrindExtraOpts'].value
1674 extraOptionsList =
None
1675 msg.debug(
"requested Valgrind command basic options: {options}".
format(options = defaultOptions))
1676 msg.debug(
"requested Valgrind command extra options: {options}".
format(options = extraOptionsList))
1678 defaultOptions = defaultOptions,
1679 extraOptionsList = extraOptionsList,
1680 AthenaSerialisedConfigurationFile = \
1681 AthenaSerialisedConfigurationFile
1683 msg.debug(
"Valgrind command: {command}".
format(command = command))
1684 print(command, file=wrapper)
1688 elif 'vtune' in self.conf._argdict
and self.conf._argdict[
'vtune'].value
is True:
1689 msg.info(
'VTune engaged')
1692 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1696 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1697 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1700 if 'vtuneDefaultOpts' in self.conf._argdict:
1701 defaultOptions = self.conf._argdict[
'vtuneDefaultOpts'].value
1703 defaultOptions =
True
1704 if 'vtuneExtraOpts' in self.conf._argdict:
1705 extraOptionsList = self.conf._argdict[
'vtuneExtraOpts'].value
1707 extraOptionsList =
None
1710 if (self._skeleton
or self._skeletonCA)
and len(self._topOptionsFiles) > 0:
1711 AthenaCommand = self._cmd[:-len(self._topOptionsFiles)]
1713 AthenaCommand = self._cmd
1714 AthenaCommand.append(AthenaSerialisedConfigurationFile)
1716 msg.debug(
"requested VTune command basic options: {options}".
format(options = defaultOptions))
1717 msg.debug(
"requested VTune command extra options: {options}".
format(options = extraOptionsList))
1719 defaultOptions = defaultOptions,
1720 extraOptionsList = extraOptionsList,
1721 AthenaCommand = AthenaCommand
1723 msg.debug(
"VTune command: {command}".
format(command = command))
1724 print(command, file=wrapper)
1726 msg.info(
'Valgrind/VTune not engaged')
1728 print(
' '.
join(self._cmd), file=wrapper)
1729 os.chmod(self._wrapperFile, 0o755)
1730 except OSError
as e:
1731 errMsg =
'error writing athena wrapper {fileName}: {error}'.
format(
1732 fileName = self._wrapperFile,
1736 raise trfExceptions.TransformExecutionException(
1737 trfExit.nameToCode(
'TRF_EXEC_SETUP_WRAPPER'),
1740 self._cmd = [ path.join(
'.', self._wrapperFile) ]
1741 if self._containerSetup
is not None:
1743 self._cmd = container_cmd + self._cmd