1544 def _writeAthenaWrapper(
1550 self._originalCmd = self._cmd
1551 self._asetup = asetup
1552 self._dbsetup = dbsetup
1553 self._containerSetup = ossetup
1554 self._workdir = os.getcwd()
1555 self._alreadyInContainer = self._workdir.startswith(
"/srv")
1556 self._wrapperFile =
'runwrapper.{name}.sh'.
format(name = self._name)
1557 self._setupFile =
'setup.{name}.sh'.
format(name = self._name)
1560 setupATLAS =
'my_setupATLAS.sh'
1561 with open(setupATLAS,
'w')
as f:
1562 print(
"#!/bin/bash", file=f)
1564 if [ -z $ATLAS_LOCAL_ROOT_BASE ]; then
1565 export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
1567 source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"""
1569 os.chmod(setupATLAS, 0o755)
1572 'Preparing wrapper file {wrapperFileName} with '
1573 'asetup={asetupStatus} and dbsetup={dbsetupStatus}'.
format(
1574 wrapperFileName = self._wrapperFile,
1575 asetupStatus = self._asetup,
1576 dbsetupStatus = self._dbsetup
1580 container_cmd =
None
1582 with open(self._wrapperFile,
'w')
as wrapper:
1583 print(
'#!/bin/sh', file=wrapper)
1584 if self._containerSetup
is not None:
1585 container_cmd = [ os.path.abspath(setupATLAS),
1587 self._containerSetup,
1591 os.path.join(
'.', self._setupFile),
1593 print(
'echo "This wrapper is executed within a container! For a local re-run, do:"', file=wrapper)
1594 print(
'echo " '+
" ".
join([
'setupATLAS'] + container_cmd[1:] + [path.join(
'.', self._wrapperFile)]) +
'"', file=wrapper)
1595 print(
'echo "N.B.: if launching a nested container, navigate to /srv before running the above command"',
1597 print(
'echo " and use --pwd workdir, where workdir is the transform running directory within /srv"',
1599 print(
'echo', file=wrapper)
1606 if self._containerSetup
is not None:
1607 asetupFile =
open(self._setupFile,
'w')
1609 print(f
'source ./{setupATLAS} -q', file=wfile)
1610 print(f
'asetup {asetup}', file=wfile)
1611 print(
'if [ ${?} != "0" ]; then exit 255; fi', file=wfile)
1613 dbroot = path.dirname(dbsetup)
1614 dbversion = path.basename(dbroot)
1615 print(
"# DBRelease setup", file=wrapper)
1616 print(
'echo Setting up DBRelease {dbroot} environment'.
format(dbroot = dbroot), file=wrapper)
1617 print(
'export DBRELEASE={dbversion}'.
format(dbversion = dbversion), file=wrapper)
1618 print(
'export CORAL_AUTH_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1619 print(
'export CORAL_DBLOOKUP_PATH={directory}'.
format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1620 print(
'export TNS_ADMIN={directory}'.
format(directory = path.join(dbroot,
'oracle-admin')), file=wrapper)
1621 print(
'DATAPATH={dbroot}:$DATAPATH'.
format(dbroot = dbroot), file=wrapper)
1623 print(
"# AthenaMT explicitly disabled for this executor", file=wrapper)
1625 print(
"# AthenaMP explicitly disabled for this executor", file=wrapper)
1626 if self._envUpdate.len > 0:
1627 for envSetting
in self._envUpdate.values:
1628 if not envSetting.startswith(
'LD_PRELOAD'):
1629 print(
"export", envSetting, file=wrapper)
1633 if 'valgrind' in self.conf._argdict
and self.conf._argdict[
'valgrind'].value
is True:
1634 msg.info(
'Valgrind engaged')
1637 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1641 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1642 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1645 if 'valgrindDefaultOpts' in self.conf._argdict:
1646 defaultOptions = self.conf._argdict[
'valgrindDefaultOpts'].value
1648 defaultOptions =
True
1649 if 'valgrindExtraOpts' in self.conf._argdict:
1650 extraOptionsList = self.conf._argdict[
'valgrindExtraOpts'].value
1652 extraOptionsList =
None
1653 msg.debug(
"requested Valgrind command basic options: {options}".
format(options = defaultOptions))
1654 msg.debug(
"requested Valgrind command extra options: {options}".
format(options = extraOptionsList))
1656 defaultOptions = defaultOptions,
1657 extraOptionsList = extraOptionsList,
1658 AthenaSerialisedConfigurationFile = \
1659 AthenaSerialisedConfigurationFile
1661 msg.debug(
"Valgrind command: {command}".
format(command = command))
1662 print(command, file=wrapper)
1666 elif 'vtune' in self.conf._argdict
and self.conf._argdict[
'vtune'].value
is True:
1667 msg.info(
'VTune engaged')
1670 AthenaSerialisedConfigurationFile =
"{name}Conf.pkl".
format(
1674 print(
' '.
join(self._cmd),
"--config-only={0}".
format(AthenaSerialisedConfigurationFile), file=wrapper)
1675 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1678 if 'vtuneDefaultOpts' in self.conf._argdict:
1679 defaultOptions = self.conf._argdict[
'vtuneDefaultOpts'].value
1681 defaultOptions =
True
1682 if 'vtuneExtraOpts' in self.conf._argdict:
1683 extraOptionsList = self.conf._argdict[
'vtuneExtraOpts'].value
1685 extraOptionsList =
None
1686 msg.debug(
"requested VTune command basic options: {options}".
format(options = defaultOptions))
1687 msg.debug(
"requested VTune command extra options: {options}".
format(options = extraOptionsList))
1689 defaultOptions = defaultOptions,
1690 extraOptionsList = extraOptionsList,
1691 AthenaSerialisedConfigurationFile = \
1692 AthenaSerialisedConfigurationFile
1694 msg.debug(
"VTune command: {command}".
format(command = command))
1695 print(command, file=wrapper)
1697 msg.info(
'Valgrind/VTune not engaged')
1699 print(
' '.
join(self._cmd), file=wrapper)
1700 os.chmod(self._wrapperFile, 0o755)
1701 except OSError
as e:
1702 errMsg =
'error writing athena wrapper {fileName}: {error}'.
format(
1703 fileName = self._wrapperFile,
1707 raise trfExceptions.TransformExecutionException(
1708 trfExit.nameToCode(
'TRF_EXEC_SETUP_WRAPPER'),
1711 self._cmd = [ path.join(
'.', self._wrapperFile) ]
1712 if self._containerSetup
is not None:
1714 self._cmd = container_cmd + self._cmd