Using the same dataset across multi-page apps

I have a dashboard with around 5 pages structured as follows:

- app.py
- index.py
- apps
   |-- __init__.py
   |-- app1.py
   |-- app2.py
   |-- app3.py
   |-- app4.py
   |-- app5.py

The same dataset is used in each of these appX.py pages, so when I start the dashboard, python loads the dataset 5 times, one for each of the appX.py pages.

This is quite inefficient and slow, is there a way that I can read the dataset in once, and then make it available for all the pages in the dashboard?

1 Like

I also hate having to reload stuff. Try using Apache Ray or Plasma if the data is large: https://arrow.apache.org/docs/python/plasma.html#the-plasma-in-memory-object-store. Otherwise use Redis

I made https://github.com/russellromney/brain-plasma that adds a namespace to Plasma to persist Python objects in memory for any process/app to use, just by calling the nane. It’s pretty alpha right now but it’ll work with most objects.

hmmm thats a shame thats there is no easy way to do it. Thanks for those links though I’ll take a look

For anyone who finds this thread at a later date, I’ve discovered that this is possible!

See the Flask-Caching section of this page: https://dash.plot.ly/performance

1 Like