You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Initialise nodes# Initialise arcs# And then...model.add_overrides(data.get("overrides", {}))
# And in Modeldefadd_overrides(self, config: Dict):
fornodeinconfig.get("nodes", {}):
type_=node.pop("type_")
name=node.pop("name")
self.nodes_type[type_][name].apply_overrides(node)
forarcinconfig.get("arcs", {}):
name=arc.pop("name")
self.arcs[name].apply_overrides(arc)
The node.apply_overrides and arc.apply_overrides will be the methods that will call the appropriate setters to ensure that any side effects of modifying those parameters are taken care of.
apply_overrides should be a method (not an abstract one) of the base class for nodes and arcs that will do nothing unless it is overridden. This way, only those specific nodes that can be overridden will need to have this method (and the relevant setters) implemented.
In terms of how this can be done from a practical point of view, I would open issues for:
Implement the above overriden logic. Should be harmless and backwards compatible with any existing code and config files.
Identify which nodes/arcs have parameters that are worth to be overriden and open an issue for each of those nodes/arcs, indicating which parameters need such override. Watch out for recursive calls! You might need some hidden internal attributes that can be set directly and only use the setters in the overrides:
classMyNode:
def__init__(...):
# Does not use the setterself._some_param=get_default_some_param(...)
@propertydefsome_param(self):
returnself._some_param@some_param.setterdefsome_param(self, value):
ifnotvalue:
return# Some complex logicself._some_param= ...
# More logic heredefapply_overrides(self, config: Dict):
self.some_param=config.pop("some_param", None)
...
Originally posted by @dalonsoa in #54 (comment)
The text was updated successfully, but these errors were encountered: