-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
__qiskit_version__ deprecation #10242
Conversation
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5604152404
💛 - Coveralls |
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.
Overall I'm fine with this, it's a little weird to do the packages with qiskit in the name like that for the magic. But since it's isolated to just the widget it's a reasonable tradeoff for people that like the table in notebooks. Just a couple small inline comments.
@@ -14,6 +14,8 @@ | |||
"""A module for monitoring backends.""" | |||
|
|||
import time | |||
from sys import modules | |||
from collections import OrderedDict |
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.
Do you need an ordered dict? For all our supported versions of Python all dicts are insertion ordered now.
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.
Fixed in d0d8588
qiskit/version.py
Outdated
warnings.warn( | ||
"qiskit.__qiskit_version__ is deprecated since " | ||
"Qiskit Terra 0.25.0, and will be removed 3 months or more later. " | ||
"Instead, you should use qiskit.__version__.", |
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.
You might want to mention that for other packages that used to be in __qiskit_version__
those packages should have a __version__
attribute too.
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.
good point. done in a846ffe
The magic ``%qiskit_version_table`` from ``qiskit.tools.jupyter`` now includes all | ||
the modules with ``'qiskit`` in the name. |
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.
Maybe say "all imported packages with qiskit
in the name"?
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.
reworded in bab5901
qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module} | ||
for qiskit_module in qiskit_modules: | ||
try: | ||
packages[metadata(qiskit_module)["Name"]] = metadata(qiskit_module)["Version"] | ||
except PackageNotFoundError: | ||
packages["qiskit"] = None |
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.
Looking at this with fresh eyes my concern here is that the module name in sys.modules
isn't necessarily going to be the package name that importlib.metadata will find. The best example of this is actually qiskit
, if you just have terra installed you would need to call metadata("qiskit-terra")
not metadata("qiskit")
to get the installed package version for the qiskit
module in sys.modules
.
I think it might be better to do:
qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module} | |
for qiskit_module in qiskit_modules: | |
try: | |
packages[metadata(qiskit_module)["Name"]] = metadata(qiskit_module)["Version"] | |
except PackageNotFoundError: | |
packages["qiskit"] = None | |
qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module} | |
for qiskit_module in qiskit_modules: | |
packages[qiskit_module] = getattr(sys.modules[qiskit_module], "__version__", None) |
so it just uses the version reported in the __version__
attribute.
qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module} | ||
for qiskit_module in qiskit_modules: | ||
try: | ||
packages[metadata(qiskit_module)["Name"]] = metadata(qiskit_module)["Version"] | ||
except PackageNotFoundError: | ||
packages["qiskit"] = None |
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.
This should probably be qiskit_module
right, because if a version can't be found for qiskit_module
you don't want to invalidate the qiskit package versio.
Co-authored-by: Matthew Treinish <[email protected]>
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, thanks for the update
One or more of the the following people are requested to review this:
|
* __qiskit_version__ deprecation * reno * reno feature * PackageNotFoundError * revert stacklevel=2 * revert change in test * remove OrderedDict * other qiskit.__qiskit_version__ packages have their own __version__ * wording in the reno * lint * Update qiskit/tools/jupyter/version_table.py Co-authored-by: Matthew Treinish <[email protected]> * Update qiskit/tools/jupyter/version_table.py * Restore removed version checks --------- Co-authored-by: Matthew Treinish <[email protected]>
Fixes #9753
This PR deprecates
qiskit.__qiskit_version__
in favor ofqiskit.__version__
The
%qiskit_version_table
now does not depend onqiskit.__qiskit_version__
. I also extended to list in the table all the modules/packages that include the wordqiskit
to have this output: