Interactive: only register once the function parameters watchers #818
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.
Alternative implementation (#768) to fix #763
The problem in #763 was two-fold:
self._obj
, e.g. a DataFrame) was registered every time a newInteractive
instance was created. Even a small pipeline creates many instances so that led to many calls being made when one of the parameters controlling the input function changed.self._obj
object. Even if all the instances share the same object, setting a new object in the update callback would not lead to that new object being set on all the instances, just on that particular one. This is why in the previous attempts made to fix this issue, which I've also tried, only setting the callbacks on the root instance (depth == 0
) didn't work; the Interactive instance being updated isn't the one that drives the display.To fix 2., I've added a small abstraction layer using a list as the data holder and properties to access/edit the object held, so that the underlying object can be shared across all the Interactive instances created in a pipeline. This means that any change made to
_obj
by any Interactive instance will be visible to all the other instances.To fix 1. I've used
depth == 0
to only register the update watchers on the root instance, which now works thanks to the fix for 2.