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