At what point does st.cache() "undestand" that an uploaded file is indeed different?

Hi,

I have an app that works with tidy CSV files.

By chance I prepared two files that are almost identical. All that changed was the name of one column.

If realized that if I open one file, and then I rerun the app and open the other file, the cache does not “see” the difference, thinks that it is still the first file (that has a different column name) and the app fails.

I guess this is more a curiosity than a real problem because (i) probably files will be more different than this and (ii) maybe using the uploader widget to load a new file automatically “tells” the cache that there is a new file.

However since my two files are (a tiny bit) different, they should have a different hash, and I was surprised that I had fooled the cache.

Thanks for the great product

Fabio

Do you have two files that you can provide that demonstrate this behavior? It’s hard to answer questions like these, since the answer could easily be that you found a bug of some sort.

In general, getting a cached result happens when the exact same arguments are provided to a function. In the case of loading data, literally anything other than the same exact file should trigger a re-run.

Hi Randy,

Of course. They are two 14MB csv files. Identical except for the title of one column. I also thought that was interesting. How can I send them?

Thanks

Fabio

Hi @randyzwitch ,

This is the link to the dropbox transfer of the two files https://www.dropbox.com/t/If0gSnvFmg74tXCH

You can reproduce the error on my app. Steps:

  1. go to Get started. Clear the streamlit cache.

  2. in the “choose a sample dataset” dropdown choose the “08 CPG” file. 08 CPG and 09 CPG are our two almost identical files

  3. In the “show variance as” dropdown choose “after COGS”

  4. hit the :rocket: Submit button

  5. now go back up and select the “09 CPG” file from the dropdown

  6. set the “show variance as” menu as “after discounts”

  7. hit the :rocket: Submit button again

  8. You get a message that says there has been a problem and that to solve it you need to clear the cache

  9. clear the cache, submit again and it works

Best & thanks

Fabio