-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Remove validation methods from primitive base classes #11052
Conversation
This deprecates the argument validation methods from primitive base classes and moves them to separate helper functions. These methods unnecessarily bloat the base classes, and are odd to have when the BasePrimitive doesn't even define a run method to validate. There is no reason primitive implementations need to use the same validation as these base classes either. A follow up will be to remove the validation from the base `run` methods and have subclasses implement their own validation.
One or more of the the following people are requested to review this:
|
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.
LGTM
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.
looks good, but I have a minor question about lifetime of new functions.
qiskit/primitives/base/validation.py
Outdated
from qiskit.opflow import PauliSumOp | ||
|
||
|
||
def validate_estimator_args( |
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.
If validate_estimator_args
and validate_sampler_args
are to be deprecated in the near future, it may not be necessary to make it public in the first place.
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.
I agree to make the validation functions private.
Pull Request Test Coverage Report for Build 6716399147
💛 - Coveralls |
@Mergifyio backport stable/0.46 |
✅ Backports have been created
|
* Remove validation methods from primitive base classes This deprecates the argument validation methods from primitive base classes and moves them to separate helper functions. These methods unnecessarily bloat the base classes, and are odd to have when the BasePrimitive doesn't even define a run method to validate. There is no reason primitive implementations need to use the same validation as these base classes either. A follow up will be to remove the validation from the base `run` methods and have subclasses implement their own validation. * Apply suggestions from code review * Update qiskit/primitives/base/base_estimator.py --------- Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com> (cherry picked from commit 05d958b) # Conflicts: # qiskit/primitives/base/base_sampler.py
* Remove validation methods from primitive base classes This deprecates the argument validation methods from primitive base classes and moves them to separate helper functions. These methods unnecessarily bloat the base classes, and are odd to have when the BasePrimitive doesn't even define a run method to validate. There is no reason primitive implementations need to use the same validation as these base classes either. A follow up will be to remove the validation from the base `run` methods and have subclasses implement their own validation. * Apply suggestions from code review * Update qiskit/primitives/base/base_estimator.py --------- Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com> (cherry picked from commit 05d958b)
… (#11532) * Remove validation methods from primitive base classes (#11052) * Remove validation methods from primitive base classes This deprecates the argument validation methods from primitive base classes and moves them to separate helper functions. These methods unnecessarily bloat the base classes, and are odd to have when the BasePrimitive doesn't even define a run method to validate. There is no reason primitive implementations need to use the same validation as these base classes either. A follow up will be to remove the validation from the base `run` methods and have subclasses implement their own validation. * Apply suggestions from code review * Update qiskit/primitives/base/base_estimator.py --------- Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com> (cherry picked from commit 05d958b) * Update qiskit/primitives/base/base_estimator.py * Add missing import --------- Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Summary
This deprecates the argument validation methods from primitive base classes and moves them to separate helper functions. These methods unnecessarily bloat the base classes, and are odd to have when the BasePrimitive doesn't even define a run method to validate. There is no reason primitive implementations need to use the same validation as these base classes either. A follow up will be to remove the validation from the base
run
methods and have subclasses implement their own validation.Details and comments