šŸ“£ Dash 2.5 Released - Easier Multi-Page Apps, Component Properties

You’re welcome - on re-reading my stream of thoughts it may have come across more negatively than I intended. So I want to be clear that there are some great aspects to them, and I would like to see some more videos on the more technical aspects of dash, and I’m sure that kind of content is very useful for a lot of people.

2 Likes

I’d like to check - to avoid loading data for all pages every time the server is run, it’d be best to load data on individual page refresh?

e.g. if I have 20 pages, I’d want to avoid loading data in all 20 pages everytime i run app.run_server, right?

I put the dcc.store in the app.py page so changing pages does not trigger a collection

1 Like

Is the new multi-page app compatible with long callbacks? I’ve seen the warnings about circular imports of app, but I don’t believe there is a @dash.long_callback equivalent of @dash.callback.

In my content .py file under /pages directory, I also tried the following, however the input object to the callback cannot be found.

app = dash.get_app()
@app.long_callback(...)
def my_callback():
    pass

hi @TimW Tim,
:wave: welcome to the Dash community.

Currently this is not possible, however, this should change within one week. With the new Dash release, this will be possible. Stay tuned.

1 Like

I notice dcc_link() and dcc_location() are in Dash v1.1.2 for Julia. I realize Python is where the community is at and this is where the excitement is. I use Julia because of its typing and performance for large datasets. Could you roughly describe how much work it would be if a contributor were to bring multiple pages to Dash.jl?

hi Kirby,
Thank you for your interest and the suggestion. I wrote you a private message to continue the conversation there.

Instantiating Dash (app variable) with use_pages = True takes quite long before the Flask app is served. I guess as this is necessary to traverse the pages folder to find which pages to use. I’ve tested it, and it’s 3 seconds vs ~35 seconds (should be dependent on how many pages/folders present.)

Is there any way to speed this up?

1 Like

Hi @etjkai

If you are checking the performance of the app and just running it with use_pages=True, or use_pages=False then yes I would expect to see a performance difference, especially if you have many pages in the pages folder, or certain pages are slow to load.

However I would expect similar performance if you compare the app with use_pages=True, and an app made the ā€œoldā€ way with manually importing each layout from the pages folder and creating the callback for the routing of each layout.

There may be ways to speed up the performance, but it would be helpful if you could narrow down which files are the slowest to load.

1 Like

Understandable - it does make sense to me. Wondering if there’s any way to filter down the files that it looks through - would hate it if the app is looking through the pesky pycache folders that are autogenerated.

Will try to remove all but 1 page, and see how that improves loading speeds.

In either 2.5.1 or 2.6 any files that begin with . are excluded, so that shouldn’t be an issue

It seems like it’s the way I’m loading my initial data files that is the cause of the slowness…

On a related, but separate note, is there anyway to use cProfile with Dash with pages? My app runs fine normally, but when I use python -m cProfile app.py, it shows an error

Exception:
    A folder called pages does not exist.
    If a folder for pages is not required in your application, set `pages_folder=""`
    For example, `app = Dash(__name__,  pages_folder="")

I do have a pages folder present, so I’m not too sure how to proceed from this.