đź“Ł Announcing Hot reload

@Philippe, it still not working for me the way it does in the gif example above. Do you have a code snippet that I can test this on to check if it is something maybe I’m doing wrong?

Did you upgrade dash to 0.29.0rc4 ? Any dash app code should work, just start the app with app.run_server(debug=True, threaded=True) and make modifications to the app or assets.

1 Like

I do, that said, it doesn’t seem to work in the way I thought it would. I still have to save the file whenever it reloads. From the gif, and the reload_interval params, it look like it is done automatically and doesn’t require saving.

Here is the app I’m trying this out on.

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(__name__)
app.layout = html.Div([
    html.Div(style={'height': '500'}),
    html.H1('Hello world!')
])
if __name__ == '__main__':
    app.run_server(debug=True, threaded=True)

Oh, it depends on the editor you are using, some editor do autosave and the reloader will pick it up. In the gif you can see the save before the reloading happen (there is a small circle in the editor tab).

Ah, yes. I see that now.

Seems like this doesn’t work with tabs though. When I’m on tab two and make an edit, the hot reload reopens to tab one again.

The state of the tab component is not kept when reloading, so it revert back to the default tab. I’ll try to keep the state, but it might go in another PR.

looks cool, will this be “pip install --upgrade” available sometime soon?

Yes, it will be released soon, probably next week.

1 Like

Hot reload has been released !

Use it with:
pip install dash==0.30.0
pip install dash-renderer==0.15.0

4 Likes

Really looking forward to using this. However, while I can get it to work in relatively simple applications no problem, I cannot seem to get it to work with a large, relatively complex app.

The app I am working on uses large files, multiple tabs, css sheets (in the assets folder), etc. Therefore, it can take some time to load in the browser. Is there a possibility that the reload is timing out?

In the browser window, I get:

Reloader failed after 9 times.
Please check your application for errors.

I have checked this both on Firefox and Chrome.

You can try setting the max_retry higher and the poll rate higher too if your application is long to start.

app.run_server(..., 
    dev_tools_hot_reload_interval=5000,
    dev_tools_hot_reload_max_retry=30
)
2 Likes

Yes! It was the max_retry that I was missing. (My editor does not autosave.) Very cool and huge time savings. Thanks for the fast response!

3 Likes

A post was split to a new topic: Hot Reload not working for me

@Philippe, not sure if you recall our convo here, but it was about allowing hot reload to maintain tab state.

Since I’m often working on different tabs that are not the default, my workaround has been to set the dcc.Tabs value property to whichever tab I’m working on at the moment and just make sure that I never commit that line or simply change/reset it when I’m done with that tab. Reason I bring this up is because it occurred to me that this could be a potential solution. I’m not sure how hot reload works under the hood, but wouldn’t it be possible to read the value property of tabs and set that value property on the reload?

Which IDEs does the hot relaod work on? I am using sypder and it’s not working.

Hi,
I have been using Dash for a while now (it’s really great :slight_smile: thanks for the hard work!) but I am now experiencing some problems with the hot reload feature. More specifically:

  • Up until dash==0.41, hot reload was almost fine (i.e. it was initially working correctly, but after the first “hot reload” it was stopping to work - see https://github.com/plotly/dash/issues/634)
  • From dash==0.42 to the current version (dash==0.43), hot reload starts submitting requests when the page is loaded, but it stops doing so as soon as the back end becomes -even just temporarily- unreachable (in my setup, this occurs every time a new version of the app is deployed). In other words, the dev_tools_hot_reload_max_retry keyword seems to be simply ignored since dash==0.42.

I face the same issue both in Chrome and in Firefox.
Any input would be really appreciated.
Cheers!

@Philippe Sorry for resurrecting this thread. When I searched hot-reload, this was what came up.

How do you add files to be watched for changes?

Its working for me I am using vscode with py 3.10 on brave browser