Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plots missing after tab refresh in jupyterlab 0.33 #49

Closed
parente opened this issue Aug 1, 2018 · 10 comments · Fixed by bokeh/bokeh#9861 or #99
Closed

Plots missing after tab refresh in jupyterlab 0.33 #49

parente opened this issue Aug 1, 2018 · 10 comments · Fixed by bokeh/bokeh#9861 or #99

Comments

@parente
Copy link

parente commented Aug 1, 2018

  1. Install bokeh 0.12.16 or 0.13.0, jupyterlab_bokeh 0.6, and jupyterlab 0.33.
  2. Run the following in a notebook cell and see the plot show up as expected.
from bokeh.io import push_notebook, show, output_notebook
from bokeh.layouts import row
from bokeh.plotting import figure
output_notebook()

opts = dict(plot_width=250, plot_height=250, min_border=0)

p1 = figure(**opts)
r1 = p1.circle([1,2,3], [4,5,6], size=20)

p2 = figure(**opts)
r2 = p2.circle([1,2,3], [4,5,6], size=20)

# get a handle to update the shown cell with
t = show(row(p1, p2), notebook_handle=True)
  1. Refresh the browser tab.
  2. When Lab reloads, the plots are missing.
  3. Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing shows in the JS console instead.

The plots did reappear properly after refresh in lab 0.32 with jupyterlab_bokeh 0.5.

@canavandl
Copy link
Collaborator

canavandl commented Aug 1, 2018

Thanks for the quality report @parente


Upon further investigation, it appears that the issue is the ```bokeh.io.output_notebook``` call embeds some JS in the notebook as part of a mime bundle. When the page is reloaded, this JS is evaled before the notebook is rendered, so the BokehJS loading is stopped here: https://github.com/bokeh/bokeh/blob/13baccbb2835f7d5831c22b5cf68214e89c02618/bokeh/core/_templates/autoload_js.js#L79

@canavandl
Copy link
Collaborator

canavandl commented Oct 27, 2018

@parente a work-around is to use

from bokeh.plotting import output_notebook, figure, show

output_notebook(hide_banner=True)

which will load BokehJS without checking for the notebook content being reading, so that plots will render correctly on reloading.

@parente
Copy link
Author

parente commented Oct 30, 2018

Thanks @canavandl. That does indeed workaround the problem.

@bryevdv
Copy link
Member

bryevdv commented Jul 10, 2019

noting still an issue with 1.0.0next but workaround still works too

@cuspime
Copy link

cuspime commented Mar 30, 2020

I have a similar problem, when I refresh the page of my Jupyter notebook, no plots are shown.
As suggested, I am using

output_notebook(hide_banner=True)

But this does not solve the problem. I'd like the plots to show automatically in its latest state before refreshing, like matplotlib or seaborn do...

@bryevdv
Copy link
Member

bryevdv commented Mar 30, 2020

@cuspime certainly we would like that to work to, though please understand the situation is very different and much more complicated than with MPL or seaboard, which only store simple PNGs. Bokeh has an entire separate JavaScript runtime that needs to execute and re-constitute live interactive plots, and that has to integrate with the notebook/jupyterlab which itself is a huge and complicated JavaScript runtime.

This used to work. I am not sure what changed (on either side) to affect things. I will relay the same advice I did in #29 which is to raise a new issue (linked to this one) in the main Bokeh repo in order to raise the visibility on this issue (this repo does not see as much attention)

@mattpap
Copy link
Contributor

mattpap commented Mar 30, 2020

I did some debugging today and there are several issues that need resolving to make the broad problem go away. I also noticed that integration with jupyter widgets doesn't fully work after a reload (can't update state), which significantly raises the priority of this issue to me.

@bryevdv
Copy link
Member

bryevdv commented Apr 2, 2020

@mattpap did you mean to add this to 2.0.2? Or are we not tracking versions? (I have no idea what intentions here re: versioning this repo)

@mattpap
Copy link
Contributor

mattpap commented Apr 2, 2020

The intention is to have 2.0.1 of jupyter_bokeh as soon as I sort out new tokens.

@bryevdv
Copy link
Member

bryevdv commented Apr 2, 2020

I can add a new token to the vault if that's simplest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants