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

Snapshot_base introduce new update=None, and use cache in parameter's snapshot_base #1833

Merged
merged 17 commits into from
May 26, 2020

Conversation

astafan8
Copy link
Contributor

@astafan8 astafan8 commented Nov 20, 2019

Main thing

_BaseParameter.snapshot_base has been refactored to use cache and rely on cache.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 and update=False meas do not ever try to update the underlying value. It is the intention that update=None should become the default in many places but that will happen in a diffrent pr.

Other notes

  • Note that _BaseParameter._snapshot_get is passed to cache.get via this new get_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

  • IMPORTANT add tests for get_if_invalid on _Cache.get(...) (also for the whole _Cache) EDIT done in a different pr
  • remove _value from DelegateCache because it should not be needed ever, thanks to this PR EDIT done in a different pr
  • due to fixes to tests that have to be done... is the suggested behavior really correct? EDIT not needed any more since the change to update=False was reverted

@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #1833 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            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     

@astafan8 astafan8 force-pushed the snapshot-base-use-cache-get branch from 4b353f4 to 6421c66 Compare November 22, 2019 13:45
@astafan8 astafan8 added this to the v0.9.0 milestone Dec 2, 2019
@astafan8 astafan8 force-pushed the snapshot-base-use-cache-get branch from 6421c66 to d447f8c Compare December 4, 2019 10:47
@astafan8 astafan8 modified the milestones: v0.9.0, v0.10.0 Dec 5, 2019
@astafan8 astafan8 removed this from the v0.10.0 cut milestone Feb 20, 2020
@jenshnielsen
Copy link
Collaborator

@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

@astafan8 astafan8 changed the title Snapshot base use cache get Snapshot_base introduce new update=None, and use cache in parameter's snapshot_base May 19, 2020
@jenshnielsen jenshnielsen marked this pull request as ready for review May 20, 2020 12:46
astafan8 and others added 15 commits May 26, 2020 12:07
.. 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.
@jenshnielsen jenshnielsen force-pushed the snapshot-base-use-cache-get branch from 8ae1b7a to 378e06f Compare May 26, 2020 11:55
@jenshnielsen
Copy link
Collaborator

@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

Copy link
Contributor Author

@astafan8 astafan8 left a 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!

@jenshnielsen jenshnielsen merged commit acd25c1 into microsoft:master May 26, 2020
@jenshnielsen jenshnielsen deleted the snapshot-base-use-cache-get branch May 26, 2020 14:28
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.

2 participants