No way to instanciate BeaconObject without creating constructor
BeaconObject
signature is
def __init__(
self,
config: dict,
name: str = None,
path: list = None,
share_hardware: bool = True,
):
The factory used to create it is
../bliss.git/bliss/config/plugins/generic.py:488: in create_objects_from_config_node
bctrl = klass(item_name, cfg_node.clone())
The sequence name
/config
do not match.
As result it is not possible to create new class without inheriting the constructor.
../bliss.git/bliss/config/static.py:998: in get
return self._get(name)
../bliss.git/bliss/config/static.py:1048: in _get
for name2itemsAndname2itemcache in iteration:
../bliss.git/bliss/config/plugins/generic.py:488: in create_objects_from_config_node
bctrl = klass(item_name, cfg_node.clone())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.helpers.test_config_obj_list_property_setting.Fake object at 0x7f53bd2cd650>, config = 'fake1'
name = {'name': 'fake1', 'plugin': 'bliss', 'class': 'Fake', 'package': 'tests.helpers.test_config_obj_list_property_setting'}, path = None, share_hardware = True
def __init__(
self,
config: dict,
name: str = None,
path: list = None,
share_hardware: bool = True,
):
self._path = path
> self._config_name = config.get("name")
E AttributeError: 'str' object has no attribute 'get'
../bliss.git/bliss/config/beacon_object.py:161: AttributeError
Here is what i have to do:
class Fake(BeaconObject):
def __init__(self, name, config):
super(Fake, self).__init__(config, name)
Proposal 1
There is many ways to fix that stuffs with many pro/con
I suggest to replace the factory by
bctrl = klass(name=item_name, config=cfg_node.clone())
Which enforce any component to have config
/name
arguments, and not something else (like cfg
).
Proposal 2
Inside BeaconObject
, swap the name/config if the type does not match.
What do you think?
Edited by Valentin Valls