1571 ):
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)
1580
1581
1582 setupATLAS = 'my_setupATLAS.sh'
1583 with open(setupATLAS, 'w') as f:
1584 print(
"#!/bin/bash", file=f)
1586if [ -z $ATLAS_LOCAL_ROOT_BASE ]; then
1587 export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
1588fi
1589source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"""
1590 , file=f)
1591 os.chmod(setupATLAS, 0o755)
1592
1593 msg.debug(
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
1599 )
1600 )
1601
1602 container_cmd = None
1603 try:
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),
1608 "-c",
1609 self._containerSetup,
1610 "--pwd",
1611 self._workdir,
1612 "-s",
1613 os.path.join('.', self._setupFile),
1614 "-r"]
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"',
1618 file = wrapper)
1619 print(
'echo " and use --pwd workdir, where workdir is the transform running directory within /srv"',
1620 file=wrapper)
1621 print(
'echo', file=wrapper)
1622
1623 if asetup:
1624 wfile = wrapper
1625 asetupFile = None
1626
1627
1628 if self._containerSetup is not None:
1629 asetupFile = open(self._setupFile, 'w')
1630 wfile = asetupFile
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)
1634 if dbsetup:
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)
1644 if self._disableMT:
1645 print(
"# AthenaMT explicitly disabled for this executor", file=wrapper)
1646 if self._disableMP:
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)
1652
1653
1654
1655 if 'valgrind' in self.conf._argdict and self.conf._argdict['valgrind'].value is True:
1656 msg.info('Valgrind engaged')
1657
1658
1659 AthenaSerialisedConfigurationFile = "{name}Conf.pkl".format(
1660 name = self._name
1661 )
1662
1663 print(
' '.join(self._cmd),
"--config-only={0}".format(AthenaSerialisedConfigurationFile), file=wrapper)
1664 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1665
1666
1667 if 'valgrindDefaultOpts' in self.conf._argdict:
1668 defaultOptions = self.conf._argdict['valgrindDefaultOpts'].value
1669 else:
1670 defaultOptions = True
1671 if 'valgrindExtraOpts' in self.conf._argdict:
1672 extraOptionsList = self.conf._argdict['valgrindExtraOpts'].value
1673 else:
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))
1677 command = ValgrindCommand(
1678 defaultOptions = defaultOptions,
1679 extraOptionsList = extraOptionsList,
1680 AthenaSerialisedConfigurationFile = \
1681 AthenaSerialisedConfigurationFile
1682 )
1683 msg.debug("Valgrind command: {command}".format(command = command))
1684 print(command, file=wrapper)
1685
1686
1687
1688 elif 'vtune' in self.conf._argdict and self.conf._argdict['vtune'].value is True:
1689 msg.info('VTune engaged')
1690
1691
1692 AthenaSerialisedConfigurationFile = "{name}Conf.pkl".format(
1693 name = self._name
1694 )
1695
1696 print(
' '.join(self._cmd),
"--config-only={0}".format(AthenaSerialisedConfigurationFile), file=wrapper)
1697 print(
'if [ $? != "0" ]; then exit 255; fi', file=wrapper)
1698
1699
1700 if 'vtuneDefaultOpts' in self.conf._argdict:
1701 defaultOptions = self.conf._argdict['vtuneDefaultOpts'].value
1702 else:
1703 defaultOptions = True
1704 if 'vtuneExtraOpts' in self.conf._argdict:
1705 extraOptionsList = self.conf._argdict['vtuneExtraOpts'].value
1706 else:
1707 extraOptionsList = None
1708
1709
1710 if (self._skeleton or self._skeletonCA) and len(self._topOptionsFiles) > 0:
1711 AthenaCommand = self._cmd[:-len(self._topOptionsFiles)]
1712 else:
1713 AthenaCommand = self._cmd
1714 AthenaCommand.append(AthenaSerialisedConfigurationFile)
1715
1716 msg.debug("requested VTune command basic options: {options}".format(options = defaultOptions))
1717 msg.debug("requested VTune command extra options: {options}".format(options = extraOptionsList))
1718 command = VTuneCommand(
1719 defaultOptions = defaultOptions,
1720 extraOptionsList = extraOptionsList,
1721 AthenaCommand = AthenaCommand
1722 )
1723 msg.debug("VTune command: {command}".format(command = command))
1724 print(command, file=wrapper)
1725 else:
1726 msg.info('Valgrind/VTune not engaged')
1727
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,
1733 error = e
1734 )
1735 msg.error(errMsg)
1736 raise trfExceptions.TransformExecutionException(
1737 trfExit.nameToCode('TRF_EXEC_SETUP_WRAPPER'),
1738 errMsg
1739 )
1740 self._cmd = [ path.join('.', self._wrapperFile) ]
1741 if self._containerSetup is not None:
1742 asetupFile.close()
1743 self._cmd = container_cmd + self._cmd
1744
1745
void print(char *figname, TCanvas *c1)