microsoft / microsoft/Qcodes

parameter.cache() will change an invalid cache to valid, even for parameters with `get_cmd=None`

Open
#4,794 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

Steps to reproduce
p = Parameter("name", set_cmd=None)
assert not p.cache.valid
p.cache()
assert not p.cache.valid
p = Parameter("name", set_cmd=None)
p.set(5)
assert p.cache.valid
p.cache.invalidate()
assert not p.cache.valid
p.cache()
assert not p.cache.valid

the last assert will fail in both cases

Expected behaviour

As we did not implement a get_cmd, parameter.cache() always returns the last cached value,even though it is not valid (this is fine).
Querying the cache should leave it marked as invalid, unless we get information about the parameter from another place, i.e. unless a get_cmd is implemented.

Actual behaviour

parameter.cache() will always update the cache, switching an invalid cache to valid. See the red path in the flow diagram:
image

Comment

It is possible that using both cache.invalidate() and get_cmd=None together is not intended and considered user error. In this case, this should be documented.

System

windows
qcodes 0.33.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Parameter cache() and cache.invalidate() entry points and reproduce the two examples from the issue on Windows or the available test environment. Add coverage for parameters with get_cmd=None, then verify that querying an invalid cache leaves it invalid while still returning the last cached value.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.