voila-dashboards / voila

Voilà turns Jupyter notebooks into standalone web applications
https://voila.readthedocs.io
Other
5.44k stars 504 forks source link

autoreload=True not working in Jupyter? #333

Open lmeyerov opened 5 years ago

lmeyerov commented 5 years ago

I expected, if I ran voila --autoreload=True my.ipynb , that saved edits to my.ipynb would cause, within 30s, the opened browser page to reload. Instead, the old page and cell values still appear.

I'm really trying to just get some sort of dashboard reload in general to reflect new DB values, so happy to achieve in another way as well. Manually refreshing appears to catch the latest ipynb, so maybe docs update to reflect this is autoreload-on-refresh and we insert some JS polling :)

Repro:

Install on OS X

# ! conda install -y -c conda-forge voila voila-gridstack
# ! jupyter serverextension enable voila --sys-prefix

Bash

voila dashboards/voila_test_app.ipynb --port 8866 --autoreload=True

Notebook

display(
    VBox([
        style_tag,
        banner_tag,
        HBox([box1_tag, box2_tag, box3_tag]),
        graph_html 
    ]))

Steps to repro:

jtpio commented 5 years ago

@lmeyerov how about using a custom template and add a bit of logic that will trigger the refresh?

setTimeout(() => {
  window.location.reload();
}, 30000); // refresh every 30s

Refreshing the page will catch the latest changes indeed (if they were saved).

Another way would be to use a browser extension for automatically refreshing a tab.

lmeyerov commented 5 years ago

I realized, even easier, we can just

display(HTML("<script>... </script>"))

This particular issue, in the end, seems to be more about:

(a) --autoreload docs are unclear to what it actually does -- not refreshing a dashboard on change ;-) -- so maybe the fix is revising the docs

(b) dashboards that refresh are a somewhat common use case. Not hard for web people, so maybe more of a docs thing as well

jtpio commented 5 years ago

(a) --autoreload docs are unclear to what it actually does -- not refreshing a dashboard on change ;-) -- so maybe the fix is revising the docs

Right, this option is a bit misleading. It is meant to be used for development, not for end users.

(b) dashboards that refresh are a somewhat common use case. Not hard for web people, so maybe more of a docs thing as well

That's a common use case indeed and can be added to the docs. Would you like to open a PR? :)

lmeyerov commented 5 years ago

I thought about production autoreload more, and it's a bit of an iceberg. E.g., need to autoheal when server goes down/up.

More on my mind is making a dashboard template more than a POC -- we ended up doing HTML(HTML(HTML(... and custom <style> . Only so many hours in a day!

jtpio commented 5 years ago

@lmeyerov did you experiment a bit more with auto refresh of dashboards?