-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix bug in cache updates and improve cache logging #3708
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
- Fix cache updates (it wrote unusable JSON, dammit). - Completely ignore platform when --skip-version-check is used. - Don't compare option setting for debug_cache (so silly).
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.
Not sure I fully understand this code, but the changes seem reasonable. Feel free to merge after addressing the two nits.
if not os.path.exists(meta_json): | ||
manager.trace('Could not load cache for {}: could not find {}'.format(id, meta_json)) | ||
manager.log('Could not load cache for {}: could not find {}'.format(id, meta_json)) |
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.
Why the change from trace
to log
? And did you intend to change the trace
above as well?
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.
So a run with one -v
will always show the decision around a particular cache file (every return None
from this function, plus specific actions in validate_meta()
. The above trace method is not a decision, promoting that would double the number of lines logged per cache file.
mypy/build.py
Outdated
# Optimization: update mtime and path (otherwise, this mismatch will reappear). | ||
meta = meta._replace(mtime=int(st.st_mtime), path=path) | ||
meta = meta._replace(mtime=mtime, path=path) | ||
meta_dict = { |
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.
It could be worth having a comment explaining the need for this.
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.
Good idea, done! Not constructing this dict was the bug here.
This started out as an attempt to make the logging messages around cache freshness/updates more useful, but I ended up discovering a bug in the code that updates the cache meta file when the mtime or path of the file has changes but size and source hash are the same. It wrote a list instead of a dict! This is a bug in a feature announced in 0.520 so should be included in 0.521 if/when we release it. I also decided to ignore debug_cache when comparing options (since it only affects the JSON style -- it's still a per-file option but changing it no longer invalidates the cache) And I made the --skip-version-check option strictly ignore the platform (since it's undocumented I can make it do what I want, and this is more useful for my one use case).
This started out as an attempt to make the logging messages around cache freshness/updates more useful, but I ended up discovering a bug in the code that updates the cache meta file when the mtime or path of the file has changes but size and source hash are the same. It wrote a list instead of a dict! This is a bug in a feature announced in 0.520 so should be included in 0.521 if/when we release it.
I also decided to ignore
debug_cache
when comparing options (since it only affects the JSON style -- it's still a per-file option but changing it no longer invalidates the cache)And I made the
--skip-version-check
option strictly ignore the platform (since it's undocumented I can make it do what I want, and this is more useful for my one use case).