AnnMarieW / dash-multi-page-app-demos

Minimal examples of multi-page apps using Dash Pages
229 stars 53 forks source link

multi_page_sync_components - not reacting to page change #5

Open bartverweire opened 2 years ago

bartverweire commented 2 years ago

Hi,

The combination of dash_extensions with multipage doesn't seem to work. The app multi_page_sync_components runs, but doesn't react to a change of the page :

I'm pretty sure it's related to dash_extensions. When converting to a standard Dash application

from dash import Dash, page_registry, page_container, html, dcc

# from dash_extensions.enrich import (
#     DashProxy,
#     MultiplexerTransform,
#     html,
#     dcc,
# )

and

# app = DashProxy(
#     __name__,
#     transforms=[MultiplexerTransform()],
#     use_pages=True,
#     prevent_initial_callbacks=True,
#     suppress_callback_exceptions=True,
# )

app = Dash(__name__, use_pages=True)

changing the imports in the pages to

from dash import dcc, html, register_page, no_update, Output, Input, State, callback
# from dash_extensions.enrich import Output, Input, State, callback

in all of the pages

and also adding and referencing different dcc.Stores for and in each page (because MultiplexerTransform obviously won't work without dash_extensions), the app runs fine.

I'm working with python 3.6.13, and the following package versions (obtained by installing from the general requirements.txt file, (where dash_extensions is missing, btw.)

async-timeout==4.0.2
Brotli==1.0.9
click==8.0.4
colorama==0.4.4
contextvars==2.4
dash==2.6.2
dash-bootstrap-components==1.2.1
dash-bootstrap-templates==1.0.4
dash-core-components==2.0.0
dash-extensions==0.0.71
dash-html-components==2.0.0
dash-table==5.0.0
dataclasses==0.8
Deprecated==1.2.13
numpy==1.19.5
pandas==1.1.5
pytz==2022.5
redis==4.3.4
six==1.16.0
tenacity==8.1.0
wrapt==1.14.1
zipp==3.6.0

Kind Regards

Bart

bartverweire commented 2 years ago

I've tested this with a more recent version of python (and the packages), where it does work.

async-timeout==4.0.2
Brotli==1.0.9
cachelib==0.9.0
click==8.1.3
colorama==0.4.5
contextvars==2.4
dash==2.6.2
dash-bootstrap-components==1.2.1
dash-bootstrap-templates==1.0.7
dash-core-components==2.0.0
dash-extensions==0.1.6
dash-html-components==2.0.0
dash-table==5.0.0
dataclasses==0.6
Deprecated==1.2.13
diskcache==5.4.0
EditorConfig==0.12.3
Flask==2.1.2
Flask-Caching==2.0.0
Flask-Compress==1.13
Flask-Login==0.6.2
immutables==0.19
importlib-metadata==5.0.0
importlib-resources==5.10.0
itsdangerous==2.1.2
Jinja2==3.1.2
jsbeautifier==1.14.7
ldap3==2.9.1
MarkupSafe==2.1.1
more-itertools==8.14.0
numpy==1.23.4
packaging==21.3
pandas==1.5.1
plotly==5.10.0
pyasn1==0.4.8
pyparsing==3.0.9
python-dateutil==2.8.2
python-dotenv==0.21.0
pytz==2022.5
redis==4.3.4
six==1.16.0
tenacity==8.1.0
typing_extensions==4.4.0
Werkzeug==2.2.2
wrapt==1.14.1
zipp==3.10.0

So I guess it's only a matter of specifying the minimum required version of dash_extensions.

Kind Regards,

Bart

AnnMarieW commented 2 years ago

Hi @bartverweire

Thanks for reporting and finding the solution!

Feel free to do a PR to update the requirments.txt if you'd like to contribute. If not, no problem, I'll do an update in the next couple of days.

bartverweire commented 2 years ago

Hi @AnnMarieW

I've done some more tests, and found that the minimum version of dash-extensions is 0.1.1. I was also trying see how to put this in the requirements.txt file, and to create a PR. However, I'm stuck with a dependency issue with Flask-Caching (>=2.0.1 to make the caching demo work), as dash-extensions has a dependency on Flask-Caching==2.0.0

I've tried to run the multi_page_cache_background_callback demo with Flask-Caching==2.0.0, but that doesn't seem to work. And I'm not sure how to put all this in 1 requirements.txt file.

Any ideas ? Perhaps provide a dedicated requirements file per subproject ?

Bart

AnnMarieW commented 2 years ago

And I thought this was going to be easy :frowning: Thanks for narrowing down the issue. A dedicated requirements.txt per demo app could work, but people who want to use dash-extensions with the dash background callbacks might run into this problem.

@emilhe Hey Emil, Is it necessary to pin Flask-Caching to 2.0.0 in Dash Extensions? Can it be changed to 2.0.1 so it's compatible with dash background callbacks?

emilhe commented 2 years ago

@AnnMarieW I have previously had issues with updates in dependencies that introduced breaking changes. That's why the version is now pinned (at 2.0.0). I haven't tested 2.0.1, but assuming there are no breaking changes/new bugs in that release, I don't see any issues with updating, i.e. changing the pinning to 2.0.1 :)