You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
I very much agree, and in fact, have just submitted a proposed PR for doing this: #644.
I ended up taking the same basic approach as yours, but with some extra logic for detecting duplicated Outputs in callbacks (including handling multi-output callbacks). Feedback welcome!
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!)
The text was updated successfully, but these errors were encountered: