Hi, Dash is awesome, i try to better understand it.:
1: the suppress_callback_exceptions
seems legacy since the app.validation_layout, right? Can callbacks appear before the layout/validation layout are set? eg shuffle your example ( Layout for Multi-Page App Validation from https://dash.plotly.com/urls)
# Index callbacks
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == "/page-1":
return layout_page_1
elif pathname == "/page-2":
return layout_page_2
else:
return layout_index
# index layout
app.layout = url_bar_and_content_div
# "complete" layout
app.validation_layout = html.Div([
url_bar_and_content_div,
layout_index,
layout_page_1,
layout_page_2,
])
The doc remains silent on that:
New in Dash 1.12 You can set app.validation_layout to a “complete” layout that contains all the components you’ll use in any of the pages / sections. app.validation_layout must be a Dash component, not a function. Then set app.layout to just the index layout.
Q2: Can the id=
repeat across pages eg layout_page_1 and in layout_page_2?
Q3: Raise on non visible outputs. Shouldnt this raise since the page-2-display-value is not in the current layout when the page-1-interval is active/visible/firing?
@app.callback(Output('page-2-display-value', 'children'),
[Input('page-1-interval', 'n_intervals')])
def update_metrics(n):
import time
return time.time()
Q4: on run with $ gunicorn --workers=2 'dapp.main:get_server()
i wonder if it is thread safe due 2 workers?