Closed
Description
Validation is awesome, but if all the components are not defined upfront it must be disabled (eg when creating multi-page / multi-file apps).
It is possible to monkey-patch delayed validation. An example is below, but since the introduction of multi-output it is probably not correct. I find this extremely useful, as I always get the @app.callback
strings wrong, and even though immediate validation is best, this is much better than nothing.
Perhaps this could be added as a feature! (I of course leave the decision to accept/reject this proposal in your capable hands!)
import dash
_old_validate = dash.Dash._validate_callback
_list = []
def new_validate(self, output, inputs, state):
_list.append(tuple((output, inputs, state)))
dash.Dash._validate_callback = new_validate
def validate_callbacks(app):
from dash._utils import create_callback_id as _create_callback_id
old_map = app.callback_map
app.callback_map = {} # Monkey patch to trick Dash from raising DuplicateCallbackOutput
for output, inputs, state in _list:
_old_validate(app, output, inputs, state)
callback_id = _create_callback_id
app.callback_map = old_map
app = dash.Dash(__name__)
# After defining all the callbacks ...
validate_callbacks(app)
app.run_server(**CONFIG)
Metadata
Metadata
Assignees
Labels
No labels