-
-
Notifications
You must be signed in to change notification settings - Fork 406
enh: Add debounce support to PlotSize and RangeXY bokeh callbacks #6672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6672 +/- ##
==========================================
- Coverage 88.96% 87.67% -1.29%
==========================================
Files 328 328
Lines 70221 70235 +14
==========================================
- Hits 62473 61580 -893
- Misses 7748 8655 +907 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
if not self._active and self.plot.document: | ||
self._active = True | ||
self._set_busy(True) | ||
await self.process_on_change() | ||
state.execute(self.process_on_change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (and likewise for on_event
) seems to be the reason why things fails. Getting _curdoc_locked RuntimeErorr when running locally with -s
ERROR tornado.application:ioloop.py:778 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOLoop object at 0x7f7038dd8980>>, <Task finished name='Task-117' coro=<Callback.process_on_event() done, defined at /home/shh/projects/holoviz/repos/holoviews/holoviews/plotting/bokeh/callbacks.py:344> exception=RuntimeError('_pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes')>)
Traceback (most recent call last):
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/tornado/ioloop.py", line 758, in _run_callback
ret = callback()
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/tornado/ioloop.py", line 782, in _discard_future_result
future.result()
~~~~~~~~~~~~~^^
File "/home/shh/projects/holoviz/repos/holoviews/holoviews/plotting/bokeh/callbacks.py", line 374, in process_on_event
await self.on_msg(msg)
File "/home/shh/projects/holoviz/repos/holoviews/holoviews/plotting/bokeh/callbacks.py", line 728, in on_msg
await self._process_selection_event()
File "/home/shh/projects/holoviz/repos/holoviews/holoviews/plotting/bokeh/callbacks.py", line 768, in _process_selection_event
self._panel.stylesheets = [
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/core/has_props.py", line 337, in __setattr__
return super().__setattr__(name, value)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/core/property/descriptors.py", line 332, in __set__
self._set(obj, old, value, setter=setter)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/core/property/descriptors.py", line 614, in _set
self._trigger(obj, old, value, hint=hint, setter=setter)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/core/property/descriptors.py", line 692, in _trigger
obj.trigger(self.name, old, value, hint, setter)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/model/model.py", line 583, in trigger
super().trigger(descriptor.name, old, new, hint=hint, setter=setter)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/util/callback_manager.py", line 177, in trigger
self.document.callbacks.notify_change(cast(Model, self), attr, old, new, hint, setter, invoke)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/callbacks.py", line 251, in notify_change
self.trigger_on_change(event)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/callbacks.py", line 423, in trigger_on_change
invoke_with_curdoc(doc, invoke_callbacks)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/callbacks.py", line 453, in invoke_with_curdoc
return f()
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/callbacks.py", line 422, in invoke_callbacks
cb(event)
~~^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/callbacks.py", line 278, in <lambda>
self._change_callbacks[receiver] = lambda event: event.dispatch(receiver)
~~~~~~~~~~~~~~^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/events.py", line 352, in dispatch
super().dispatch(receiver)
~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/document/events.py", line 218, in dispatch
cast(DocumentPatchedMixin, receiver)._document_patched(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/shh/.local/conda/envs/holoviz/lib/python3.13/site-packages/bokeh/server/session.py", line 244, in _document_patched
raise RuntimeError("_pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes")
RuntimeError: _pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes
The throttling/debouncing behavior behind stream callbacks seems to have regressed at some point, such that a datashaded HoloViews plot using PlotSize and RangeXY streams seems to generate a ton of events. This PR reimplements a debouncing approach that actually works. For now I've hardcoded the debounce timeout to 100ms, which is the value we use for notebook event debouncing.