-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Flag 'suppress_callback_exceptions' not working as intended #3054
Comments
It looks like the error originates here, dash/dash/dash-renderer/src/actions/callbacks.ts Lines 109 to 126 in 0d9cd2c
Would it make sense to suppress this error similar to how it's done in
What do you think, T4rk1n? |
@emer-bestseller I think the parameter |
By the way, there is a trick to handle this kind of error with import dash
from dash import html
from dash.dependencies import Input, Output, ALL
app = dash.Dash(
__name__,
prevent_initial_callbacks=True,
suppress_callback_exceptions=True,
)
app.layout = html.Div(
[
html.Button(id="button", children="Button Exists"),
html.Div(id={"type": "exists", "index": "whatever"}),
]
)
@app.callback(
Output("exists", "children"),
Input("button", "n_clicks"),
Input({"type": "exists", "index": ALL}, "n_clicks"),
)
def on_click(_, __):
return "Hello world"
if __name__ == "__main__":
app.run(debug=True) |
Ah, so you're saying that it's in fact intended only to silence errors related to (initial) layout validation? In that case, I guess the code is correct, but that the documentation might need some clarification 👍 Reading through the source code, I also started to think about the "hack" of using an ALL wildcard to circumvent the issue. I guess that could be a workaround. Introducing pattern matching callback does increase code complexity somewhat though (partly in syntax, partly in concept; by adding an ALL wildcard the code suggests that there can be multiple elements while in fact the intent is that there will always be exactly one - or zero, of course), so maybe it would make sense to have (another?) flag to silence the exception mentioned in the issue? (: I don't see any immediate downside of introducing such a flag / allowing these kind of dynamic layout constructs. |
Describe your context
Describe the bug
The
suppress_callback_exceptions
doesn't seem to be working as intended. If I run this MWE,and click the button, I get a console error,
Expected behavior
As per the documentation, if this flag is set, I would expect the callback simply to not fire (and thus no errors to be raised).
https://dash.plotly.com/callback-gotchas
Screenshots
The text was updated successfully, but these errors were encountered: