Closed liamhuber closed 2 months ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Coverage variation | Diff coverage |
---|---|
:white_check_mark: +0.04% (target: -1.00%) | :white_check_mark: 100.00% |
Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more
This eliminates the metaclass
HasPost
fromNode
; previously this was used to ensure that loading and running nodes always happened after everything in__init__
was totally finished. This was important becauseMacro
(currently...) needs to have built its subgraph before some storage can load its child data, and because obviously we want all the children ofNode
to be finished their setup procedures before we try running.In its place,
Node.__init__
now ends withself._setup_node(); self._after_node_setup( *args, overwrite_save=overwrite_save, run_after_init=run_after_init, **kwargs)
. Children can thus (a) do stuff before callingsuper().__init__
and (b) override_setup_node
in order to get everything done that needs to be done before loading and running inNode._after_node_setup
.This places a bit more cognitive load on developers of
Node
subclasses, as they need to remember the business with_setup_node
when defining the subclass, but it relieves the complication of using a metaclass. I discussed the idea with @pmrv and he agreed this is probably the lesser of two evils, saying something to the effect of "this way it is at least much clearer when we are going to shoot ourselves in the foot". This is definitely a trade-off with downside, but I think it's a net win.Note that typical users/developers who are creating new macro, function, and workflow nodes, e.g. with the decorators, don't give a hoot about any of this. They can keep on decorating functions and instantiating workflows to their hearts content. It is only development at one stage above these "node designers" that need to know about/care about this stuff.
It's also the case that
Node
and its children now parse all remaining**kwargs
and*args
as node input channel data, just likeFunction
always did! IMO this is nice sinceMacro
definitions are now very function-like and users/developers are often likely to have a good sense of the order of arguments, so allowing*arg
specification should be convenient. This is also the case for parsingNode.run
and all the run-like methods. The one exception isWorkflow.__init__
, where*nodes
takes the place of*args
and these are considered initial children. Anyhow, this is purely an extension/relaxation of the existing syntax.