question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Allowing native Bokeh server app support on Visual Studio Code

See original GitHub issue

My problem / request

Hi,

(This post is related to what I thought was a bug in the Jupyter extension of Visual Studio Code and is actually more of a missing feature in Bokeh)

I am working with Bokeh and Jupyter Notebooks in Visual Studio Code because, well … I like them. After a bit of fiddling with Server Apps for animated plots (following this example), I realised that they show no output in VSCode, and I did not see any error message while running the code.

Alternatives considered

I have run the code successfully in Jupyter Lab & Jupyter Notebook. So it is a VSCode+Bokeh problem.

What seems to be missing

Some people of the Jupyter Notebook community (thanks, @rchiodo !) have pointed me to the following error happening during the code execution (somehow I could not see it):

ERROR:bokeh.server.views.ws:Refusing websocket connection from Origin 'vscode-webview://8676e056-ff6e-461f-b0b9-4b600c50665f';                       use --allow-websocket-origin=8676e056-ff6e-461f-b0b9-4b600c50665f or set BOKEH_ALLOW_WS_ORIGIN=8676e056-ff6e-461f-b0b9-4b600c50665f to permit this; currently we allow origins {'localhost:8888'}
WARNING:tornado.access:403 GET /ws?platform=electron (::1) 1.00ms

Solving the issue

Is there any way we could :

  1. Allow the plots from VSCode on-the-fly using just show() ?
  2. Alternatively, provide a bit more info to the user on where to set these options either :
    • as a warning / message when the code is run,
    • as a additional comment in the last lines of the nice example from above,
    • or even in the documentation ?

Cheers,

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ddrinkacommented, Nov 29, 2022

@FilJed I haven’t come back around to this in a couple months, but according to @Hoxbro in https://github.com/holoviz/holoviews/pull/5398, the following should work now.

import holoviews as hv
import pandas as pd

hv.extension('bokeh')

import panel as pn
pn.config.comms = "vscode"  # <- this is needed for it to work

# creating a dataframe with both an int and an obj dtype
df = pd.DataFrame({
    'count':    [ 0,    1,    2 ], 
    'distance': [ 3,    4,    7 ],
    'length':   [ 5,  -20,   35 ]
})

# set up a DynamicMap where the user can select the y_axis column
y_dim = hv.Dimension('y_column', values=df.columns.tolist(), default='distance')

def return_scatter(col_name):
    return hv.Scatter(df, kdims='count', vdims=[col_name])

hv.DynamicMap(return_scatter, kdims=y_dim).opts(framewise=True, axiswise=True)
1reaction
ddrinkacommented, Sep 22, 2022

I’ve created https://github.com/holoviz/panel/issues/3876 to try to get Panel up and running. I’ll come back here to document a workaround for Bokeh interactivity if I’m able to get that sorted out over there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bokeh server — Bokeh 3.0.3 Documentation
The Bokeh server is a component of Bokeh that allows you to build interactive web applications that are connected to Python code running...
Read more >
Webview API - Visual Studio Code
The webview API allows extensions to create fully customizable views within ... to build complex user interfaces beyond what VS Code's native APIs...
Read more >
Can a Bokeh server be run in the Jupyter extension of VS Code?
It is not yet clear whether integration with VSCode is possible, or not. Bokeh expects to be able to make an HTTP connection...
Read more >
How to Build Interactive Data Visualizations for Python ... - InfoQ
Bokeh provides a Python API to create visual data applications in D3.js, without necessarily writing any JavaScript code. It allows the use ...
Read more >
Top JupyterLab Alternatives in 2022 - Slashdot
Visual LANSA includes features such as access Controls/Permissions, code ... Open-source web application, the Jupyter Notebook, allows you to create and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found