Skip to content
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

Fix #1230: OSError not caught when writing cache to disk #8

Merged
merged 2 commits into from
Aug 26, 2019

Conversation

tvst
Copy link
Contributor

@tvst tvst commented Aug 26, 2019

This fixes an uncaught Python 2 exception, as reported here: #1230.

It also hides a hashing warning when a user imports a module from inside a cached function. This is a common scenario, and the warning UI is too invasive today. We should come up with a better UI.

@tvst tvst requested a review from domoritz August 26, 2019 06:17
@tvst tvst self-assigned this Aug 26, 2019
Copy link
Contributor

@domoritz domoritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, so #1230 was a Python 2 specific issue.

The warning you disabled is very common for Python 2 since we don't analyze the bytecode there. Having said that, I still think it's coming up too often even in Python 3.

@tvst tvst merged commit 2f73a88 into streamlit:develop Aug 26, 2019
@domoritz
Copy link
Contributor

Would it make sense to use the standard logger so that we at least know on the command line that something wasn't hashed?

tconkling added a commit to tconkling/streamlit that referenced this pull request Aug 27, 2019
* develop:
  Fix streamlit#1230: OSError not caught when writing cache to disk (streamlit#8)
  Improve caching code (streamlit#2)
  Remove incorrect background of code inside error messages (streamlit#4)
  Fix line number in error message (streamlit#3)
  Update README.md
  Implement Caching object to support running code blocks only once (streamlit#1)
  Update README.md
  Add font licenses to NOTICE (streamlit#1267)
  Clean up repo for open source release. Remove unecessary folders. (streamlit#1266)
  Fix st.cache (streamlit#1273)
  Close streamlit#1092 (streamlit#1270)
  Change license header in variables.scss so it's compatible with scss-to-json. (streamlit#1268)
  Sidebar (streamlit#1224)
  Add Apache license and update all license headers (streamlit#1265)
  Handling objects with empty docs in st.help (streamlit#1261)
  Enhance Mochawesome report with screenshots (streamlit#1263)
  Add LICENSES file (streamlit#1262)
@treuille
Copy link
Contributor

FYI: Adding this py2/3 compatibility header to the top of hashing.py solves this too:

# Python 2/3 compatibility
from __future__ import print_function, division, unicode_literals, absolute_import
from streamlit.compatibility import setup_2_3_shims
setup_2_3_shims(globals())

since it creates FileNotFoundError.

@domoritz
Copy link
Contributor

Hmm, I had to remove the header because unicode literals cause a bug in Astor. Here is the patch berkerpeksag/astor#154

@tvst tvst deleted the caching branch November 12, 2019 04:33
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.

None yet

3 participants