Repository navigation
Fix bug in cache updates and improve cache logging - #3708
Merged
Merged
Conversation
added 2 commits
July 12, 2017 13:23
- 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).
ddfisher
self-requested a review
July 13, 2017 00:03
ddfisher
approved these changes
Jul 13, 2017
| manager.trace('Looking for {} at {}'.format(id, meta_json)) | ||
| 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)) |
Collaborator
There was a problem hiding this comment.
Why the change from trace to log? And did you intend to change the trace above as well?
Member
Author
There was a problem hiding this comment.
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.
| # 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 = { |
Collaborator
There was a problem hiding this comment.
It could be worth having a comment explaining the need for this.
Member
Author
There was a problem hiding this comment.
Good idea, done! Not constructing this dict was the bug here.
gvanrossum
added a commit
to gvanrossum/mypy
that referenced
this pull request
Jul 18, 2017
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_cachewhen 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-checkoption 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).