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