Skip to content

Better error messages for st.cache#1146

Merged
tvst merged 33 commits intostreamlit:developfrom
tvst:hashtrace
Mar 11, 2020
Merged

Better error messages for st.cache#1146
tvst merged 33 commits intostreamlit:developfrom
tvst:hashtrace

Conversation

@tvst
Copy link
Copy Markdown
Contributor

@tvst tvst commented Feb 26, 2020

This does a few things (apologies for the big PR!)

  • Improves error messages for st.cache by including the cache stack and the hashing reason. In the process, I moved the place where we product the message strings inside the Exception classes, since they're not used anywhere else.
  • Makes hashing errors tell the user whether the hashing error occurred when hashing the arguments, the body, or the output. See the HashReason enum.
  • Makes UserHashError show up to the user not as UserHashError but as FooError, for whatever FooError was actually thrown under the hood. This way the error is easier to Google.
  • Makes st.cache warnings use Exceptions in order to produce a nice stack trace, and then makes them use st.exception() protos so their output looks more similar to the exception output. But since we want warnings to show up in yellow, this also adds an is_warning field to exception protos that lets us tweak colors on the frontend.

And some smaller things:

  • Makes st.exception() always read tracebacks from their input Exception, rather than allow people to pass their own exceptions (since that last code path was not used anywhere in the code).
  • Does some light refactoring: makes CodeHasher a tiny bit less complex by making it not hold a hasher object internally, moves hashing-related Exception classes from one file to another, renames a couple of variables, removes some Python 2 code, etc.
  • Make _HashStacks use weak references to threads rather than thread IDs, so avoid a memory leak when threads end.
  • Improves the CSS for code blocks and inline code inside exceptions.

@tvst tvst added WIP and removed WIP labels Feb 27, 2020
@tvst tvst removed the WIP label Feb 29, 2020
@tvst tvst marked this pull request as ready for review February 29, 2020 21:32
@tvst tvst requested a review from a team as a code owner February 29, 2020 21:32
@tvst tvst requested a review from jrhone February 29, 2020 21:32
@tvst tvst merged commit bebb41e into streamlit:develop Mar 11, 2020
@tvst tvst deleted the hashtrace branch March 11, 2020 19:06
tconkling added a commit to tconkling/streamlit that referenced this pull request Mar 11, 2020
* develop:
  Better error messages for st.cache (streamlit#1146)
  Fix st.cache (streamlit#1208)
  file_uploader: support for multiple files (streamlit#1183)
  Another attempt at test_multiple_scriptrunners timeouts (streamlit#1211)
  Speed up `make jstest` on CircleCI
  De-flake ScriptRunner_test.py (streamlit#1195)
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.

2 participants