-
Notifications
You must be signed in to change notification settings - Fork 322
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
Snapshot_base introduce new update=None, and use cache in parameter's snapshot_base #1833
Snapshot_base introduce new update=None, and use cache in parameter's snapshot_base #1833
Conversation
c396dab
to
4b353f4
Compare
Codecov Report
@@ Coverage Diff @@
## master #1833 +/- ##
==========================================
- Coverage 71.11% 71.11% -0.01%
==========================================
Files 145 145
Lines 19485 19487 +2
==========================================
+ Hits 13857 13858 +1
- Misses 5628 5629 +1 |
4b353f4
to
6421c66
Compare
6421c66
to
d447f8c
Compare
@astafan8 I ended up changing the API of update for snapshot_base slightly. Now it takes an optional bool. Such that True and False works as before but if the value is None it will only update the cache if it is known to be invalid (the new behaviour) This is primarily so that we can be sure that https://github.com/QCoDeS/Qcodes/blob/master/qcodes/instrument/base.py#L217 never triggers an update. I suggest that we then (in a subsequent pr) change the default values of update from False to None in Station |
.. also, this means that if the cache is invalid, the parameter get still will be called if other flags allow it.
* ``self._count -= 1`` is moved below the exception so that ``count`` kwarg correctly determines the number of times that the parameter's ``get`` can be called * since it's a "memory" parameter, use ``self.cache.raw_value`` in its ``get_raw`` as opposed to ``get_latest`` These were found thanks to the fact that ``snapshot_base`` of the ``Parameter`` was improved to react to the "invalidity" of the cache.
8ae1b7a
to
378e06f
Compare
@astafan8 I think this is ready for a final look before merging. Note that the cache tests that used ot be here have already landed via one of the other prs |
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.
Approve! :) Thanks for finishing this up!
Co-authored-by: Mikhail Astafev <[email protected]>
Main thing
_BaseParameter.snapshot_base
has been refactored to usecache
and rely oncache.get
.It has gaied a third value for update such that
update=True
means unconditionally update the cache.update=None
means update if known to be out of date andupdate=False
meas do not ever try to update the underlying value. It is the intention thatupdate=None
should become the default in many places but that will happen in a diffrent pr.Other notes
_BaseParameter._snapshot_get
is passed tocache.get
via this newget_if_invalid
flag._BaseParameter.snapshot_base
got it's own set of parametrized set of tests so that its current behavior is captured (to the best of my abilities)ToDo
get_if_invalid
on_Cache.get(...)
(also for the whole_Cache
) EDIT done in a different pr_value
fromDelegateCache
because it should not be needed ever, thanks to this PR EDIT done in a different pr