-
Notifications
You must be signed in to change notification settings - Fork 301
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
Add _Cache to _BaseParameter, use it in GetLatest, remove set_cache method, remove _latest #1832
Merged
Conversation
This file contains 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
also remove unnecessary cache-related methods, keep set_cache for now
... for readability and clarity
Codecov Report
@@ Coverage Diff @@
## master #1832 +/- ##
==========================================
+ Coverage 70.24% 70.28% +0.03%
==========================================
Files 148 148
Lines 18598 18621 +23
==========================================
+ Hits 13064 13087 +23
Misses 5534 5534 |
This was referenced Nov 20, 2019
3a13e53
to
7cde148
Compare
Dominik-Vogel
approved these changes
Nov 21, 2019
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.
Great! and good job with removing _latest from all the tests!
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.
Main thing
This PR takes another approach to #1791 - introducing
_Cache
class which:_latest
dictionary withvalue
,raw_value
, andtimestamp
(alsomax_val_age
), andget
method that behaves asget_latest
andset
method that behaves asset_cache
that was introduced in _BaseParameter cached value: add set_cache method, make _save_val method useless, convert raw_value attribute to property #1757.This PR subsumes significant part of #1828 but not the improvements to
snapshot_base
.Some details of this PR
GetLatest
andget_latest
remain as is for backwards compatibility, but under the hood they reuse_Cache
and its methods "as-is". In the near future we will be able to deprecateGetLatest
altogetherand move our users to use
.cache
only._Cache.get
as opposed toget_latest.get
has an additionalget_if_invalid
flag that is useful to set toFalse
when you don't want to callget
of the parameter if the cached value is invalid (for example, because the parameter has never been captured).parameter.py
were rewritten to reflect the existence of the_Cache
set_cache
were changed to usecache.set
.test_parameter.py
into a package is out of scope for this PRTo be done in another PR:
test_parameter.py
to testcache.*
instead ofget_latest.*
but also add minor tests forget_latest
to ensure that it does the same ascache