Is there an IDE for Dash? There’re a lot of toggles from the dash_core_components
that I would like to get familiar with, but it is such a hassle to reload the server every time I make a minor change or edit.
Any other suggestions would be appreciated as well.
Thanks,
Maxim
There isn’t, but there might be in the future. For now, one way to do do development a little bit faster is to use the Interval
component to refresh your content ever e.g. 500ms.
Here’s an example:
import dash
from dash.dependencies import Event, Input, Output
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
# Edit this object!
layout = html.Div([
html.H1('Hello Dash!'),
html.H3('Dash with live-reload'),
])
# Barebones layout
app.layout = html.Div([
dcc.Interval(id='refresh', interval=200),
html.Div(id='content', className="container")
])
# Update the `content` div with the `layout` object.
# When you save this file, `debug=True` will re-run
# this script, serving the new layout
@app.callback(
Output('content', 'children'),
events=[Event('refresh', 'interval')])
def display_layout():
return layout
app.css.append_css({"external_url": "https://codepen.io/chriddyp/pen/bWLwgP.css"})
if __name__ == '__main__':
app.run_server(debug=True)
1 Like
Ahh yes, that is exactly what I was looking for. Thanks @chriddyp
*Well not exactly, but still get the job done. Though, I think the future possibility of having one sounds exciting.
1 Like
@chriddyp, just one more question. Why when I plug in your code I get an error(see below), but when I take out debug=True
from app.run_server(debug=True)
, I get no issues? Should I be worried about leaving that out?
Thanks,
Maxim
* Restarting with stat
* Debugger is active!
* Debugger PIN: 106-069-239
* Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
* Detected change in 'C:\\Users\\mkupfer\\Coding\\interactive_dash\\i
-dash-session-DEMO.py', reloading
* Restarting with stat
* Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
@mbkupfer - Good question. These actually aren’t errors or issues, they’re just “informative messages”. Keep debug=True
in there, it will automatically restart the server whenever you save your file (that’s what the "Detected change in '...', reloading"
message is trying to tell you). This is much easier than stopping the server (with CTRL+C
) and restarting it every time.
@chriddyp, thanks for clarifying!
Another heads up: if you save the file with a syntax error such as not closing with a (comma), it looks like the program irreversibly crashes and the server has to be reloaded. Any chance that could be fixed?
Unfortunately, probably not. We’re just using the underlying debugger provided by the Flask project.
I spoke too soon. It looks like someone made a flask package that gets around this: https://github.com/mgood/flask-failsafe. I haven’t used it myself.
Hi Chris, this is a cool function. Is there any update from this?
Thanks for all,
regards from Argentina.
the feature that this thread talks about were implemented into the core library about 18 months ago - it’s the “dash hot reloading” feature
Ohhh great! Im going to give it a try now.
Thanks so much.