-
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
DEBUG log messages emitted on imports #7498
Comments
For the record, I imported every single component of Terra, and this is the full set of log messages: In [1]: import logging
...: logging.basicConfig(level=logging.NOTSET)
...: logging.getLogger("matplotlib").setLevel(logging.WARNING)
...: logging.getLogger("asyncio").setLevel(logging.WARNING)
...: import importlib
...: import pathlib
...: for path in pathlib.Path("qiskit").glob("**/*.py"):
...: parents = list(path.parents)[-2::-1]
...: mod = ".".join(str(x.name) for x in parents)
...: if path.name != "__init__.py":
...: mod += "." + path.name[:-3]
...: importlib.import_module(mod)
I think the |
The test one is something we should just get rid of it's parsing a weird environment variable that sets key value pairs as a single string. Those aren't really used anywhere anymore (except for the caveats related to #862 and something else might be using it) except for the slow test skip piece which is easy enough to pivot to a better mechanism. The assembler calls are probably from aer on import. It runs some circuits to determine the capabilities of the binary executable: https://github.com/Qiskit/qiskit-aer/blob/24c51a675b8653c8ad2af587d40b795ac94c07c7/qiskit/providers/aer/backends/backend_utils.py#L119-L153 we probably should switch that to some metadata we set to the binary that can be read and avoid doing that on import. |
The synthesis log message is being caused by this global: https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/quantum_info/synthesis/two_qubit_decompose.py#L1405 which gets used by most of the transpiler and is part of the default set of what gets pulled in on |
I made the two-qubit decompose variable lazy in #7525 (it was the last thing loading any component of The testing options used to be loaded immediately on import, but with #7525 they'll now only be loaded when one of the testing decorators is used that accesses the options, so that'll provide the context - it could be useful still in that sense, so long as we actually support the |
Environment
What is happening?
When importing some modules, including the root
qiskit
namespace,DEBUG
log messages get emitted. For exampleimport qiskit
emits:and
import qiskit.test
emits:How can we reproduce the issue?
What should happen?
We shouldn't be emitting runtime log messages during an import. This is primarily a side effect of code being executed at the module level on import, normally to setup global objects, but emitting these log messages on import is missing the context and really serves no useful purpose.
Any suggestions?
First we need to find all the places this is happening in the tree (I only tested these two paths there might be others). Then we either remove the logging if it serves no purpose (arguable the qiskit.test example falls in this category )or filter the logs from code that is executed on import (the decomposition falls in this example because normally logging the decomposition fidelity can be useful when code is explicitly calling the synthesis routines).
The text was updated successfully, but these errors were encountered: