'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.



Solution 1:[1]

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).

Solution 2:[2]

Figured it out

if __name__ == '__main__':
    app.run_server(debug=False,dev_tools_ui=False,dev_tools_props_check=False)

Needed to just disable dev_tools_ui on the actual webpage

Solution 3:[3]

When I ran into this problem, I had to place the config statement immediately after the app creation to suppress the errors. For example:

app=dash.Dash(__name__)
app.config.suppress_callback_exceptions=True

Found my answer here and it worked for me.

Solution 4:[4]

Just to complete the answers given:

app = dash.Dash( ... , suppress_callback_exceptions=True) works well for normal callbacks. If you have a long_callback you also need to provide a validation_layout that contains all of the components referenced by callbacks in the app and set the prevent_initial_call=True argument of app.long_callback.

For more information and examples please refer to the official documentation of long callbacks:
https://dash.plotly.com/long-callbacks#limitations

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zcoop98
Solution 2 Nbishop
Solution 3 zcoop98
Solution 4 Florian