Open daviddavo opened 2 years ago
You just have to put what we put in the regular boilerplate __init__.py
in your namespace.components.__init__.py
@T4rk1n Are you sure that'll work? Ever since moving html
, dcc
, and dash_table
into dash
(not a namespace package, but they are submodules) we need special handling of their files:
https://github.com/plotly/dash/blob/0df861f212cbd4a55dcbf77f64c1a1bffedb0bc7/dash/dash.py#L804-L812
Would be great if we could avoid that, and maybe it would address @daviddavo's use case as well? ie if these were registered like regular components they'd be picked up by get_all_scripts
:
https://github.com/plotly/dash/blob/0df861f212cbd4a55dcbf77f64c1a1bffedb0bc7/dash/dash.py#L800
Hmm, it's missing something to handle namespace.sub.bundle.js
in both frontend (needs a single namespace
without dots for the resolution) and backend (requires the dot/slash for serving the bundle).
@alexcjohnson Maybe we can add something like "resource_path": "package/subpackage"
and join the relative_package_path
from there if that key is present in the dist dict's ?
Yes, I've been trying a couple of hours multiple combinations of changing namespace names, using folders, etc. But there was no way...
Another option would be to explore the "package path" until we found the _js_dist, but I don't know if it would break some implementations.
Describe your context
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, whilemy_namespace.web
holds the dash application to show the data. I also created a new package to hold the components, calledmy_namespace.components
. This means that there's no__init__.py
inside themy_namespace
folder.I can import components like
from my_namespace.components import MyComponent
, but when I visit the webpage it raises anError: <my components namespace name> was not found
. This is because the script needed is not loaded. And the script is not loaded because the modulemy_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
anddash.dcc