1592 ):
1593 self._originalCmd = self._cmd
1594 self._asetup = asetup
1595 self._dbsetup = dbsetup
1596 self._containerSetup = ossetup
1597 self._workdir = os.getcwd()
1598 self._alreadyInContainer = self._workdir.startswith("/srv")
1599 self._wrapperFile = 'runwrapper.{name}.sh'.format(name = self._name)
1600 self._setupFile = 'setup.{name}.sh'.format(name = self._name)
1601
1602
1603 setupATLAS = 'my_setupATLAS.sh'
1604 with open(setupATLAS, 'w') as f:
1605 print(
"#!/bin/bash", file=f)
1607if [ -z $ATLAS_LOCAL_ROOT_BASE ]; then
1608 export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
1609fi
1610source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"""
1611 , file=f)
1612 os.chmod(setupATLAS, 0o755)
1613
1614 msg.debug(
1615 'Preparing wrapper file {wrapperFileName} with '
1616 'asetup={asetupStatus} and dbsetup={dbsetupStatus}'.format(
1617 wrapperFileName = self._wrapperFile,
1618 asetupStatus = self._asetup,
1619 dbsetupStatus = self._dbsetup
1620 )
1621 )
1622
1623 container_cmd = None
1624 try:
1625 with open(self._wrapperFile, 'w') as wrapper:
1626 print(
'#!/bin/sh', file=wrapper)
1627 if self._containerSetup is not None:
1628 container_cmd = [ os.path.abspath(setupATLAS),
1629 "-c",
1630 self._containerSetup,
1631 "--pwd",
1632 self._workdir,
1633 "-s",
1634 os.path.join('.', self._setupFile),
1635 "-r"]
1636 print(
'echo "This wrapper is executed within a container! For a local re-run, do:"', file=wrapper)
1637 print(
'echo " '+
" ".join([
'setupATLAS'] + container_cmd[1:] + [path.join(
'.', self._wrapperFile)]) +
'"', file=wrapper)
1638 print(
'echo "N.B.: if launching a nested container, navigate to /srv before running the above command"',
1639 file = wrapper)
1640 print(
'echo " and use --pwd workdir, where workdir is the transform running directory within /srv"',
1641 file=wrapper)
1642 print(
'echo', file=wrapper)
1643
1644 if asetup:
1645 wfile = wrapper
1646 asetupFile = None
1647
1648
1649 if self._containerSetup is not None:
1650 asetupFile = open(self._setupFile, 'w')
1651 wfile = asetupFile
1652 print(f
'source ./{setupATLAS} -q', file=wfile)
1653 print(f
'asetup {asetup}', file=wfile)
1654 print(
'if [ ${?} != "0" ]; then exit 255; fi', file=wfile)
1655 if dbsetup:
1656 dbroot = path.dirname(dbsetup)
1657 dbversion = path.basename(dbroot)
1658 print(
"# DBRelease setup", file=wrapper)
1659 print(
'echo Setting up DBRelease {dbroot} environment'.format(dbroot = dbroot), file=wrapper)
1660 print(
'export DBRELEASE={dbversion}'.format(dbversion = dbversion), file=wrapper)
1661 print(
'export CORAL_AUTH_PATH={directory}'.format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1662 print(
'export CORAL_DBLOOKUP_PATH={directory}'.format(directory = path.join(dbroot,
'XMLConfig')), file=wrapper)
1663 print(
'export TNS_ADMIN={directory}'.format(directory = path.join(dbroot,
'oracle-admin')), file=wrapper)
1664 print(
'DATAPATH={dbroot}:$DATAPATH'.format(dbroot = dbroot), file=wrapper)
1665 if self._disableMT:
1666 print(
"# AthenaMT explicitly disabled for this executor", file=wrapper)
1667 if self._disableMP:
1668 print(
"# AthenaMP explicitly disabled for this executor", file=wrapper)
1669 if self._envUpdate.len > 0:
1670 for envSetting in self._envUpdate.values:
1671 if not envSetting.startswith('LD_PRELOAD'):
1672 print(
"export", envSetting, file=wrapper)
1673
1674
1675
1676 if 'valgrind' in self.conf._argdict and self.conf._argdict['valgrind'].value is True:
1677 msg.info('Valgrind engaged')
1678
1679
1680 AthenaSerialisedConfigurationFile = "{name}Conf.pkl".format(
1681 name = self._name
1682 )
1683
1684 print(
' '.join(self._cmd),
"--config-only={0}".format(AthenaSerialisedConfigurationFile), file=wrapper)
1685 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1686
1687
1688 if 'valgrindDefaultOpts' in self.conf._argdict:
1689 defaultOptions = self.conf._argdict['valgrindDefaultOpts'].value
1690 else:
1691 defaultOptions = True
1692 if 'valgrindExtraOpts' in self.conf._argdict:
1693 extraOptionsList = self.conf._argdict['valgrindExtraOpts'].value
1694 else:
1695 extraOptionsList = None
1696 msg.debug("requested Valgrind command basic options: {options}".format(options = defaultOptions))
1697 msg.debug("requested Valgrind command extra options: {options}".format(options = extraOptionsList))
1698 command = ValgrindCommand(
1699 defaultOptions = defaultOptions,
1700 extraOptionsList = extraOptionsList,
1701 AthenaSerialisedConfigurationFile = \
1702 AthenaSerialisedConfigurationFile
1703 )
1704 msg.debug("Valgrind command: {command}".format(command = command))
1705 print(command, file=wrapper)
1706
1707
1708
1709 elif 'vtune' in self.conf._argdict and self.conf._argdict['vtune'].value is True:
1710 msg.info('VTune engaged')
1711
1712
1713 AthenaSerialisedConfigurationFile = "{name}Conf.pkl".format(
1714 name = self._name
1715 )
1716
1717 print(
' '.join(self._cmd),
"--config-only={0}".format(AthenaSerialisedConfigurationFile), file=wrapper)
1718 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1719
1720
1721 if 'vtuneDefaultOpts' in self.conf._argdict:
1722 defaultOptions = self.conf._argdict['vtuneDefaultOpts'].value
1723 else:
1724 defaultOptions = True
1725 if 'vtuneExtraOpts' in self.conf._argdict:
1726 extraOptionsList = self.conf._argdict['vtuneExtraOpts'].value
1727 else:
1728 extraOptionsList = None
1729
1730
1731 if (self._skeleton or self._skeletonCA) and len(self._topOptionsFiles) > 0:
1732 AthenaCommand = self._cmd[:-len(self._topOptionsFiles)]
1733 else:
1734 AthenaCommand = self._cmd
1735 AthenaCommand.append(AthenaSerialisedConfigurationFile)
1736
1737 msg.debug("requested VTune command basic options: {options}".format(options = defaultOptions))
1738 msg.debug("requested VTune command extra options: {options}".format(options = extraOptionsList))
1739 command = VTuneCommand(
1740 defaultOptions = defaultOptions,
1741 extraOptionsList = extraOptionsList,
1742 AthenaCommand = AthenaCommand
1743 )
1744 msg.debug("VTune command: {command}".format(command = command))
1745 print(command, file=wrapper)
1746 else:
1747 msg.info('Valgrind/VTune not engaged')
1748
1749 print(
' '.join(self._cmd), file=wrapper)
1750 os.chmod(self._wrapperFile, 0o755)
1751 except OSError as e:
1752 errMsg = 'error writing athena wrapper {fileName}: {error}'.format(
1753 fileName = self._wrapperFile,
1754 error = e
1755 )
1756 msg.error(errMsg)
1757 raise trfExceptions.TransformExecutionException(
1758 trfExit.nameToCode('TRF_EXEC_SETUP_WRAPPER'),
1759 errMsg
1760 )
1761 self._cmd = [ path.join('.', self._wrapperFile) ]
1762 if self._containerSetup is not None:
1763 asetupFile.close()
1764 self._cmd = container_cmd + self._cmd
1765
1766
void print(char *figname, TCanvas *c1)