GaudiConfig2: Change in unpickling behavior
We ran into some further problems with GaudiConfig2 when trying to unpickle derived Configurable classes (in case you have access, https://its.cern.ch/jira/browse/ATR-21356).
The problem shows up when trying to pickle/unpickle derived Configurables with this signature:
class MyClass(MyBase):
def __init__ (self, name):
super(MyClass, self).__init__(name)
self.regions = "blah"
Note the lack of *args, **kwargs
in the arguments. On unpickling this results in e.g.
File "/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2020-05-04T2139/GAUDI/22.0.13/InstallArea/x86_64-centos7-gcc8-opt/python/GaudiConfig2/_configurables.py", line 219, in __setstate__
self.__init__(state.get('name'), **state['properties'])
TypeError: __init__() got an unexpected keyword argument 'regions'
Adding *args, **kwargs
to the __init__
function fixes this problem. The difference comes down to using
-
setattr
in the old configurables: https://gitlab.cern.ch/gaudi/Gaudi/-/blob/master/GaudiKernel/python/GaudiKernel/Configurable.py#L387 -
__init__
for the new ones: https://gitlab.cern.ch/gaudi/Gaudi/-/blob/master/GaudiConfiguration/python/GaudiConfig2/_configurables.py#L219
Was there a particular reason for this change?
Edited by Frank Winklmeier