Search code examples
cachingstreamlit

Where does Streamlit store cached data when using persist="disk"?


I have the following error while changing the version of pandas between runs of Streamlit:

AttributeError: Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' from '/opt/conda/lib/python3.8/site-packages/pandas/_libs/internals.cpython-38-x86_64-linux-gnu.so'>

Since I am using @st.experimental_memo(show_spinner=False, max_entries=3, persist="disk") , it seems that pickled data persisted on disk is still being used, even after killing and reloading the Streamlit app. That is making the pickle manipulations fail.

How can I get rid of that error (or get rid of the cached data)?


Solution

  • The cached data is stored inside ~/.streamlit/cache:

    $ ls -al ~/.streamlit/cache
    -rw-rw-r-- 1 vvvvv vvvvv 444K nov.   3 16:43 3b9268941beaac500fe825eae1588edd-10e37a1e5ea7a25c0ce5eb261dc18d4d.memo
    -rw-rw-r-- 1 vvvvv vvvvv    4 nov.  10 16:20 3b9268941beaac500fe825eae1588edd-23e3001508dcffed68f049cb063bc262.memo
    -rw-rw-r-- 1 vvvvv vvvvv 428K nov.  10 16:20 3b9268941beaac500fe825eae1588edd-663346b0bef4b568b0833efd2d033bcf.memo
    -rw-rw-r-- 1 vvvvv vvvvv 428K nov.   3 16:44 3b9268941beaac500fe825eae1588edd-a0b908404721bc015e4b911157e41ad1.memo
    -rw-rw-r-- 1 vvvvv vvvvv    4 nov.   3 16:43 3b9268941beaac500fe825eae1588edd-e5ac73f7820ca5608235d6d5b20ee1cf.memo
    -rw-rw-r-- 1 vvvvv vvvvv    4 nov.   3 16:43 3b9268941beaac500fe825eae1588edd-f05dc4d32c92e4f1f8ca6f1074e7853e.memo
    

    Removing the files here solved my problem.

    I found the solution using snehankekre's answer on https://discuss.streamlit.io/t/where-data-is-cached/2931/4.


    Note: this solution worked in my case, but the cache could be used by more than one Streamlit app. Therefore, deleting all the files like this only works if only one app is using the cache.