Qiskit Tools
qiskit.tools
Monitoring
A helper module to get IBM backend information and submitted job status.
job_monitor
qiskit.tools.job_monitor(job, interval=None, quiet=False, output=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, line_discipline='\r')
Monitor the status of a Job
instance.
Parameters
- job (BaseJob) – Job to monitor.
- interval (int) – Time interval between status queries.
- quiet (bool) – If True, do not print status messages.
- output (file) – The file like object to write status messages to.
- default (By) –
- sys.stdout. (this is) –
- line_discipline (string) – character emitted at start of a line of job monitor output,
- r. (This defaults to) –
Examples
from qiskit import BasicAer, transpile
from qiskit.circuit import QuantumCircuit
from qiskit.tools.monitor import job_monitor
sim_backend = BasicAer.get_backend("qasm_simulator")
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
tqc = transpile(qc, sim_backend)
job_sim = sim_backend.run(tqc)
job_monitor(job_sim)
backend_monitor
qiskit.tools.backend_monitor(backend)
Monitor a single IBM Quantum backend.
Parameters
backend (IBMBackend) – Backend to monitor.
Raises
- QiskitError – Input is not a IBM Quantum backend.
- MissingOptionalLibraryError – If qiskit-ibm-provider is not installed
Examples: .. code-block:: python
from qiskit_ibm_provider import IBMProvider from qiskit.tools.monitor import backend_monitor provider = IBMProvider() backend_monitor(provider.get_backend(‘ibm_sherbrooke’))
backend_overview
qiskit.tools.backend_overview()
Gives overview information on all the IBM Quantum backends that are available.
Examples
from qiskit.tools.monitor import backend_overview
backend_overview()
Events (qiskit.tools.events
)
A helper component for publishing and subscribing to events.
TextProgressBar
class qiskit.tools.events.TextProgressBar(output_handler=None)
A simple text-based progress bar.
output_handlerthe handler the progress bar should be written to, default
is sys.stdout, another option is sys.stderr
Examples
The progress bar can be used to track the progress of a parallel_map.
import numpy as np
import qiskit.tools.jupyter
from qiskit.tools.parallel import parallel_map
from qiskit.tools.events import TextProgressBar
TextProgressBar()
%qiskit_progress_bar -t text
parallel_map(np.sin, np.linspace(0,10,100));
And it can also be used individually.
from qiskit.tools.events import TextProgressBar
iterations = 100
t = TextProgressBar()
t.start(iterations=iterations)
for i in range(iterations):
# step i of heavy calculation ...
t.update(i + 1) # update progress bar