-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Breaking change for chained callbacks in dash>=2.9.0 #2767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @nicolearksey1, reaching out on this bug report as a DE customer is expecting a quick turnaround, i.e. 2 days. I know this is unrealistic, but wanted to make sure this is on your radar. Might we be able to accelerate this fix to some reasonable time frame and provide them an SLA for a patch release. cc: @mjainGH |
@michaelbabyn found that this change could be the cause: #1519 (this was merged in 2.7.1: Line 267 in 6b31a8f
|
I modified Celia's example slightly so that it reproduces the desired behaviour in 2.7.0 but it breaks in 2.7.1 from dash import Output, Input, html, dcc, ctx, callback
from dash_iconify import DashIconify
import dash_mantine_components as dmc
import time
import dash
import random
app = dash.Dash(__name__)
app.layout = dmc.NotificationsProvider(
html.Div(
[
html.Button("click", id="btn-start"),
html.Button("stop", id="btn-stop"), # style={'display': 'none'}),
html.Div(id="notify-container"),
html.Div(id="intermediate-value", style={"display": "none"}),
]
)
)
# start button updates intermediate value
@callback(
Output("intermediate-value", "children"),
Input("btn-start", "n_clicks"),
prevent_initial_call=True,
)
def start_process(n_clicks):
print("CALLBACK 0")
return n_clicks
@callback(
Output("btn-stop", "n_clicks"),
Input("intermediate-value", "children"),
)
def make_api_call(nc1):
# print("CALLBACK 1")
# print(f"nc1: {nc1}")
changed_id = [p["prop_id"] for p in ctx.triggered][0]
if "intermediate" in changed_id:
# making api call
print("api call")
time.sleep(3)
return nc1
# else :
# return dash.no_update
@callback(
Output("notify-container", "children"),
Input("btn-start", "n_clicks"),
Input("btn-stop", "n_clicks"),
# prevent_initial_call=True,
)
def notify(nc1, nc2):
# print("CALLBACK 2")
button_id = [p["prop_id"] for p in dash.callback_context.triggered][0]
if "start" in button_id:
return dmc.Notification(
id="my-notification",
title="Process initiated",
message="The process has started.",
loading=True,
color="orange",
action="show",
autoClose=False,
disallowClose=True,
)
elif "stop" in button_id:
return dmc.Notification(
id="my-notification",
title="Data loaded",
message="The process has started.",
color="green",
# action="show",
action="update",
icon=DashIconify(icon="akar-icons:circle-check"),
)
else:
return dash.no_update
if __name__ == "__main__":
app.run(debug=True, port=8021)
|
See Slack thread for additional details. |
@celia-lm Is this issue closed by using the callback |
Describe the bug
"Click" button is the Input for two callbacks. When we click it, both should be triggered:
Screen.Recording.2024-02-21.at.17.28.05.mov
The developer who reported this experienced after upgrading from dash==2.6.2 to dash==2.15.0.
Hypothesis: this might be due to the 2.9.0 changes to accommodate duplicate outputs.
Code to reproduce the issue:
Expected behavior
"Click" button should trigger both callbacks at the same time, which would result in "Progress" notification showing immediately and lasting 3 seconds, and then "Complete" notification replacing it:
Screen.Recording.2024-02-21.at.17.22.04.mov
This behaviour can be reproduced with dash>=2.9.x if we use duplicate outputs, but for users this would mean rewriting several callbacks, as this would be a breaking change otherwise:
Describe your context
pip list | grep dash
belowThe text was updated successfully, but these errors were encountered: