plotly / plotly/dash

Can't define components in submodules

Open
#2,236 5 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

Describe your context

dash==2.6.1
dash-bootstrap-components==1.2.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0

Describe the bug

I have an application that is deployed using a namespace package. It has multiple parts, and each of them is a different package, but all of them in the same namespace:

my_namespace.scripts holds data retrieval scripts, while my_namespace.web holds the dash application to show the data. I also created a new package to hold the components, called my_namespace.components. This means that there's no __init__.py inside the my_namespace folder.

I can import components like from my_namespace.components import MyComponent, but when I visit the webpage it raises an Error: <my components namespace name> was not found. This is because the script needed is not loaded. And the script is not loaded because the module my_namespace.components is not added to the registry (see line 38).

https://github.com/plotly/dash/blob/0df861f212cbd4a55dcbf77f64c1a1bffedb0bc7/dash/development/base_component.py#L33-L50

Expected behavior

To be able to define my components in a namespace package, like dash does with dash.html and dash.dcc

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 in dash/development/base_component.py around lines 33-50 and trace how component modules are added to the registry. Reproduce the failure with a namespace package containing my_namespace.components, then compare the behavior with dash.html and dash.dcc. Done means components in a namespace package are registered and their required script loads when the Dash page is visited.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
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.