Skip to content

Commit

Permalink
Merge pull request #10863 from amaltaro/bundle-154patch2
Browse files Browse the repository at this point in the history
Bundle of patches for WMAgent 1.5.4.patch2
  • Loading branch information
amaltaro authored Oct 12, 2021
2 parents 038860b + 578110d commit 6ceee3a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 9 deletions.
11 changes: 8 additions & 3 deletions etc/submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@ echo -e "======== WMAgent CMS environment load finished at $(TZ=GMT date) ======


echo "======== WMAgent COMP Python bootstrap starting at $(TZ=GMT date) ========"
# First, decide which COMP ScramArch to use based on the required OS
# First, decide which COMP ScramArch to use based on the required OS and Architecture
THIS_ARCH=`uname -m` # if it's PowerPC, it returns `ppc64le`
if [ "$THIS_ARCH" = "x86_64" ]
then
THIS_ARCH="amd64"
fi
if [ "$REQUIRED_OS" = "rhel7" ];
then
WMA_SCRAM_ARCH=slc7_amd64_gcc630
WMA_SCRAM_ARCH=slc7_${THIS_ARCH}_gcc630
else
WMA_SCRAM_ARCH=slc6_amd64_gcc493
WMA_SCRAM_ARCH=slc6_${THIS_ARCH}_gcc700
fi
echo "Job requires OS: $REQUIRED_OS, thus setting ScramArch to: $WMA_SCRAM_ARCH"

Expand Down
11 changes: 8 additions & 3 deletions etc/submit_py3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@ echo -e "======== WMAgent CMS environment load finished at $(TZ=GMT date) ======


echo "======== WMAgent COMP Python bootstrap starting at $(TZ=GMT date) ========"
# First, decide which COMP ScramArch to use based on the required OS
# First, decide which COMP ScramArch to use based on the required OS and Architecture
THIS_ARCH=`uname -m` # if it's PowerPC, it returns `ppc64le`
if [ "$THIS_ARCH" = "x86_64" ]
then
THIS_ARCH="amd64"
fi
if [ "$REQUIRED_OS" = "rhel7" ];
then
WMA_SCRAM_ARCH=slc7_amd64_gcc630
WMA_SCRAM_ARCH=slc7_${THIS_ARCH}_gcc630
else
WMA_SCRAM_ARCH=slc6_amd64_gcc700
WMA_SCRAM_ARCH=slc6_${THIS_ARCH}_gcc700
fi
echo "Job requires OS: $REQUIRED_OS, thus setting ScramArch to: $WMA_SCRAM_ARCH"

Expand Down
9 changes: 9 additions & 0 deletions src/python/WMComponent/JobAccountant/AccountantWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ def handleJob(self, jobID, fwkJobReport):
conn=self.getDBConn(),
transaction=self.existingTransaction())

# FIXME: temporary workaround for: https://github.com/dmwm/WMCore/issues/9633
skipOutputFiles = False
if jobSuccess:
fileList = fwkJobReport.getAllFiles()

Expand Down Expand Up @@ -504,6 +506,7 @@ def handleJob(self, jobID, fwkJobReport):
if not fwjrFile.get("locations") and fwjrFile.get("lfn", "").endswith(".root"):
logging.warning("The following file doesn't have any location: %s", fwjrFile)
jobSuccess = False
skipOutputFiles = True
break
else:
fileList = fwkJobReport.getAllFilesFromStep(step='logArch1')
Expand Down Expand Up @@ -548,6 +551,12 @@ def handleJob(self, jobID, fwkJobReport):
else:
wmbsJob["outcome"] = "failure"

# FIXME: BAD HACK to avoid crashing the component
if skipOutputFiles:
logging.warning("Skipping output file registration for failed job: %d", jobID)
self.listOfJobsToFail.append(wmbsJob)
return jobSuccess

for fwjrFile in fileList:

logging.debug("Job %d , register output %s", jobID, fwjrFile["lfn"])
Expand Down
40 changes: 39 additions & 1 deletion src/python/WMCore/BossAir/Plugins/BasePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from builtins import object, str, bytes
from future.utils import viewitems, viewvalues

from Utils.Utilities import decodeBytesToUnicode
from WMCore.WMException import WMException
from WMCore.WMRuntime.Tools.Scram import ARCH_TO_OS
from WMCore.WMRuntime.Tools.Scram import ARCH_TO_OS, SCRAM_TO_ARCH



Expand Down Expand Up @@ -152,3 +153,40 @@ def scramArchtoRequiredOS(scramArch=None):
requiredOSes.add('any')

return ','.join(sorted(requiredOSes))

@staticmethod
def scramArchtoRequiredArch(scramArch=None):
"""
Converts a given ScramArch to a unique target CPU architecture.
Note that an architecture precedence is enforced in case there are
multiple matches.
In case no scramArch is defined, leave the architecture undefined.
:param scramArch: can be either a string or a list of ScramArchs
:return: a string with the matched architecture
"""
defaultArch = "X86_64"
requiredArchs = set()
if scramArch is None:
return None
elif isinstance(scramArch, (str, bytes)):
scramArch = [scramArch]

for item in scramArch:
item = decodeBytesToUnicode(item)
arch = item.split("_")[1]
if arch not in SCRAM_TO_ARCH:
msg = "Job configured to a ScramArch: '{}' not supported in BossAir".format(item)
raise BossAirPluginException(msg)
requiredArchs.add(SCRAM_TO_ARCH.get(arch))

# now we have the final list of architectures, return only 1 of them
if len(requiredArchs) == 1:
return requiredArchs.pop()
elif "X86_64" in requiredArchs:
return "X86_64"
elif "ppc64le" in requiredArchs:
return "ppc64le"
elif "aarch64" in requiredArchs:
return "aarch64"
else: # should never get here!
return defaultArch
7 changes: 6 additions & 1 deletion src/python/WMCore/BossAir/Plugins/SimpleCondorPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,12 @@ def getJobParameters(self, jobList):
ad['My.REQUIRED_OS'] = classad.quote(encodeUnicodeToBytesConditional(requiredOSes, condition=PY2))
cmsswVersions = ','.join(job.get('swVersion'))
ad['My.CMSSW_Versions'] = classad.quote(encodeUnicodeToBytesConditional(cmsswVersions, condition=PY2))

requiredArch = self.scramArchtoRequiredArch(job.get('scramArch'))
if not requiredArch: # only Cleanup jobs should not have ScramArch defined
ad['Requirements'] = '(TARGET.Arch =!= Undefined)'
else:
ad['Requirements'] = '(TARGET.Arch =?= "{}")'.format(requiredArch)

jobParameters.append(ad)

return jobParameters
Expand Down
2 changes: 1 addition & 1 deletion src/python/WMCore/WMRuntime/Tools/Scram.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
from Utils.PythonVersion import PY3
from Utils.Utilities import encodeUnicodeToBytesConditional, decodeBytesToUnicodeConditional

SCRAM_TO_ARCH = {'amd64': 'X86_64', 'aarch64': 'aarch64', 'ppc64le': 'ppc64le'}
ARCH_TO_OS = {'slc5': ['rhel6'], 'slc6': ['rhel6'], 'slc7': ['rhel7']}

OS_TO_ARCH = {}
for arch, oses in viewitems(ARCH_TO_OS):
for osName in oses:
Expand Down

0 comments on commit 6ceee3a

Please sign in to comment.