Errors with caching using st.experimental_memo

I am using @st.experimental_memo(ttl=300) on all functions per the documentation as I understand it. These functions are loading dataframes and displaying data in charts & tables so st.experimental_memo seemed like the best option, however I am now receiving errors whenever I change a streamlit input widget such as:

image

I did not receive these errors when using the standard @st.cache so I am very confused about the differences and how to best utilize @st.experimental_memo for this app.

Repo is located here .
App is located here .

Errors when adding/changing indicators:

KeyError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).

Traceback:
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 430, in _run_script
    exec(code, module.__dict__)File "/app/axe_cap_terminal/terminal.py", line 1325, in <module>
    main_chart = load_main_chart(df)File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/caching/cache_utils.py", line 145, in wrapper
    return get_or_create_cached_value()File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/caching/cache_utils.py", line 137, in get_or_create_cached_value
    return_value = func(*args, **kwargs)File "/app/axe_cap_terminal/terminal.py", line 634, in load_main_chart
    fig.add_trace(go.Scatter(x=df.index, y=df['Trail'], line={'color': 'orange'}, name='SwingArmsFlip'))File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 3458, in __getitem__
    indexer = self.columns.get_loc(key)File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc
    raise KeyError(key) from err

When observing the local console I see this is specifically related to the caching\cache_utils.py in Streamlit:

raise CacheKeyNotFoundError("Key not found in mem cache")
streamlit.caching.cache_errors.CacheKeyNotFoundError: Key not found in mem cache

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.