jupyter-dash icon indicating copy to clipboard operation
jupyter-dash copied to clipboard

I would like to know if there is a way to refresh the jupyter dash server without restarting the kernel

Open mumususu opened this issue 3 years ago • 2 comments

I am using jupyter dash to make a dash project on a jupyter notebook. Every time I update my code, I have to kill the kernel and then restart the jupyter notebook to get the changed code to work properly. Otherwise, the dash page will show a double loading error. I would like to know if there is a way to refresh the jupyter dash server without restarting the kernel.

mumususu avatar Aug 15 '22 03:08 mumususu

Here is an unofficial workaround that seems to work for refreshing callback cells without restarting the kernel:

  1. Close any running Jupyter Notebook or JupyterLab instances
  2. Make a backup of the file ~/anaconda3/lib/python3.9/site-packages/jupyter_dash/jupyter_app.py (note: the path may differ depending on your system type and installation location of jupyter-dash)
  3. Open the original jupyter_app.py in a text editor
  4. Change the line: kwargs['dev_tools_hot_reload'] = mode == "external" to be kwargs['dev_tools_hot_reload'] = True and then save and close the file
  5. Reopen Jupyter Notebook or JupyterLab as usual

This uses the hot reload capability of Dash to allow you to edit and run Jupyter cells and then see the changes for any newly-drawn callbacks. Any HTML that is already rendered won't change, however. Perhaps the dash or jupyter-dash authors know of a way to safely refresh all rendered objects?

Also, note that jupyter_app.py mentions that enabling the code change above can sometimes cause Jupyter problems when there is no active kernel. I haven't encountered this issue yet.

jon-abbott avatar Sep 14 '22 00:09 jon-abbott

this might also be solved by https://github.com/plotly/jupyter-dash/pull/105

benedikt-budig avatar Jan 03 '23 14:01 benedikt-budig