positron icon indicating copy to clipboard operation
positron copied to clipboard

Bokeh support

Open nstrayer opened this issue 1 year ago • 2 comments

A sub-issue of #1924 Currently, bokeh plots don't work as one would hope.

If running plain bokeh plot code: e.g.

from bokeh.plotting import figure, show
p = figure(title="Simple line example", x_axis_label='x', y_axis_label='y')
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], legend_label="Temp.", line_width=2)
show(p)

The plot shows up, but in an external browser window: image

If you try and get clever and use the notebook mode things get even less useful:

from bokeh.io import output_notebook
from bokeh.plotting import figure, show
output_notebook()
p = figure(title="Simple line example", x_axis_label='x', y_axis_label='y')
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], legend_label="Temp.", line_width=2)
show(p)
image (Note the two empty plot examples that have shown up.)

The error that appears in the javascript/webview developer console is the helpful:

Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing

nstrayer avatar Jul 22 '24 20:07 nstrayer

It's worth checking if this works in VSCode. If so, we may just need to wire something up properly (probably in the notebook output webview service or positron notebook controllers).

seeM avatar Jul 23 '24 15:07 seeM

Using vscode the plain bokeh plot output opens in an external browser as well.

Image

nstrayer avatar Jul 29 '24 17:07 nstrayer

(To be clear, calling output_notebook() first does allow one to render a bokeh plot inline via the interactive terminal)

peekxc avatar Jul 30 '24 17:07 peekxc

Verified Fixed

Positron Version(s) : 2024.07.0-125
OS Version          : OSX

Test scenario(s)

Verified fixed using original filing criteria. Will keep an open for dialog related functionality with upcoming tickets.

Link(s) to TestRail test cases run or created: N/A

testlabauto avatar Aug 01 '24 20:08 testlabauto

This doesn't seem to work on windows. The sample code results in:

{
	"name": "PermissionError",
	"message": "[Errno 13] Permission denied: 'c:\\\\Program Files\\\\Positron\\\\resources\\\\app\\\\extensions\\\\positron-python\\\\python_files\\\\positron\\\\positron_language_server.html'",
	"stack": "---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
Cell In[1], line 4
      2 p = figure(title=\"Simple line example\", x_axis_label='x', y_axis_label='y')
      3 p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], legend_label=\"Temp.\", line_width=2)
----> 4 show(p)

File ~\\.pyenv\\pyenv-win\\versions\\3.12.2\\Lib\\site-packages\\bokeh\\io\\showing.py:147, in show(obj, browser, new, notebook_handle, notebook_url, **kwargs)
    144 state = curstate()
    146 if isinstance(obj, UIElement):
--> 147     return _show_with_state(obj, state, browser, new, notebook_handle=notebook_handle)
    149 def is_application(obj: Any) -> TypeGuard[Application]:
    150     return getattr(obj, '_is_a_bokeh_application_class', False)

File ~\\.pyenv\\pyenv-win\\versions\\3.12.2\\Lib\\site-packages\\bokeh\\io\\showing.py:198, in _show_with_state(obj, state, browser, new, notebook_handle)
    195     shown = True
    197 if state.file or not shown:
--> 198     _show_file_with_state(obj, state, new, controller)
    200 return comms_handle

File ~\\.pyenv\\pyenv-win\\versions\\3.12.2\\Lib\\site-packages\\bokeh\\io\\showing.py:179, in _show_file_with_state(obj, state, new, controller)
    175 def _show_file_with_state(obj: UIElement, state: State, new: BrowserTarget, controller: BrowserLike) -> None:
    176     '''
    177 
    178     '''
--> 179     filename = save(obj, state=state)
    180     controller.open(\"file://\" + filename, new=NEW_PARAM[new])

File ~\\.pyenv\\pyenv-win\\versions\\3.12.2\\Lib\\site-packages\\bokeh\\io\\saving.py:98, in save(obj, filename, resources, title, template, state)
     95 theme = state.document.theme
     97 filename, resources, title = _get_save_args(state, filename, resources, title)
---> 98 _save_helper(obj, filename, resources, title, template, theme)
     99 return abspath(expanduser(filename))

File ~\\.pyenv\\pyenv-win\\versions\\3.12.2\\Lib\\site-packages\\bokeh\\io\\saving.py:166, in _save_helper(obj, filename, resources, title, template, theme)
    163 from ..embed import file_html
    164 html = file_html(obj, resources=resources, title=title, template=template or FILE, theme=theme)
--> 166 with open(filename, mode=\"w\", encoding=\"utf-8\") as f:
    167     f.write(html)

PermissionError: [Errno 13] Permission denied: 'c:\\\\Program Files\\\\Positron\\\\resources\\\\app\\\\extensions\\\\positron-python\\\\python_files\\\\positron\\\\positron_language_server.html'"
}

jonvanausdeln avatar Aug 19 '24 15:08 jonvanausdeln