From fe04448eb00b548de3e8d1bd1c98637f278752ff Mon Sep 17 00:00:00 2001
From: Christian Nass <christian.nass@cern.ch>
Date: Thu, 18 Jun 2020 12:54:48 +0200
Subject: [PATCH] Adding conf2toConfigurable changes by hand

---
 .../python/ComponentAccumulator.py            | 27 ++++++++++++-------
 .../test/test_trigUpgr_full_menu_cf_build.sh  |  3 ++-
 .../HLTMenuConfig/Bjet/BjetSequenceSetup.py   |  1 +
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py
index 25cd773e566f..6013dbf569fd 100644
--- a/Control/AthenaConfiguration/python/ComponentAccumulator.py
+++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py
@@ -819,9 +819,14 @@ def __setProperties( destConfigurableInstance, sourceConf2Instance, indent="" ):
             setattr( destConfigurableInstance, pname, [conf2toConfigurable( tool, __indent( indent ) ) for tool in pvalue] )
             _log.debug( "{}Set the private tools array {} of {}".format( indent, pname,  destConfigurableInstance.name() ) )
         elif "PrivateToolHandle" in propType or "GaudiConfig2.Configurables" in propType or "ServiceHandle" in propType:
-            #_log.info( "{} {}  {}".format( indent, pname, dir(pvalue) ) )
             _log.debug( "{}Set the property {}  that is private tool {} ".format( indent,  pname, destConfigurableInstance.name() ) )
-            setattr( destConfigurableInstance, pname, conf2toConfigurable( pvalue, indent=__indent( indent ) ) )
+            try: #sometimes it is not printable
+                _log.debug("{}Tool: {}".format(indent, pvalue))
+            except Exception:
+                _log.debug("{}Could not print it".format(indent))
+                pass
+            if pvalue is not None:
+                setattr( destConfigurableInstance, pname, conf2toConfigurable( pvalue, indent=__indent( indent ) ) )
         else: # plain data
             if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)):
                 pvalue=pvalue.data
@@ -899,7 +904,7 @@ def conf2toConfigurable( comp, indent="" ):
 
 
     def __areSettingsSame( existingConfigurableInstance, newConf2Instance, indent="" ):
-        _log.debug( "{}Checking if setting is the same {}".format( indent, compName(existingConfigurableInstance) ) )
+        _log.debug( "{}Checking if setting is the same {}".format( indent, existingConfigurableInstance.getFullName() ) )
         alreadySetProperties = dict([ (pname, pvalue) for pname,pvalue
                                       in six.iteritems(existingConfigurableInstance.getValuedProperties()) ])
         for pname, pvalue in six.iteritems( newConf2Instance._properties ): # six.iteritems(comp._properties):
@@ -914,15 +919,18 @@ def conf2toConfigurable( comp, indent="" ):
                 for oldC, newC in zip( alreadySetProperties[pname], pvalue):
                     __areSettingsSame( oldC, newC, __indent(indent))
             elif "PrivateToolHandle" in propType or "GaudiConfig2.Configurables" in propType or "ServiceHandle" in propType:
-                #__areSettingsSame( alreadySetProperties[pname], pvalue, __indent(indent))
-                _log.debug( "{} {}".format( indent, dir(pvalue) ) )
-                __areSettingsSame( getattr(existingConfigurableInstance, pname), pvalue, __indent(indent))
+                exisitngVal = getattr(existingConfigurableInstance, pname)
+                if isinstance( pvalue, str ):
+                    _log.warning("{}The handle {} of component {}.{} is just a string {}, skipping deeper checks, configuration may be incorrect".format(indent, propType, newConf2Instance.name, pname, pvalue))
+                else:
+                    _log.debug( "{}Some kind of handle  and, object type {} existing {}".format( indent, type(pvalue), type(exisitngVal) ) )
+                    __areSettingsSame( exisitngVal, pvalue, indent)
             else:
                 if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)):
                     pvalue=pvalue.data
 
                 if alreadySetProperties[pname] != pvalue:
-                    _log.info("{}Merging property: {} for {}".format(__indent(indent), pname, newConf2Instance.getName() ))
+                    _log.info("{}Merging property: {} for {}".format(indent, pname, newConf2Instance.getName() ))
                     # create surrogate
                     clone = newConf2Instance.getInstance("Clone")
                     setattr(clone, pname, alreadySetProperties[pname])
@@ -932,15 +940,16 @@ def conf2toConfigurable( comp, indent="" ):
                     setattr(existingConfigurable, pname, updatedPropValue)
                     del clone
                     _log.info("{} invoked GaudiConf2 semantics to merge the {} and the {} to {} for property {} of {}".format(
-                        __indent(indent), alreadySetProperties[pname], pvalue, pname,  updatedPropValue, existingConfigurable.getName()))
+                        indent, alreadySetProperties[pname], pvalue, pname,  updatedPropValue, existingConfigurable.getFullName()))
 
     existingConfigurable = __alreadyConfigured( comp.name )
     if existingConfigurable: # if configurable exists we try to merge with it
+        _log.debug( "{}Pre-existing configurable {} was found, checking if has the same properties".format( indent, comp.getName() ) )
         __areSettingsSame( existingConfigurable, comp )
         _log.debug( "{}Pre-existing configurable was found to have the same properties".format( indent, comp.name ) )
         instance = existingConfigurable
     else: # create new configurable
-        _log.debug( "{}Creating component configurable {}".format( indent, comp.name ) )
+        _log.debug( "{}Creating component configurable {}".format( indent, comp.getFullJobOptName() ) )
         configurableClass = __findConfigurableClass( comp.getFullJobOptName().split( "/" )[0] )
         instance = configurableClass( comp.name )
         __setProperties( instance, comp, __indent( indent ) )
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_trigUpgr_full_menu_cf_build.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_trigUpgr_full_menu_cf_build.sh
index 4a140764cf13..cd18c2a59066 100755
--- a/Trigger/TrigValidation/TrigUpgradeTest/test/test_trigUpgr_full_menu_cf_build.sh
+++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_trigUpgr_full_menu_cf_build.sh
@@ -10,7 +10,8 @@ export THREADS=1
 export SLOTS=1
 export JOBOPTION="TrigUpgradeTest/full_menu_cf.py"
 export REGTESTEXP="TriggerSummaryStep.*HLT_.*|TriggerMonitorFinal.*HLT_.*|TrigSignatureMoniMT.*HLT_.*|TrigSignatureMoniMT.*-- #[0-9]+ (Events|Features).*"
-export EXTRA="doWriteBS=False;doWriteRDOTrigger=True;"
+#export EXTRA="doWriteBS=False;doWriteRDOTrigger=True;"
+export EXTRA="doWriteBS=False;doWriteRDOTrigger=True;forceEnableAllChains=True;doEmptyMenu=True;doBjetSlice=True;"
 
 # Find the regtest reference installed with the release
 export REGTESTREF=`find_data.py TrigUpgradeTest/full_menu_cf_build.ref`
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetSequenceSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetSequenceSetup.py
index a78a03f0558c..1283c77fe951 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetSequenceSetup.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetSequenceSetup.py
@@ -87,6 +87,7 @@ def bJetStep2Sequence():
     for alg in findAllAlgorithms(acc_flavourTaggingAlgs.getSequence("AthAlgSeq")):
         AllFlavourTaggingAlgs.append(conf2toConfigurable(alg))
 
+    acc_flavourTaggingAlgs.wasMerged()
     bJetBtagSequence = seqAND( "bJetBtagSequence", secondStageAlgs + AllFlavourTaggingAlgs )
     InputMakerAlg.ViewNodeName = "bJetBtagSequence"
 
-- 
GitLab