code-server icon indicating copy to clipboard operation
code-server copied to clipboard

HoloViews/ hvplot not working in code-server Jupyter Notebook on Binder

Open MarcSkovMadsen opened this issue 4 years ago • 6 comments

CROSSPOST OF: https://github.com/holoviz/holoviews/issues/5182

I'm trying to create a nice repository for me and Sophia M Yang for a blog post and tutorial. I would also like to show case that the HoloViz ecosystem works with VS Code. So I added the code-server to the Binder environment.

Unfortunately it seems not to work

Reproducible Steps

https://user-images.githubusercontent.com/42288570/149618402-0d65e26d-c85d-435c-8c28-8a6b34981754.mp4 (The video is speeded up with a factor 1.7)

Repo: https://github.com/MarcSkovMadsen/hvplot_interactive commit 3cd8bf19dc326a76efe20e2dd3fedb7f1ff6e6af

  • Open https://mybinder.org/v2/gh/marcskovmadsen/hvplot_interactive/3cd8bf19dc326a76efe20e2dd3fedb7f1ff6e6af
  • Open VS Code
  • View Output - Jupyter to see log message
  • Create a new notebook
  • Make sure the kernel is notebook
print('hello')
import hvplot.pandas

Notice how it took a long time to execute this cell

print('hello')

Notice the console how you get an error message as you print hello.

import holoviews as hv

hv.extension("bokeh")

In the video this load pretty quickly (8secs) but I've also experienced it running for minutes before I've given up.

import panel as pn

It stopped working.

Versions

jupyter_bokeh bokeh Version: 0.12.6 Name: holoviews Version: 1.14.7 Name: hvplot Version: 0.7.3 Name: ipykernel Version: 6.7.0 Name: jupyter-bokeh Version: 3.0.4 Name: bokeh Version: 2.4.2 python Python 3.7.12 Python VS Code extension Version: ms-python v2021.12.1559732655 Jupyter VS Code extension Version: ms-toolsai v2021.11.1001552333 code-server Version: 4.0.1 735c6da829535969ff7193c79379299e4a1cb9bc

Log for Output - Jupyter window

stacktrace.txt

Additional Context

  • I don't experience the same problems in "real" VS Code on my laptop.
  • I experience similar problems on my Jupyter Hub for work where code-server is also running.

MarcSkovMadsen avatar Jan 15 '22 10:01 MarcSkovMadsen

Thanks for the report and URL to reproduce. Unfortunately I'm not a user of Jupyter Notebook, Binder and don't write Python regularly so I'm not sure what to expect here?

I did try following your steps and I'm seeing some errors but I'm not sure what HoloViews is or how hvplot is supposed to work.

image

Can you elaborate on what you expect? I don't see anything specific that could cause this but it's also very hard to isolate the problem because they are so many variables at play. I noticed you said to use notebook for the kernel and it is provided by conda. Have you tried removing conda from the equation?

jsjoeio avatar Jan 18 '22 20:01 jsjoeio

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

stale[bot] avatar Jul 17 '22 21:07 stale[bot]

I did a quick check at https://demo.jupyter.b-data.ch (Image R (verse:latest) + code-server).

When a cell does not finish executing, i see the following in the container log over and over again:

[I 2022-07-22 13:18:43.962 SingleUserLabApp log:189] 101 GET /user/benz0li/code-server/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false (benz0li@[redacted]) 2.91ms
[I 2022-07-22 13:18:43.962 SingleUserLabApp handlers:432] Trying to establish websocket connection to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[I 2022-07-22 13:18:43.968 SingleUserLabApp handlers:439] Websocket connection established to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[13:18:44] [127.0.0.1][c68db751][ExtensionHostConnection] The client has reconnected.

benz0li avatar Jul 22 '22 11:07 benz0li

When executing cell by cell

import holoviews as hv

hv.extension("bokeh")

leads to

[I 2022-07-22 13:31:42.510 SingleUserLabApp log:189] 101 GET /user/benz0li/code-server/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false (benz0li@[redacted]) 4.80ms
[I 2022-07-22 13:31:42.511 SingleUserLabApp handlers:432] Trying to establish websocket connection to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[I 2022-07-22 13:31:42.517 SingleUserLabApp handlers:439] Websocket connection established to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[13:31:42] [127.0.0.1][aa56c074][ExtensionHostConnection] The client has reconnected.
[E 2022-07-22 13:31:44.101 SingleUserLabApp websocket:1578] Uncaught exception
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/dist-packages/tornado/websocket.py", line 635, in _run_callback
        result = callback(*args, **kwargs)
      File "/usr/local/lib/python3.9/dist-packages/tornado/websocket.py", line 1523, in on_message
        return self._on_message(message)
      File "/usr/local/lib/python3.9/dist-packages/tornado/websocket.py", line 1529, in _on_message
        self._on_message_callback(message)
      File "/usr/local/lib/python3.9/dist-packages/jupyter_server_proxy/handlers.py", line 420, in message_cb
        self.write_message(message, binary=isinstance(message, bytes))
      File "/usr/local/lib/python3.9/dist-packages/tornado/websocket.py", line 336, in write_message
        raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
[I 2022-07-22 13:31:44.411 SingleUserLabApp log:189] 101 GET /user/benz0li/code-server/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false (benz0li@[redacted]) 2.64ms
[I 2022-07-22 13:31:44.411 SingleUserLabApp handlers:432] Trying to establish websocket connection to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[I 2022-07-22 13:31:44.416 SingleUserLabApp handlers:439] Websocket connection established to ws://localhost:33777/stable-30d9c6cd9483b2cc586687151bcbcd635f373630?type=ExtensionHost&reconnectionToken=[redacted]&reconnection=true&skipWebSocketFrames=false
[13:31:44] [127.0.0.1][aa56c074][ExtensionHostConnection] The client has reconnected.

with the last four lines repeating over and over again.

benz0li avatar Jul 22 '22 11:07 benz0li

Nice find! Well at least we can reproduce this consistently.

jsjoeio avatar Jul 22 '22 17:07 jsjoeio

One can reproduce this locally with docker, too.

Initial startup:

docker run -it --rm -p 8888:8888 -v $PWD:/home/jovyan -e GEN_CERT=yes registry.gitlab.b-data.ch/jupyterlab/r/verse

Subsequent startups:

docker run -it --rm -p 8888:8888 -v $PWD:/home/jovyan registry.gitlab.b-data.ch/jupyterlab/r/verse start-notebook.sh --NotebookApp.certfile=~/.local/share/jupyter/notebook.pem

Run the initial command in an empty directory so that the container populates it. Visit https://127.0.0.1:8888/lab?token=<token> in a browser to load JupyterLab.

benz0li avatar Jul 23 '22 07:07 benz0li