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