-
Notifications
You must be signed in to change notification settings - Fork 155
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
🐛 Fix deprecated Loader.load_module()
#728
Conversation
the errors were the result of an ImportWarning in rustworkx which pytest interprets as an error. See See Qiskit/rustworkx#728 Until that is fixed, this PR just ignores the corresponding warning. Signed-off-by: burgholzer <[email protected]>
I am pretty confident we copied this code from Qiskit/qiskit#5089 (so it does also impact Qiskit Terra). I'll let @mtreinish review it |
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.
Thanks for fixing this, I think this should do the trick and maintain compatibility with the new import API to avoid the warnings.
As @IvanIsCoding said I did just copy this from what I ended up doing in qiskit-terra. The warning has actually been reported in an issue on the qiskit already: Qiskit/qiskit#8853 and I had forgot to circle back and write a fix for it there. If you have the bandwidth would you mind push a similar PR to qiskit-terra to fix the same issue in its loader class (if not no worries).
Sure. I'll do that over the weekend 👍🏻 |
Pull Request Test Coverage Report for Build 3395316397
💛 - Coveralls |
(cherry picked from commit 53f0e31)
(cherry picked from commit 53f0e31) Co-authored-by: Lukas Burgholzer <[email protected]>
See Qiskit/qiskit#9078. |
Any package that imports
retworkx
(such asqiskit-terra
) underPython>=3.10
currently raisesImportWarning: RetworkxLoader.exec_module() not found; falling back to load_module()
Any system that uses
pytest
and sets thefilterwarnings
feature toerror
will fail loudly as a consequence of this (see, e.g., https://github.com/cda-tum/qcec/actions/runs/3394728729/jobs/5643660360#step:4:453).Loader.load_module()
has been deprecated since Python 3.4 (https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module) and starting with 3.10, Python has started to actually raise the aboveImportWarning
.This PR works around this issue by providing (rather straight-forward) implementations of the required
Loader.create_module()
andLoader.exec_module()
methods. The fix is inspired by benjaminp/six#343.With this PR,
rustworkx
and, in turn,qiskit
can be used without errors underPython>=3.10
.