Hello everyone,
I have this app repository folder organization:
\
_init_.py
app.py
\pages
page1.py
page2.py
in app.py
I have of th app instantiation and cache setting:
dash_app =
Dash(
name,
use_pages=True,
pages_folder =str((Path(file).parent / ‘pages’).absolute()),
assets_folder= str((Path(file).parent / ‘assets’).absolute()),
prevent_initial_callbacks = True,
suppress_callback_exceptions = True,
external_stylesheets=[themes.BOOTSTRAP]
)
cache = Cache(dash_app.server, config={
‘CACHE_TYPE’: ‘FileSystemCache’,
‘CACHE_DIR’: ‘cache-directory’
})
and a cache function below the code above:
@cache.memoize(timeout=CACHE_TIMEOUT)
def compute_data():
return data
In pages\page1.py
I rgister the page of course but then I would also want to import and use the function compute data
.
I am struggling to make it work because i has ImportError caused by the thing that in app = Dash() all the pages are imported but the function `compute_data()´ is not yet defined,
so I get a final
ImportError cannot import compute_data from partially initialized module
Did it ever happened to you a similar multipage app an functions design?
Do someone have any sugestion on how to achieve possibility to use in pages callback functions defined in app.py
?
My idea would have been to init pages after the app= Dash() instantiation but at the moment it is not possible and if I implement modifications on a dash package fork, I thought I would lose all or I would have to manage all the future updates on the dash package.
Many thanks,
Nick