issues handling bokeh message protocol
epifanio opened this issue · comments
Not sure what is the cause, but after a rebuild of a working bokeh
+ipywidgets
docker
environment - I am having the following error while running an ipyleaflet
widget within a bokeh application:
bokeh_1 | 2021-07-15 14:47:20,754 error handling message
bokeh_1 | message: Message 'PATCH-DOC' content: {'events': [{'kind': 'MessageSent', 'msg_type': 'ipywidgets_bokeh', 'msg_data': '{"buffers":[],"channel":"shell","content":{"comm_id":"5f6fb61e7c174d2d84b73bfafdd35ec3","data":{"method":"custom","content":{"event":"interaction","type":"mouseout","coordinates":[52.198611636156976,360.1245832443238]}}},"header":{"date":"2021-07-15T14:47:20.752Z","msg_id":"6068335f-bf37-4df8-896c-7e9a04bf3bf3","msg_type":"comm_msg","session":"86e52fc5-b439-4ddf-beb9-6ade95961403","username":"","version":"5.2"},"metadata":{},"parent_header":{}}'}], 'references': []}
bokeh_1 | error: TypeError('dispatch_shell() takes 2 positional arguments but 3 were given')
bokeh_1 | Traceback (most recent call last):
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/server/protocol_handler.py", line 90, in handle
bokeh_1 | work = await handler(message, connection)
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/server/session.py", line 67, in _needs_document_lock_wrapper
bokeh_1 | result = func(self, *args, **kwargs)
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/server/session.py", line 261, in _handle_patch
bokeh_1 | message.apply_to_document(self.document, self)
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/protocol/messages/patch_doc.py", line 100, in apply_to_document
bokeh_1 | doc._with_self_as_curdoc(lambda: doc.apply_json_patch(self.content, setter))
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/document/document.py", line 1198, in _with_self_as_curdoc
bokeh_1 | return f()
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/protocol/messages/patch_doc.py", line 100, in <lambda>
bokeh_1 | doc._with_self_as_curdoc(lambda: doc.apply_json_patch(self.content, setter))
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/document/document.py", line 398, in apply_json_patch
bokeh_1 | self._trigger_on_message(event_json["msg_type"], event_json["msg_data"])
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/bokeh/document/document.py", line 687, in _trigger_on_message
bokeh_1 | cb(msg_data)
bokeh_1 | File "/opt/venv/lib/python3.9/site-packages/ipywidgets_bokeh/kernel.py", line 75, in receive
bokeh_1 | self.parent.dispatch_shell(stream, msg_list)
bokeh_1 | TypeError: dispatch_shell() takes 2 positional arguments but 3 were given
bokeh_1 | 2021-07-15 14:47:29,177 [pid 6] 1 clients connected
The log above is printed out from the shell where the docker environament is running, and it is printed when the mouse is hovering the map widget. I noticed it while attempting to capture the cursor position on the map-canvas.
To reproduce the error I used the following code /app/main.py
:
from ipyleaflet import Map
from bokeh.plotting import curdoc
from ipywidgets_bokeh import IPyWidget
from bokeh.layouts import row, layout
curdoc_element = curdoc()
center = (52.204793, 360.121558)
m = Map(center=center, zoom=15)
wrap_map = IPyWidget(widget=m)
layout = row([wrap_map], height_policy='fit', sizing_mode='scale_both')
curdoc_element.add_root(layout)
below a dockerfile
to reproduce the environment I am using
FROM python:3.9-slim-buster
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y apt-utils build-essential
RUN apt-get install -y libproj-dev libgeos-dev proj-bin proj-data git
# Install dependencies:
COPY requirements.txt .
RUN pip install -U pip
RUN pip install ipyleaflet \
bokeh \
ipywidgets_bokeh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 7000
ENV ORIGIN="0.0.0.0:7000" PORT="7000" PREFIX="" LOG_LEVEL="debug"
ENTRYPOINT ["./entrypoint.sh"]
My Entry point looks like this:
bokeh serve --port ${PORT} --address 0.0.0.0 --allow-websocket-origin '*' ${PREFIX_PARAM} --log-level debug /app
Where app contains the python code (main.py)
Use ipykernel<6
. They switched the ipykernel implementation to asyncio
which means this package has to be rewritten.
Same as #30