Fixed deserialization bug for nodes depending on on_input_connected #316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Nodes which depend on
on_input_connectedbeing called are not properly initialized after a load_session.I simply added
BaseNode.on_input_connectedcall tobase.graph._deserialize()(graph.py:1615, see diff) to fix this issue. Theoretically, when loading a session, I would imagine a graph should behave just as it does when created withset_inputandset_output, this is my justification for believing on_input_connected should be called. (Personlly, rather than internally updating node connection dicts, I perhaps would use the API methods to build the session to unify the functionality in the first place.)I had a situation which motivated this, several nodes which were using on_input_connected visually looked initialized, but were not behaving exactly as they do on first startup / creation until I manually reconnected them. My use case could be a result of bad design choices, I could grab the only node on the input connection dynamically - that did work - rather than setting it on connection. (Maybe someone has a stern lecture for me on this design choice...) However, I do think this would be a bugfix regardless of my personal motivation. It seems to work robustly and I hope you consider including this change or a variation of it.