Apps keeps resetting and loosing imported files. Need to start again

Hello,

I have developed an app that basically does this:

  1. Import file 1 (csv)
  2. Import file 2 (csv or xlsx)
  3. Select needed columns from file1 and file2 and pass them as variables
  4. Does a bunch of operations
  5. Click a button to sequentially do a few different operations
  6. Click a button to generate export links

The problem that I currently have is that the app reset itself (need to re-enter file 1 and file 2) after item 3 or item 4 or item 5. It seems to be loading, calculating for a while and then it resets the page and I have to start the process all over again. Why is that and how can I fix it?
Thank you

I have a very similar issue where my data-cleaning app resets almost at random while people are working through pages. Any luck finding a solutions on this?

I am also running into the same issue. It’s really unpleasant that i have to reload the file and filter everything from the beginning.

Hi @Ummair_Radi, could you share a minimal reproducible example which shows this issue? That would make it easier to provide suggestions.

My application is a dashboard for a sales report. I use the file uploader to upload an Excel sheet, which then provides me with sidebar filters and charts. The issue is that the app will reset (similar to refreshing the website) and I will have to start over. It’s troublesome since I have so much data filtered that I have to redo it again.

I read somewhere here that many are facing the same issue, i use streamlit share for my app. not sure if there is a fix to it.

1 Like

Hi @Ummair_Radi, this might be a true bug that needs to be reported, or there might be a different way of building your app that will avoid this. But, in order to be able to figure that out, we need to have a reproducible example that demonstrates this issue. See this post for more details.

1 Like

you can check my code here if you like but that data is confidential because it’s a sales report, it has more than 40k rows in the excel file. if you see anything that could be changed or modified let me know. i tried using cache ttl but i am not sure what it really does but i saw some improvements. it will stay longer then the page will refresh/reset.

Hello @Ummair_Radi,

I tried using your code with an example excel file that I made, and couldn’t reproduce the issue. Can you please share some dummy data that I can use for the app, and explain the steps that reproduce the error?

Could you try using st.experimental_memo instead of st.cache? That’s the recommended way to cache data, rather than the deprecated st.cache.

Hi @blackary,

It seems that the app is behaving much better with st.experimental_memo. The issue is only seen on Streamlit Share. Locally, it works flawlessly.

The app resets on share every 20-25min, is that normal? I’m not sure if this is actually an error or just a cloud reset thing.

Here is a gif for when the app resets by itself. it will show connecting… then reloads the app

ezgif.com-gif-maker

Then i have to reupload the file and start from the beginning.

How about changing the program flow.

  1. Upload file.
  2. Get df and save to session variable
  3. Start the main and others.

When we interact on the widgets, etc., and possibly disconnects on the uploaded file [1], we always have the df in session variable.

Don’t do this:

if uploaded_file:
    # run stuff

Do like this:

if uploaded_file:
    # save df to session state variable
    st.session_state.df1 = df1

# Start main and others and use st.session_state.df1

# ---- SIDEBAR ----

...

# ---- MAINPAGE ----

...

If uploaded file is lost, it does not matter anymore, we already have the df in session variable.


  1. Isolating a possible issue on uploaded file persistence. I have experience something like this in the past that is the uploaded file is lost. ↩︎

1 Like