Skip to content
Snippets Groups Projects
Commit 6430992a authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'more-robust-conversion-of-new-config-to-old-take2' into 'master'

More robust conversion of new config to old

See merge request atlas/athena!33837
parents f87ceed5 30ad92e0
No related branches found
No related tags found
No related merge requests found
...@@ -819,9 +819,14 @@ def __setProperties( destConfigurableInstance, sourceConf2Instance, indent="" ): ...@@ -819,9 +819,14 @@ def __setProperties( destConfigurableInstance, sourceConf2Instance, indent="" ):
setattr( destConfigurableInstance, pname, [conf2toConfigurable( tool, __indent( indent ) ) for tool in pvalue] ) setattr( destConfigurableInstance, pname, [conf2toConfigurable( tool, __indent( indent ) ) for tool in pvalue] )
_log.debug( "{}Set the private tools array {} of {}".format( indent, pname, destConfigurableInstance.name() ) ) _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: 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() ) ) _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 else: # plain data
if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)): if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)):
pvalue=pvalue.data pvalue=pvalue.data
...@@ -899,7 +904,7 @@ def conf2toConfigurable( comp, indent="" ): ...@@ -899,7 +904,7 @@ def conf2toConfigurable( comp, indent="" ):
def __areSettingsSame( existingConfigurableInstance, newConf2Instance, 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 alreadySetProperties = dict([ (pname, pvalue) for pname,pvalue
in six.iteritems(existingConfigurableInstance.getValuedProperties()) ]) in six.iteritems(existingConfigurableInstance.getValuedProperties()) ])
for pname, pvalue in six.iteritems( newConf2Instance._properties ): # six.iteritems(comp._properties): for pname, pvalue in six.iteritems( newConf2Instance._properties ): # six.iteritems(comp._properties):
...@@ -914,15 +919,18 @@ def conf2toConfigurable( comp, indent="" ): ...@@ -914,15 +919,18 @@ def conf2toConfigurable( comp, indent="" ):
for oldC, newC in zip( alreadySetProperties[pname], pvalue): for oldC, newC in zip( alreadySetProperties[pname], pvalue):
__areSettingsSame( oldC, newC, __indent(indent)) __areSettingsSame( oldC, newC, __indent(indent))
elif "PrivateToolHandle" in propType or "GaudiConfig2.Configurables" in propType or "ServiceHandle" in propType: elif "PrivateToolHandle" in propType or "GaudiConfig2.Configurables" in propType or "ServiceHandle" in propType:
#__areSettingsSame( alreadySetProperties[pname], pvalue, __indent(indent)) exisitngVal = getattr(existingConfigurableInstance, pname)
_log.debug( "{} {}".format( indent, dir(pvalue) ) ) if isinstance( pvalue, str ):
__areSettingsSame( getattr(existingConfigurableInstance, pname), pvalue, __indent(indent)) _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: else:
if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)): if isinstance(pvalue,(GaudiConfig2.semantics._ListHelper,GaudiConfig2.semantics._DictHelper)):
pvalue=pvalue.data pvalue=pvalue.data
if alreadySetProperties[pname] != pvalue: 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 # create surrogate
clone = newConf2Instance.getInstance("Clone") clone = newConf2Instance.getInstance("Clone")
setattr(clone, pname, alreadySetProperties[pname]) setattr(clone, pname, alreadySetProperties[pname])
...@@ -932,15 +940,16 @@ def conf2toConfigurable( comp, indent="" ): ...@@ -932,15 +940,16 @@ def conf2toConfigurable( comp, indent="" ):
setattr(existingConfigurable, pname, updatedPropValue) setattr(existingConfigurable, pname, updatedPropValue)
del clone del clone
_log.info("{} invoked GaudiConf2 semantics to merge the {} and the {} to {} for property {} of {}".format( _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 ) existingConfigurable = __alreadyConfigured( comp.name )
if existingConfigurable: # if configurable exists we try to merge with it 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 ) __areSettingsSame( existingConfigurable, comp )
_log.debug( "{}Pre-existing configurable was found to have the same properties".format( indent, comp.name ) ) _log.debug( "{}Pre-existing configurable was found to have the same properties".format( indent, comp.name ) )
instance = existingConfigurable instance = existingConfigurable
else: # create new configurable 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] ) configurableClass = __findConfigurableClass( comp.getFullJobOptName().split( "/" )[0] )
instance = configurableClass( comp.name ) instance = configurableClass( comp.name )
__setProperties( instance, comp, __indent( indent ) ) __setProperties( instance, comp, __indent( indent ) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment