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

Deprecate convenience methods on Instrument classes #6086

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

jenshnielsen
Copy link
Collaborator

@jenshnielsen jenshnielsen commented May 17, 2024

Following the discussion in #6080 I think we should consider getting rid of these methods on the instrument classes.

All of this functionality can be done in ways that is more obvious, direct and more frequently used

E.g. parameter and functions can be looked up from the parameters and functions delegate attr dicts if you need to look them up dynamically.

Copy link

codecov bot commented May 17, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.34%. Comparing base (badc122) to head (f02bdc2).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/qcodes/instrument_drivers/tektronix/AWG5014.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6086      +/-   ##
==========================================
- Coverage   67.35%   67.34%   -0.01%     
==========================================
  Files         352      352              
  Lines       32139    32143       +4     
==========================================
+ Hits        21646    21647       +1     
- Misses      10493    10496       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

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

I support this deprecation. The only usefulness related to this that I can recall is calling parameters/methods/functions on channel lists, but that I already implemented and work for both proper parameters and bound methods (right?)

@jenshnielsen
Copy link
Collaborator Author

I support this deprecation. The only usefulness related to this that I can recall is calling parameters/methods/functions on channel lists, but that I already implemented and work for both proper parameters and bound methods (right?)

Yes, there was a limitation where you could not call a method on more than one channel (which was an advantage of a qcodes function) but that has since been lifted.

@jenshnielsen jenshnielsen added this pull request to the merge queue Sep 25, 2024
Merged via the queue into microsoft:main with commit dce5c6f Sep 25, 2024
16 checks passed
@jenshnielsen jenshnielsen deleted the deprecate_getters branch September 25, 2024 09:27
@sldesnoo-Delft
Copy link
Contributor

This deprecation results in quite some warnings in our code. I agree that the code is cleaner, but I don't like it that code used in the labs will break in many places when this functionality is removed.

@jenshnielsen
Copy link
Collaborator Author

@sldesnoo-Delft Thanks for your input. In the code that I had access to I saw very few uses of these patterns so good to know they are being used elsewhere. I would suggest that we leave this code deprecated but there is no reason that we have to remove it any time soon if there is real usage of it. That way users will be guided in the right direction.

BTW since we are using the new 3.13 deprecated decorator (backported from typing extensions) you can use a type checker for catching most usage of deprecated code. I have been using pyright with a config like this (pyright.json)

{
    "typeCheckingMode": "off",
    "reportDeprecated": true
}

as a quick way to find all calls to deprecated methods etc.

I believe that mypy is also in the process of adding support for this in the next release or so.

@grahamnorris
Copy link

I just want to chime in here as someone from a lab that has built a software package where many objects (qubits, AWGs, etc.) are instances of qcodes InstrumentBase.
This change results in a lot of deprecation warnings at once.
Many measurements may now emit more than 10 of these.

While we will refactor the several hundred instances of get/set, I would like to understand the reasoning here a bit better.
Are there any performance or other technical reasons for this change, or is it rather one of code organization?
#6080 doesn't seem to explicitly discuss get and set, but rather focuses on indexing.

I also briefly note that these methods are not shown as deprecated in the API documentation

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.

4 participants