diff --git a/Control/AthenaConfiguration/CMakeLists.txt b/Control/AthenaConfiguration/CMakeLists.txt index 79d9249c519102e88b769bac41b4495240535939..d18df53c31db3d2a755fb85bf96e4667121cdfcb 100644 --- a/Control/AthenaConfiguration/CMakeLists.txt +++ b/Control/AthenaConfiguration/CMakeLists.txt @@ -17,9 +17,6 @@ atlas_add_test( ComponentAccumulatorTest SCRIPT python -m unittest -v AthenaConfiguration.ComponentAccumulatorTest POST_EXEC_SCRIPT nopost.sh ) -atlas_add_test( UnifyPropertiesTest - SCRIPT python -m unittest -v AthenaConfiguration.UnifyProperties - POST_EXEC_SCRIPT nopost.sh ) atlas_add_test( AthConfigFlagsTest SCRIPT python -m unittest AthenaConfiguration.AthConfigFlags diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py index c2575bdfc09bf54ff1d2a9e2fd6ae4f27551e7ca..33c34e346fe982b2e748618c235b08dfdd3cbd82 100644 --- a/Control/AthenaConfiguration/python/ComponentAccumulator.py +++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py @@ -18,7 +18,6 @@ import six import copy import sys -from AthenaConfiguration.UnifyProperties import unifySet @@ -466,7 +465,7 @@ class ComponentAccumulator(object): if self._theAppProps[key] == value: self._msg.debug("ApplicationMgr property '%s' already set to '%s'.", key, value) elif isinstance(self._theAppProps[key],collections.Sequence) and not isinstance(self._theAppProps[key],str): - value=unifySet(self._theAppProps[key],value) + value=self._theAppProps[key] + [el for el in value if el not in self._theAppProps[key]] self._msg.info("ApplicationMgr property '%s' already set to '%s'. Overwriting with %s", key, self._theAppProps[key], value) self._theAppProps[key]=value else: @@ -1077,7 +1076,7 @@ def appendCAtoAthena(ca): if origPropValue == propValue: _log.debug("ApplicationMgr property '%s' already set to '%s'.", propName, propValue) elif isinstance(origPropValue, collections.Sequence) and not isinstance(origPropValue, str): - propValue = unifySet(origPropValue, propValue) + propValue = origPropValue + [el for el in propValue if el not in origPropValue] _log.info("ApplicationMgr property '%s' already set to '%s'. Overwriting with %s", propName, origPropValue, propValue) setattr(theApp, propName, propValue) else: diff --git a/Control/AthenaConfiguration/python/UnifyProperties.py b/Control/AthenaConfiguration/python/UnifyProperties.py deleted file mode 100644 index 937df77b35d1652231f58a83b48b5440843bb1e4..0000000000000000000000000000000000000000 --- a/Control/AthenaConfiguration/python/UnifyProperties.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration - -# A collection of methods to unify/merge list-properties -# ToDo: Define the merging-method when defining the property - -from __future__ import print_function - -from AthenaCommon.Logging import logging - -log=logging.getLogger('ComponentAccumulator') - -def unifySet(prop1,prop2): - #May want to strip whitespace in case the params are lists of strings - missingProps = [p for p in prop2 if p not in prop1] - return prop1 + missingProps - -def unifySetVerbose(prop1,prop2): - log.debug("In UnifyProperties: unifying sets" ) - log.debug( str(prop1) ) - log.debug( "and" ) - log.debug( str(prop2) ) - return unifySet(prop1,prop2) - -def unifySetOfPairs(prop1,prop2): - - def getPairs(seq): - r=set() - nPairs=int(len(seq)/2) - if (2*nPairs!=len(seq)): - from AthenaConfiguration.ComponentAccumulator import ConfigurationError - raise ConfigurationError("Expected a sequence with even number of elements") - - for i in range(0,nPairs): - r.add((seq[2*i],seq[2*i+1])) - return r - - setOfPairs1=getPairs(prop1) - setOfPairs2=getPairs(prop2) - unionOfPairs=(setOfPairs1 | setOfPairs2) - finallist=[] - for p in unionOfPairs: - finallist+=p - return finallist - - - -def unifyAppendDict(prop1,prop2): - #Unify two dictionaries by appending. Throws on conflicting keys - #find conflicting keys - doubleKeys= set(prop1.keys()) & set(prop2.keys()) - for k in doubleKeys: - if prop1[k]!= prop2[k]: - from AthenaConfiguration.Deduplication import DeduplicationFailed - raise DeduplicationFailed("Map-property defined multiple times with conflicting values for key %s" % k) - pass - newDict=prop1 - newDict.update(prop2) - return newDict - - -_propsToUnify={"GeoModelSvc.DetectorTools":unifySet, - "CondInputLoader.Load":unifySet, - "IOVDbSvc.Folders":unifySet, - "IOVDbSvc.FoldersToMetaData":unifySet, - "IOVDbSvc.overrideTags":unifySet, - "EvtPersistencySvc.CnvServices":unifySet, - "PoolSvc.ReadCatalog":unifySet, - "ProxyProviderSvc.ProviderNames":unifySet, - "TagInfoMgr.ExtraTagValuePairs":unifyAppendDict, - "AthenaOutputStream.ItemList":unifySet, - "AthenaPoolCnvSvc.PoolAttributes":unifySet, - "*.HypoTools": unifySet, - "AtDSFMTGenSvc.Seeds": unifySet, - "AtRanluxGenSvc.Seeds": unifySet, - "AtRndmGenSvc.Seeds": unifySet, - "dummyService.AList": unifySet, - "dummyTool.BList" : unifySet, - "*.InputMakerInputDecisions": unifySet, - "AddressRemappingSvc.TypeKeyRenameMaps": unifySet, - "AuditorSvc.Auditors": unifySet, - "MetaDataSvc.MetaDataTools": unifySet, - "ByteStreamAddressProviderSvc.TypeNames": unifySet, - } - -def setUnificationFunction(key, function): - _propsToUnify[key] = function - -def getUnificationKey(propname): - if propname in _propsToUnify: - return propname - try: - objectName, variableName = propname.split('.')[-2:] - - matchingByVariable = '*.{}'.format(variableName) - if matchingByVariable in _propsToUnify: - return matchingByVariable - - matchingByObject = '{}.*'.format(objectName) - if matchingByObject in _propsToUnify: - return matchingByObject - - except Exception: - pass - - return None - - -def matchProperty(propname): - return getUnificationKey(propname) is not None - - -def getUnificationFunc(propname): - unificationKey = getUnificationKey(propname) - if unificationKey is None: - return None - return _propsToUnify[unificationKey] - - -def unifyProperty(propname,prop1,prop2): - unificationFunc = getUnificationFunc(propname) - - if unificationFunc is None: - from AthenaConfiguration.Deduplication import DeduplicationFailed - raise DeduplicationFailed("List property %s defined multiple times with conflicting values.\n " % propname \ - + str(prop1) +"\n and \n" +str(prop2) \ - + "\nIf this property should be merged, consider adding it to AthenaConfiguration/UnifyProperties.py") - return unificationFunc(prop1,prop2) - - -# self test -import unittest - -class BasicTest( unittest.TestCase ): - def runTest( self ): - unified = unifyProperty("Alg.HypoTools", ["a", "b"], ["c", "b"]) - self.assertEqual( sorted(unified), sorted(["a", "b", "c"]), "Hypo tools unification failed" ) - - setUnificationFunction("*.HypoTools", unifySetVerbose) - log.setLevel(7) - unified = unifyProperty("Alg.HypoTools", ["a", "b"], ["c", "b"]) - self.assertEqual( sorted(unified), sorted(["a", "b", "c"]), "Hypo tools unification failed" ) -