From 4d43873e979109483ccb8ba78630281e7820adcf Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Tue, 12 Apr 2022 08:38:17 -0400 Subject: [PATCH] Enhance logic to map ScramArch to OS typo in the docstring --- .../WMCore/BossAir/Plugins/BasePlugin.py | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/python/WMCore/BossAir/Plugins/BasePlugin.py b/src/python/WMCore/BossAir/Plugins/BasePlugin.py index f6981b2d27..0dfbab16a2 100644 --- a/src/python/WMCore/BossAir/Plugins/BasePlugin.py +++ b/src/python/WMCore/BossAir/Plugins/BasePlugin.py @@ -6,7 +6,7 @@ """ from builtins import object, str, bytes -from future.utils import viewitems, viewvalues +from future.utils import viewvalues from Utils.Utilities import decodeBytesToUnicode from WMCore.WMException import WMException @@ -130,27 +130,25 @@ def updateSiteInformation(self, jobs, siteName, excludeSite): @staticmethod def scramArchtoRequiredOS(scramArch=None): """ + Matches a ScramArch - or a list of it - against a map of Scram + to Operating System - Args: - scramArch: string or list of scramArches that are acceptable for the job - - Returns: - string to be matched for OS requirements for job + :param scramArch: string or list of scramArches defined for a given job + :return: a string with the required OS to use """ - requiredOSes = set() + defaultValue = 'any' if not scramArch: - requiredOSes.add('any') - elif isinstance(scramArch, (str, bytes)): - for arch, validOSes in viewitems(ARCH_TO_OS): - if arch in scramArch: - requiredOSes.update(validOSes) - elif isinstance(scramArch, list): - for validArch in scramArch: - for arch, validOSes in viewitems(ARCH_TO_OS): - if arch in validArch: - requiredOSes.update(validOSes) - else: - requiredOSes.add('any') + return defaultValue + + requiredOSes = set() + if isinstance(scramArch, (str, bytes)): + scramArch = [scramArch] + elif not isinstance(scramArch, (list, tuple)): + return defaultValue + + for validArch in scramArch: + scramOS = validArch.split("_")[0] + requiredOSes.update(ARCH_TO_OS.get(scramOS, [])) return ','.join(sorted(requiredOSes))