Pre-rendering Javascript powered visualizations in notebooks using nbconvert

16 views
Skip to first unread message

Güngör Budak

unread,
Aug 8, 2017, 3:17:41 AM8/8/17
to Project Jupyter
Hi,

I'm using bokeh to generate interactive visualizations and I want to pre-render / execute the notebooks I programmatically generate using "jupyter nbconvert --to notebook --execute notebook1.ipynb --output notebook1_output.ipynb". Although it seems it executes the cells but the outputs from JS powered visualizations are not stored in the executed notebook file and manual execution is required on the browser.

Is there a way to keep such outputs in the notebook files programmatically through Terminal?


Best
Gungor

Thomas Kluyver

unread,
Aug 8, 2017, 6:40:03 AM8/8/17
to Project Jupyter
Hi Güngör,

Their speculation in the later part of that thread is essentially correct. Nbconvert runs your Python code and produces the output, which from Jupyter's point of view is the Javascript Bokeh sends to produce the plots. That Javascript runs when you open the file in your browser, but at that point the Bokeh backend it needs to talk to is gone, so it can't display the plot.

If you need Javascript to execute while the kernel is running, you'll need to run it in a browser. Depending on your use case, that could mean automating a headless browser (using e.g. Selenium), or some extra Javascript running in a regular browser.

Thomas

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/9ac12388-61cf-4dd5-ae4d-7d5791650d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Güngör Budak

unread,
Aug 8, 2017, 9:37:52 AM8/8/17
to Project Jupyter
Hi Thomas,

It makes sense, thanks for the tips I'll try a headless browser

Best
Gungor


On Tuesday, August 8, 2017 at 1:40:03 PM UTC+3, takowl wrote:
Hi Güngör,

Their speculation in the later part of that thread is essentially correct. Nbconvert runs your Python code and produces the output, which from Jupyter's point of view is the Javascript Bokeh sends to produce the plots. That Javascript runs when you open the file in your browser, but at that point the Bokeh backend it needs to talk to is gone, so it can't display the plot.

If you need Javascript to execute while the kernel is running, you'll need to run it in a browser. Depending on your use case, that could mean automating a headless browser (using e.g. Selenium), or some extra Javascript running in a regular browser.

Thomas
On 8 August 2017 at 08:17, Güngör Budak <gng...@gmail.com> wrote:
Hi,

I'm using bokeh to generate interactive visualizations and I want to pre-render / execute the notebooks I programmatically generate using "jupyter nbconvert --to notebook --execute notebook1.ipynb --output notebook1_output.ipynb". Although it seems it executes the cells but the outputs from JS powered visualizations are not stored in the executed notebook file and manual execution is required on the browser.

Is there a way to keep such outputs in the notebook files programmatically through Terminal?


Best
Gungor

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages