I have a function like this:
@st.cache_data
def load_account_data(directory_path: str) -> pd.DataFrame:
…and a multiselect:
selected_types = st.sidebar.multiselect(
"Account Types",
all_types,
default=all_types,
)
I have a button to clear the account data cache, in the case of files on disk changing:
with st.sidebar:
if st.button("🔄 Reload Data", help="Reload all files from disk"):
load_account_data.clear()
st.success("Cache cleared! Data will be reloaded.")
st.rerun()
…but when I click this button, while it clears the cached function data, it also seems to totally screw up multiselect selections: they aren’t applied, but the multiselect element renders as if they were. To fix things, I have to remove and then re-add the selections.
I’m using streamlit v1.48.1. What am I doing wrong?