-
Notifications
You must be signed in to change notification settings - Fork 4k
Handle different Caching error messages #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| pass | ||
|
|
||
|
|
||
| class StreamlitAPIException(MarkdownFormattedException): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of the docs should move to the Markdown class above:
Instances of this class can use markdown in their messages, which will get nicely formatted on the frontend
| pass | ||
|
|
||
|
|
||
| class InternalHashError(MarkdownFormattedException): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring. Something like:
Exception in Streamlit hashing code (i.e. not a user error)
|
|
||
| def _hashing_user_error_message(exc, lines, filename, lineno): | ||
| return ( | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment above this string saying this needs to have zero indentation otherwise %(line)s will render incorrectly in Markdown.
| ).strip("\n") | ||
|
|
||
|
|
||
| def _get_failing_lines(code, lineno): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring:
"""Get list of strings (lines of code) from lineno to lineno+3.
We'd rather return the exact line where the error took place, but these are several reasons why this is not possible without a lot of work, including playing with the AST. So for now we're just returning 3 lines "near" where the error took place.
"""
...or something like that.
lib/streamlit/hashing_py3.py
Outdated
| # code reads `bar` of `foo`. We are going over the bytecode to resolve | ||
| # from which object an attribute is requested. | ||
| # Read more about bytecode at https://docs.python.org/3/library/dis.html | ||
| def handle_operation(op): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cleaner if this function just took lineno and tos as arguments and returned lineno, tos. It's always best to have side-effect-free functions, as they're easier to understand.
Then you can also move handle_operation out of here and into the top level scope, which makes it clear that it doesn't use a closure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there needs to be some additional changes for this to work, as it's breaking the current logic by only doing what you've described.
Instead I I got rid of the handle_operation function and moved that code back inside the try block, where it was before my changes.
lib/streamlit/hashing_py3.py
Outdated
| nonlocal tos | ||
| nonlocal lineno | ||
| if op.starts_line is not None: | ||
| lineno = op.starts_line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment:
Sometimes starts_line is None, in which case let's just remember the previous start_line (if any). This way when there's an exception we at least can point users somewhat near the line where the error stems from.
* handle internal and user errors during hashing * update hashing error messages and traceback handling * add filename and lineno to user hash error message
* Slider Unit test (#1052) * Moving balloons e2e to unit test * Slider unit test * Testing bounds * Adding comment for the await timeout * Set a classname prefix for atomic styletron css classes (#1047) - fix css conflict between plotly and baseweb slider * Audio unit test (#1058) * Make TSC happy (#1067) * Custom hashing logic for numpy.ufunc types (#1066) * Adding custom hashing logic for np.ufunc * added comment and changed np to numpy * review comments * Fix a couple Python 3.5 regressions caught in other work: (#1070) o f-strings is a 3.6 feature o 3.5 doesn't support a trailing comma after "**kwargs" at the end of a function definition. * Fixing add_rows index calculation (#1054) * Fixing index computation on add_rows * linter * snapshots * reverting snapshot * reverting snapshot * new snapshot from circleci ssh * Advanced caching updates feb (#1040) * Updating caching section in main concepts. * Moving Caching doc over from Google with minor contextual edits. Another pass is still needed. There are placeholders for advanced caching and troubleshooting documents. * Caching issues is still incomplete. * Removing content for push later today. Will add advanced and caching issues next rev. * Addressing Amanda's comments. * Update * Advanced caching and issues. * Edits requested by Thiago * Fixing link * Adjusting main concepts to match the google docs section verbatim * Small tweaks: renamed "items" → "components" and changed verb tenses here and there * Forgot one verb tense change * Rename "items" → "components" * Update PR directly instead of commenting. Co-authored-by: Thiago Teixeira <thiagot@gmail.com> * Fix for the CORS check (#965) * Adding CORS to troubleshooting guide. (#1001) * Adding CORS to troubleshooting guide. * Fixing CORS issues from Thiago. * Changing tip to note. * Separate common issues into multiple docs and improve them. * Talk about S4T Co-authored-by: Thiago Teixeira <thiagot@gmail.com> * Improve docs (#1075) * Improve docs. * Apostrophes * Add CircleCI jobs to run the oldest and newest Python versions we support. (#1053) As part of this, we've removed the per-Python-version lib/Pipfile.locks/ files in favor of running without pipenv lock files, and having CircleCI cache our Python environment using a combination of the Python binary, lib/Pipfile, and the current data. This implies that once per day we'll potentially upgrade our Python packages, consistent with any requirements in lib/Pipfile. We will always regenerate our Python environment if lib/Pipfile changes, potentially upgrading any other packages at that time as well. This was deemed acceptable in a conversation with @tvst. This also introduces tests.testutils.requires_tensorflow(), a decorator for tests that require Tensorflow, so that we can skip these under Python 3.8, which Tensorflow does not yet support. In doing this work, it was discovered that we had broken our support for Python 3.5. This required two fixes: o Invocations of "black" were modified to tell it that it needs to retain support for Python 3.5 syntax, which does not permit a trailing comma after "**kwargs" in a function definition. Fixed this in two places in DeltaGenerator.py, restoring Python 3.5 support. o In e2e/scripts/st_magic.py, tests of async generators were made conditional on Python 3.6 or greater. Following this change I expect one follow-up commit, and I made a few voluntary style changes: o Once this makes it to master, I expect to change the "fully-specified" job from python-3.7.4 to python-3.8, leaving only one "inheriting" job at 3.5. Not doing this yet so we can get the new name passing before we change out GitHub status checks to reference it. o The new job names reference the Python major and minor versions they belong to, but *not* the micro version (e.g., 4 in 3.7.4). I think we should be able to advance along these micro/maintenance releases without switching job names. o In the new 3.5 and 3.8 jobs, I removed explicit selection of the Debian version underlying the circleci Debian image we run the tests under. I could just have easily switched these to "buster", the new latest Debian, but I think it's probably better to just go with CircleCI's defaults rather than having to remember to check and update this every year or so. o Moved jstests to run against 3.8, since I'm planning to retire testing against 3.7 soon per the above. I tried doing this with Cypress as well, but ran against diffs due to font differences, so I fell back. * [mypy] First phase of work on testing Python type annotations. (#1079) o Introduces lib/mypy.ini with a starter set of strictness options. o All changes required to make these options pass. o scripts/mypy created to control running mypy based on suggestion at https://mypy.readthedocs.io/en/latest/existing_code.html#continuous-integration. o scripts/mypy --report emits a "coverage" report, with a summary % at the bottom detailing what % of our non-empty/comment source lines have full type information. Currently at 19.92%, probably based largely on assignments from literals. o 'scripts/mypy --report' is hooked into CircleCI under the python-3.8 job. lib/mypy.ini makes it enforce 3.5-compatible syntax, so I see no reason not to run it under our latest Python version only. o In CircleCI, I modified generation of ~/protobuf.md5 that's used for cache key generation to also include vary if our protoc or protoc-gen-mypy binaries change, as otherwise we'd currently think the prior cache was valid without producing .pyi files. * Widgets unit tests (#1077) * Checkbox unit test * Checkbox unit test * DateInput unit test foundations * DateInput unit test * Multiselect unit test * Testing multiselect overrides * Radio unit test * Selectbox unit test * TextArea unit test * TextArea unit test * TextArea unit test * TextInput unit tests * TimeInput test * Removing unused var * Fixing date * Fixing date * Fix indentation error in fad994c. (#1084) * Fix an incomplete copy for a dict that's then modified. (#1078) New test fails before the change, and passes afterwards. * Handle different Caching error messages (#1068) * handle internal and user errors during hashing * update hashing error messages and traceback handling * add filename and lineno to user hash error message * Retire python-3.7.4 CircleCI project. (#1086) We'll retain testing only against our oldest (3.5) and newest (3.8) supported Python versions going forward. FWIW, the "cypress" test continues to be based on a 3.7.4 image because efforts to upgrade under #1053 failed due to font rendering differences with screenshots. Handling this upgrade, when needed, will be performed separately, but should not block removal of running the whole Python suite against 3.7.4. * Version 0.55.1 (just pointing to new docs) (#1089) * Fix links in docs. * Point Streamlit caching error messages to the right URLs * Improve docs (#1075) * Improve docs. * Apostrophes * Lint * Update version to 0.55.1 * Fix update_version.py to point to correct md file * Somehow the changelog for 0.55 got lost. Fixed. * Somehow the changelog for 0.55 got lost. Fixed. * Remove old advanced caching section from advanced_concepts.md * Fix missing caching URL (#1094) * Allow wider range of int-like types in NumberInput (#1087) * test value integer types inclusive of numpy int64, int32, etc * check all params as numbers.Integer (not just int) * be more accepting of int types in JSNumber * Fix signatures of wrapped DG functions * Lint * Fix bug where icon assets were missing from "make install" * Ugly hack: name screencast files foo.webm.mp4 so it works on sites like Twitter with no modification. * Version 0.56.0 * Add logs to caching/hashing * In hashing.py, only import numpy when needed * Lint * Unbreak audio component * Fix audio tests * Chmod -x all .ts(x) files * Block Streamlit installation if Python < 3.5 * Force Python >= 3.5 * Update snaps. * Update headers and notices * Update changelog * Forgot to add emojis to changelog! * Fix bad merge with audio.test.tsx Co-authored-by: Nahuel Emiliano Rosso Fandiño <arraydude@gmail.com> Co-authored-by: Jonathan Rhone <rhone.j@gmail.com> Co-authored-by: Henrikh Kantuni <henrikh.kantuni@gmail.com> Co-authored-by: Matteo <monchier@users.noreply.github.com> Co-authored-by: Nate White <whiten@georgetown.edu> Co-authored-by: erikhopf <erik.hopf@gmail.com> Co-authored-by: Jackie <52658745+1wpro2@users.noreply.github.com> Co-authored-by: Naomi Most <pnaomi@gmail.com>
* develop: (29 commits) Release 0.56.0 (streamlit#1101) Fix bug where icon assets were missing from "make install" (streamlit#1100) Clean signatures of wrapped DeltaGenerator methods (streamlit#1099) Using widgetId as the key when rendering elements (streamlit#1102) Pass --skip-lock to pipenv under pipenv-install Makefile target. (streamlit#1093) Allow wider range of int-like types in NumberInput (streamlit#1087) Fix missing caching URL (streamlit#1094) Version 0.55.1 (just pointing to new docs) (streamlit#1089) Retire python-3.7.4 CircleCI project. (streamlit#1086) Handle different Caching error messages (streamlit#1068) Fix an incomplete copy for a dict that's then modified. (streamlit#1078) Fix indentation error in fad994c. (streamlit#1084) Widgets unit tests (streamlit#1077) [mypy] First phase of work on testing Python type annotations. (streamlit#1079) Add CircleCI jobs to run the oldest and newest Python versions we support. (streamlit#1053) Improve docs (streamlit#1075) Adding CORS to troubleshooting guide. (streamlit#1001) Fix for the CORS check (streamlit#965) Advanced caching updates feb (streamlit#1040) Fixing add_rows index calculation (streamlit#1054) ...
* develop: (30 commits) [Screencast] Fixing countdown bug (streamlit#1082) Release 0.56.0 (streamlit#1101) Fix bug where icon assets were missing from "make install" (streamlit#1100) Clean signatures of wrapped DeltaGenerator methods (streamlit#1099) Using widgetId as the key when rendering elements (streamlit#1102) Pass --skip-lock to pipenv under pipenv-install Makefile target. (streamlit#1093) Allow wider range of int-like types in NumberInput (streamlit#1087) Fix missing caching URL (streamlit#1094) Version 0.55.1 (just pointing to new docs) (streamlit#1089) Retire python-3.7.4 CircleCI project. (streamlit#1086) Handle different Caching error messages (streamlit#1068) Fix an incomplete copy for a dict that's then modified. (streamlit#1078) Fix indentation error in fad994c. (streamlit#1084) Widgets unit tests (streamlit#1077) [mypy] First phase of work on testing Python type annotations. (streamlit#1079) Add CircleCI jobs to run the oldest and newest Python versions we support. (streamlit#1053) Improve docs (streamlit#1075) Adding CORS to troubleshooting guide. (streamlit#1001) Fix for the CORS check (streamlit#965) Advanced caching updates feb (streamlit#1040) ...
* develop: (53 commits) Update plotly.js to 1.52 (streamlit#1119) Add tooltip in Altair/Vega-lite docstring code (streamlit#1092) Ability to bind to a server address with server.address config option (streamlit#1107) [mypy] Enable check_untyped_defs throughout the codebase. (streamlit#1110) st.map: set "radiusMinPixels" to 3 (streamlit#1113) st.plotly_chart docs incorrectly refer to Altair (streamlit#1118) Fix BytesIO and numpy array data sources for audio/video (streamlit#1116) Show warning to user and use skipkeys=True if json.dumps causes TypeError (streamlit#1112) Server: store SessionInfo by id (streamlit#1056) [Screencast] Fixing countdown bug (streamlit#1082) Release 0.56.0 (streamlit#1101) Fix bug where icon assets were missing from "make install" (streamlit#1100) Clean signatures of wrapped DeltaGenerator methods (streamlit#1099) Using widgetId as the key when rendering elements (streamlit#1102) Pass --skip-lock to pipenv under pipenv-install Makefile target. (streamlit#1093) Allow wider range of int-like types in NumberInput (streamlit#1087) Fix missing caching URL (streamlit#1094) Version 0.55.1 (just pointing to new docs) (streamlit#1089) Retire python-3.7.4 CircleCI project. (streamlit#1086) Handle different Caching error messages (streamlit#1068) ...
Issue #1007
Handle cache failures that occur because of an error during processing, either because of a bug in our caching code, or a bug in the user's app.
Distinguish these errors from actual
can't hash this objecterrors, and display the original exception to the user for these cases.Cases: