Nbconvert: Add ability to watch notebook files and convert automatically

Created on 8 Jun 2018  路  4Comments  路  Source: jupyter/nbconvert

My use case is using Jupyter Notebooks to create a slideshow. I am then periodically running:

jupyter nbconvert myfile.ipynb --to slides --post serve

This automatically opens a browser tab with the rendered slideshow in it. When I have made a change to the notebook file, I then have to close that browser tab, Ctrl-C on the nbconvert process in the terminal and run it again.

I would like to able able to run something like:

jupyter nbconvert myfile.ipynb --to slides --post serve --watch

which would track changes to the notebook file, automatically rerun the conversion and reload the slideshow in the browser to show the latest changes.

This would mean that I could simply leave that process running in the background while I am developing the material, and only have to deal with switching between the two windows to see the changes almost live.

Most helpful comment

Partial workaround: use entr for reloading. nbconvert doesn't support serving without opening a new browser tab, which means you will have another browser tab opened on each reload.

ls *.ipynb | entr -r jupyter nbconvert myfile.ipynb --to slides --post serve

All 4 comments

Partial workaround: use entr for reloading. nbconvert doesn't support serving without opening a new browser tab, which means you will have another browser tab opened on each reload.

ls *.ipynb | entr -r jupyter nbconvert myfile.ipynb --to slides --post serve

This can likely be done with Jupyter notebook's post save hooks.

@teodorlu did you find a way to have it not open a new browser tab at each save in the notebook? Thanks 馃檹

One can prevent the browser from opening with the following config setting.

c.ServePostProcessor.open_in_browser=False
Was this page helpful?
0 / 5 - 0 ratings