-
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
Add env variable and user config option to suppress packaging warnings #3362
Conversation
I'm not opposed to having a flag to do this. But before we add it I'm curious does the example from the documentation at the end of the terra from source section (https://qiskit.org/documentation/contributing_to_qiskit.html#installing-terra-from-source work) for your use case? That being said I think if we want to make this more easily configurable. You raise a good point about compiling aer, aer's build system makes it hard to build from source in a lot of environments. I think we should change the flag to be |
Yes, that example code using the warning filter does address my use case. I'm happy with that since it is documented (I didn't want to blindly apply a warnings filter and didn't read the doc). I do like both of your suggestions. |
Yeah, I think it's worthwhile even if it's not for the majority of users I think that there is a big enough set of users where this matters. I actually hit this personally because on one of my systems I'm fighting a packaging issue with ibmq and the import doesn't ever work which always emits a warning. So having a way to filter it easily outside of the calling script would be handy. I think that this will make the developer experience a bit more friendly. The warnings were mostly added as a stopgap against frequent bug filings because of the fragility of python packaging, especially around namespace packages. But, that was a conscious tradeoff of annoying people with more specialized use cases. So having a builtin workaround for that is a good idea. |
@ThePrez is there any update on this? |
Sorry. I haven't had time to circle back around and finish this up in other places. I probably won't be able to dig back into this for another couple weeks. We can let simmer, or we can merge the trivial changes in this PR and keep a work item open for the qiskit user config file and also ibmq if needed. |
This commit continues where the previous one left off, it makes 2 changes to functionality of the option to suppressing the packaging warnings. First, it changes the environment variable to be QISKIT_SUPPRESS_PACKAGING_WARNINGS and applies it to both aer and ibmq. Then it also adds an option for supressing these warnings to the user config file. This will enable users to disable the warnings globally locally without needing to ensure an env var is set. At the same time the test jobs are updated so that we suppress the warnings there because we don't install aer in ci (since it's not used).
@ThePrez I went ahead and updated this, it's been sitting idle for several months and we'd really like to get this feature in the next release. It has come up several times that using just filter warnings isn't flexible enough for several use cases. |
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.
Is it worth specifying the behavior if the user provides conflicting config and an env values? (Right now, I think if either are 'Y'/'y'/True, the message will be suppressed, but the ENV variable could take precedence over the config value or vice versa. I don't know if there's precedent for other config values.)
Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
That's a fair point, the env variable should take precedence over the user config file. We don't have it with env vars anywhere but it does exist for the parameters (like visualization backend) |
Qiskit#3362) * Add environment variable to suppress aer warning * Rename env var and add user config file option This commit continues where the previous one left off, it makes 2 changes to functionality of the option to suppressing the packaging warnings. First, it changes the environment variable to be QISKIT_SUPPRESS_PACKAGING_WARNINGS and applies it to both aer and ibmq. Then it also adds an option for supressing these warnings to the user config file. This will enable users to disable the warnings globally locally without needing to ensure an env var is set. At the same time the test jobs are updated so that we suppress the warnings there because we don't install aer in ci (since it's not used). * Fix lint * Update qiskit/__init__.py Co-Authored-By: Kevin Krsulich <kevin@krsulich.net> * Let env var override user config file * Adjust logic for printing warnings Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Summary
This PR adds a new env variable
QISKIT_SUPPRESS_PACKAGING_WARNINGS
and amatching user config file option
suppress_packaging_warnings
which can be used to optionallysuppress the regular warnings about aer and/or ibmq-provider missing at import time. This strikes
a balance between telling users who potentially have a packaging issue that would otherwise go
by unnoticed and giving users who are intentionally (or unable to) install the components the ability to disable the warnings.
Details and comments
Some platforms (in my case IBM i) cannot reliably build newer versions qiskit-aer due to new dependencies, etc. In my case, I want to pursue qiskit use with only terra (and show others), but the constant RuntimeWarning is an annoyance easily (incorrectly) perceived as an error.
In short, I'd like a way to suppress that warning, and I think an environment variable is a cheap and easy way to do so.
Co-authored-by: Matthew Treinish mtreinish@kortar.org