Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dash suppress_callback_exceptions not working

Here is how I implement it in my code. I have tried each way individually and using all of them as uncommented lines of code. No matter the combination of methods I use, I still have to manually turn suppress errors once my dashboard loads.

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.title = 'TEST'

app.config['suppress_callback_exceptions'] = True
app.config.suppress_callback_exceptions = True

I have also tried (without any luck):

app = dash.Dash(__name__, external_stylesheets=external_stylesheets,
                suppress_callback_exceptions = True)

and

import sys
class HaltCallback(Exception):
    pass

@app.server.errorhandler(HaltCallback)
def handle_error(error):
    print(error, file=sys.stderr)
    return ('', 204)

Are there any other possible ways I can try to suppress the callback exceptions? I'm making a dashboard for my boss, so I'd really like automate the error suppression upon loading it.

like image 986
Nbishop Avatar asked Jan 02 '20 18:01

Nbishop


People also ask

How do dash callbacks work?

Whenever an input property changes, the function that the callback decorator wraps will get called automatically. Dash provides this callback function with the new value of the input property as its argument, and Dash updates the property of the output component with whatever was returned by the function.

Can you have multiple callbacks in dash?

If a Dash app has multiple callbacks, the dash-renderer requests callbacks to be executed based on whether or not they can be immediately executed with the newly changed inputs. If several inputs change simultaneously, then requests are made to execute them all.

What is Suppress_callback_exceptions?

suppress_callback_exceptions: check callbacks to ensure referenced IDs exist and props are valid. Set to True if your layout is dynamic, to bypass these checks. So there isn't really a difference in the examples you linked on their own.


1 Answers

For any future viewers: This bug was fixed some time after the question was posted.

The oldest answer does technically fix it, but it will also disable real callback errors along the way (that aren't fired on the start). If you are looking for where to put suppress_callback_exceptions=True, put it in the app declaration itself, like:
app = dash.Dash( ... , suppress_callback_exceptions=True).

like image 197
MilkyDeveloper Avatar answered Sep 19 '22 20:09

MilkyDeveloper