oegedijk / explainerdashboard

Quickly build Explainable AI dashboards that show the inner workings of so-called "blackbox" machine learning models.
http://explainerdashboard.readthedocs.io
MIT License
2.32k stars 332 forks source link

ExplainerHub fails to add dashboard via add_dashboard endpoint #269

Open gamis opened 1 year ago

gamis commented 1 year ago

Hi! Great library you have here, really enjoying it.

I'm trying to set up ExplainerHub with the add_dashboard_route, and it's not working. "ERROR: Failed to add dashboard!". If I print the traceback leading to that error, I get the trace below.

Any ideas?

Details

import explainerdashboard
db1 = explainerdashboard.ExplainerDashboard.from_config('ll_fce10_proc_20200227_100455_l1.yaml')
explainerdashboard.ExplainerHub([db1], add_dashboard_route=True).run(debug=False)

Starts up fine, I can load db1 fine, but when I got to add a second db via http://127.0.0.1:8050/add_dashboard/ll_fce10_proc_20200117_105803_l1.yaml, I get

traceback (most recent call last):
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\explainerdashboard\dashboards.py", line 2572, in add_dashboard
    dashboard_name = self.add_dashboard(
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\explainerdashboard\dashboards.py", line 1629, in add_dashboard
    ExplainerDashboard.from_config(
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\explainerdashboard\dashboards.py", line 943, in from_config
    return cls(explainer, tabs, **dashboard_params, **kwargs)
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\explainerdashboard\dashboards.py", line 687, in __init__
    self.app = self._get_dash_app()
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\explainerdashboard\dashboards.py", line 1180, in _get_dash_app
    app = dash.Dash(
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\dash\dash.py", line 504, in __init__
    self.init_app()
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\dash\dash.py", line 529, in init_app
    self.server.register_blueprint(
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\flask\scaffold.py", line 49, in wrapper_func
    self._check_setup_finished(f_name)
  File "G:\Temp\venvs\calciumexpansion_3_9_12\lib\site-packages\flask\app.py", line 722, in _check_setup_finished
    raise AssertionError(
AssertionError: The setup method 'register_blueprint' can no longer be called on the application. It has already handled its first request, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the application are done before running it.

The second board yaml is

dashboard:
  explainerfile: ll_fce10_proc_20200117_105803_l1.dill
  params:
    title: Model Explainer
    name: null
    description: "This dashboard shows the workings of a fitted\n            machine\
      \ learning model, and explains its predictions."
    simple: false
    hide_header: false
    header_hide_title: false
    header_hide_selector: false
    header_hide_download: false
    hide_poweredby: false
    block_selector_callbacks: false
    pos_label: null
    fluid: true
    mode: dash
    width: 1000
    height: 800
    bootstrap: null
    external_stylesheets: null
    url_base_pathname: null
    routes_pathname_prefix: null
    requests_pathname_prefix: null
    responsive: true
    logins: null
    port: 8050
    importances: true
    model_summary: true
    contributions: true
    whatif: true
    shap_dependence: true
    shap_interaction: true
    decision_trees: true
    kwargs: {}
    tabs: null