Skip to content

Warn when calling st.foo from within st.cache#185

Merged
tvst merged 11 commits intostreamlit:developfrom
tconkling:tim/StCacheWriteError
Sep 27, 2019
Merged

Warn when calling st.foo from within st.cache#185
tvst merged 11 commits intostreamlit:developfrom
tconkling:tim/StCacheWriteError

Conversation

@tconkling
Copy link
Copy Markdown
Contributor

@tconkling tconkling commented Sep 24, 2019

When a script calls a st.foo from within a cached function, show an st.warning telling the user that they probably don't want to do that.

You can do st.cache(supress_st_warning=True) to suppress the warning.

This PR adds a thread local that contains some information about whether we're inside a cached function. There's some additional complexity around suppressing warnings in places where st calls can happen automatically (e.g. st.cache's wrapper function can call st.spinner).

Fixes #139


  • By checking this box, I agree that all contributions to this project are made under the Apache 2.0 license.

* develop:
  Release 0.46.0 (streamlit#170)
  Magic fixes (streamlit#138)
  [docs] Add analytics; redirect /secret/docs; fix compilation problem (streamlit#149)
  Fix bug for startup under windows (streamlit#144)
  Responsive layout (streamlit#104)
  Add basic PR template
  Better method signatures (streamlit#88)
  Publish docs to both /docs and /secret/docs, until we deprecate /secret/docs in January. (streamlit#141)
  Rename/report2app (streamlit#126)
@tconkling tconkling requested review from monchier and tvst September 24, 2019 23:47
@tconkling tconkling marked this pull request as ready for review September 24, 2019 23:47
# By Jonathan Rhone (3) and others
# Via GitHub
* develop:
  Text changes in ☰ menu and several CLI prompts (streamlit#180)
  add format option for slider widget and return texts for display values (streamlit#154)
  Merge ForwardMsg caching into develop  (streamlit#178)
  e2e test for magic (streamlit#172)
  Bart example update (streamlit#179)
  Pedantic CircleCI cleanup (streamlit#174)
  Fix overwriting elements in the sidebar (streamlit#181)
  update vega lite chart snapshot (streamlit#183)
  Stop react-markdown from converting "[foo]" to a link. (streamlit#151)
  Issue 1204: Graphs using Vega-Lite (streamlit#56)
  Removing uber demo from streamlit repo (streamlit#159)

# Conflicts:
#	lib/streamlit/DeltaGenerator.py
@tconkling tconkling changed the title Tim/st cache write error Warn when calling st.foo from within st.cache Sep 25, 2019
@tvst tvst merged commit 78f9b97 into streamlit:develop Sep 27, 2019
@tconkling tconkling deleted the tim/StCacheWriteError branch October 1, 2019 15:19
@afza1 afza1 mentioned this pull request Jul 10, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling st.write etc. in st.cache should throw an exception.

2 participants