Skip to content

fix: bokeh logging noise - #140

Open
rileythai wants to merge 4 commits into
mainfrom
fix-keyerror-bokeh
Open

fix: bokeh logging noise#140
rileythai wants to merge 4 commits into
mainfrom
fix-keyerror-bokeh

Conversation

@rileythai

Copy link
Copy Markdown
Collaborator

this PR fixes #129 by doing two things:

  1. making the Comm logger quiet (it seems harmless)
  2. making a patched version of the BokehModel from jupyter_bokeh which prevents the KeyError messages and drops events and callbacks prior to things.

The mechanisms are basically:

  1. No such comm comes from the comm module's logger, presumably because there are JS messages that hang from callbacks after the object is changed on add/remove. The fix is to just make the logger quiet.
  2. The KeyError is because of garbage collection. It happens randomly (whenever garbage collection decides to run), but is mostly harmless. Because the entire object is serialized and then later updated, we need to ensure the object is deleted and only tried to be deleted if it's actually there (I don't know which case it is but it should already be deleted when the gc calls it).

There are now explicit cleanup callbacks in FigureBokeh and a new patched subclass BokehModel (SafeBokehModel) which overrides the close and _sync_model methods to handle these error cases.

The DeserializationError only sometimes occured in my docker tests.

The PR also bumps jupyter_bokeh>=4.1.0.

- prevent callback from occuring upstream in patched jupyter_bokeh
version (which should be moved to a submodule but relied on compiled
artifacts to attach the env)
- also explicitly remove the Widget from the document with a cleanup
callback
- this doesn't fix "No such comm" issues (they still spawn N no comm
messages on add/remove, where N is the number of effects attached I
think)
- added currently as a uv tool source but we can change later
- the messages are completely harmless and only occur on add remove
- the reason comm messages like this occur is because a JS message is
probably trying to hit a non-existent (or mis-identified widget)
- another way would be to rewrite the grid but it needs reserialized
objects to actually update and rerender properly
- the easiest way is to make it quiet via making the logger quiet
- we patch directly in the BokehModel, i don't know if it's too
overscoped to add this to BokehModel because I dont know if anyone else
uses the class like this
- confirmed working in docker compose
- removed from pyproject/uv.lock/docker
- they have underscores sometimes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bokeh callback key error

1 participant