plotly / plotly/dash

problem with ComponentRegistry and late imports

Open
#514 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Late imports of components libraries are not served on the index if the app has already started.

Example

import dash
import dash_html_components as html

from dash.exceptions import PreventUpdate
from dash.dependencies import Output, Input

app = dash.Dash(__name__)
app.layout = html.Div([
    html.Button('click', id='click'),
    html.Div(id='output')
])


@app.callback(Output('output', 'children'), [Input('click', 'n_clicks')])
def on_click(n_clicks):
    if n_clicks is None:
        raise PreventUpdate

    import dash_core_components as dcc

    return dcc.Input(id='input', value='my-value')


if __name__ == '__main__':
    app.run_server(debug=True, port=8051)


The button will not be inserted and the console show error:

Error: dash_core_components was not found.

https://github.com/T4rk1n/pytest-dash/issues/15

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ComponentRegistry and the index-serving path, then reproduce the provided callback example with a late import of dash_core_components. Done means the dynamically returned component is served after the app starts and the button inserts it without the “dash_core_components was not found” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.