diff --git a/docs/apidoc/index.rst b/docs/apidoc/index.rst index 9d1eb2f64960..3fc3e25e457d 100644 --- a/docs/apidoc/index.rst +++ b/docs/apidoc/index.rst @@ -35,7 +35,6 @@ API Reference quantum_info result tools - tools_jupyter transpiler transpiler_passes transpiler_preset diff --git a/docs/apidoc/tools_jupyter.rst b/docs/apidoc/tools_jupyter.rst deleted file mode 100644 index 92691f6ba9a8..000000000000 --- a/docs/apidoc/tools_jupyter.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _qiskit-tools-jupyter: - -.. automodule:: qiskit.tools.jupyter - :no-members: - :no-inherited-members: - :no-special-members: diff --git a/pyproject.toml b/pyproject.toml index 04bafbf3f995..d42b249a1058 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,6 @@ qasm3-import = [ ] visualization = [ "matplotlib >= 3.3", - "ipywidgets >= 7.3.0", "pydot", "Pillow >= 4.2.1", "pylatexenc >= 1.4", diff --git a/qiskit/__init__.py b/qiskit/__init__.py index 664cd8c57c5c..444aea12e024 100644 --- a/qiskit/__init__.py +++ b/qiskit/__init__.py @@ -74,8 +74,6 @@ _config = _user_config.get_config() -# Moved to after IBMQ and Aer imports due to import issues -# with other modules that check for IBMQ (tools) from qiskit.execute_function import execute from qiskit.compiler import transpile, assemble, schedule, sequence @@ -125,64 +123,13 @@ def __getattr__(self, attr): return getattr(self.aer, attr) -class IBMQWrapper: - """Lazy loading wrapper for IBMQ provider.""" - - def __init__(self): - self.ibmq = None - - def __bool__(self): - if self.ibmq is None: - try: - from qiskit.providers import ibmq - - self.ibmq = ibmq.IBMQ - warnings.warn( - "The qiskit.IBMQ entrypoint and the qiskit-ibmq-provider package (" - "accessible from 'qiskit.providers.ibmq`) are deprecated and will be removed " - "in a future release. Instead you should use the qiskit-ibm-provider package " - "which is accessible from 'qiskit_ibm_provider'. You can install it with " - "'pip install qiskit_ibm_provider'", - DeprecationWarning, - stacklevel=2, - ) - - except ImportError: - return False - return True - - def __getattr__(self, attr): - if not self.ibmq: - try: - from qiskit.providers import ibmq - - self.ibmq = ibmq.IBMQ - warnings.warn( - "The qiskit.IBMQ entrypoint and the qiskit-ibmq-provider package (" - "accessible from 'qiskit.providers.ibmq`) are deprecated and will be removed " - "in a future release. Instead you should use the qiskit-ibm-provider package " - "which is accessible from 'qiskit_ibm_provider'. You can install it with " - "'pip install qiskit_ibm_provider'. Just replace 'qiskit.IBMQ' with " - "'qiskit_ibm_provider.IBMProvider'", - DeprecationWarning, - stacklevel=2, - ) - except ImportError as ex: - raise MissingOptionalLibraryError( - "qiskit-ibmq-provider", "IBMQ provider", "pip install qiskit-ibmq-provider" - ) from ex - return getattr(self.ibmq, attr) - - Aer = AerWrapper() -IBMQ = IBMQWrapper() __all__ = [ "Aer", "AncillaRegister", "BasicAer", "ClassicalRegister", - "IBMQ", "MissingOptionalLibraryError", "QiskitError", "QuantumCircuit", diff --git a/qiskit/circuit/library/basis_change/qft.py b/qiskit/circuit/library/basis_change/qft.py index 7e9262d81943..9dcb1251453f 100644 --- a/qiskit/circuit/library/basis_change/qft.py +++ b/qiskit/circuit/library/basis_change/qft.py @@ -41,7 +41,7 @@ class QFT(BlueprintCircuit): .. plot:: from qiskit.circuit.library import QFT - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = QFT(4) _generate_circuit_library_visualization(circuit) @@ -51,7 +51,7 @@ class QFT(BlueprintCircuit): .. plot:: from qiskit.circuit.library import QFT - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = QFT(4).inverse() _generate_circuit_library_visualization(circuit) @@ -67,7 +67,7 @@ class QFT(BlueprintCircuit): .. plot:: from qiskit.circuit.library import QFT - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = QFT(5, approximation_degree=2) _generate_circuit_library_visualization(circuit) diff --git a/qiskit/circuit/library/boolean_logic/inner_product.py b/qiskit/circuit/library/boolean_logic/inner_product.py index 08524f51048a..6efbc8a02913 100644 --- a/qiskit/circuit/library/boolean_logic/inner_product.py +++ b/qiskit/circuit/library/boolean_logic/inner_product.py @@ -56,7 +56,7 @@ class InnerProduct(QuantumCircuit): .. plot:: from qiskit.circuit.library import InnerProduct - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = InnerProduct(4) _generate_circuit_library_visualization(circuit) """ diff --git a/qiskit/circuit/library/boolean_logic/quantum_and.py b/qiskit/circuit/library/boolean_logic/quantum_and.py index 97c2a0e143b9..ce2d253ca85a 100644 --- a/qiskit/circuit/library/boolean_logic/quantum_and.py +++ b/qiskit/circuit/library/boolean_logic/quantum_and.py @@ -32,7 +32,7 @@ class AND(QuantumCircuit): .. plot:: from qiskit.circuit.library import AND - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = AND(5) _generate_circuit_library_visualization(circuit) @@ -43,7 +43,7 @@ class AND(QuantumCircuit): .. plot:: from qiskit.circuit.library import AND - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = AND(5, flags=[-1, 0, 0, 1, 1]) _generate_circuit_library_visualization(circuit) diff --git a/qiskit/circuit/library/boolean_logic/quantum_or.py b/qiskit/circuit/library/boolean_logic/quantum_or.py index 2ac114ffb1b1..91d6c4fbdd52 100644 --- a/qiskit/circuit/library/boolean_logic/quantum_or.py +++ b/qiskit/circuit/library/boolean_logic/quantum_or.py @@ -33,7 +33,7 @@ class OR(QuantumCircuit): .. plot:: from qiskit.circuit.library import OR - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = OR(5) _generate_circuit_library_visualization(circuit) @@ -44,7 +44,7 @@ class OR(QuantumCircuit): .. plot:: from qiskit.circuit.library import OR - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = OR(5, flags=[-1, 0, 0, 1, 1]) _generate_circuit_library_visualization(circuit) diff --git a/qiskit/circuit/library/boolean_logic/quantum_xor.py b/qiskit/circuit/library/boolean_logic/quantum_xor.py index 08b0055248fa..5b230345137d 100644 --- a/qiskit/circuit/library/boolean_logic/quantum_xor.py +++ b/qiskit/circuit/library/boolean_logic/quantum_xor.py @@ -48,7 +48,7 @@ def __init__( .. plot:: from qiskit.circuit.library import XOR - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = XOR(5, seed=42) _generate_circuit_library_visualization(circuit) """ diff --git a/qiskit/circuit/library/fourier_checking.py b/qiskit/circuit/library/fourier_checking.py index b31dc9748e83..9035fbc360d4 100644 --- a/qiskit/circuit/library/fourier_checking.py +++ b/qiskit/circuit/library/fourier_checking.py @@ -66,7 +66,7 @@ def __init__(self, f: List[int], g: List[int]) -> None: .. plot:: from qiskit.circuit.library import FourierChecking - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization f = [1, -1, -1, -1] g = [1, 1, -1, -1] circuit = FourierChecking(f, g) diff --git a/qiskit/circuit/library/generalized_gates/gms.py b/qiskit/circuit/library/generalized_gates/gms.py index 46b28cac60af..fccb332d438c 100644 --- a/qiskit/circuit/library/generalized_gates/gms.py +++ b/qiskit/circuit/library/generalized_gates/gms.py @@ -44,7 +44,7 @@ class GMS(QuantumCircuit): .. plot:: from qiskit.circuit.library import GMS - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import numpy as np circuit = GMS(num_qubits=3, theta=[[0, np.pi/4, np.pi/8], [0, 0, np.pi/2], diff --git a/qiskit/circuit/library/generalized_gates/gr.py b/qiskit/circuit/library/generalized_gates/gr.py index acb83909cce0..e79851db4779 100644 --- a/qiskit/circuit/library/generalized_gates/gr.py +++ b/qiskit/circuit/library/generalized_gates/gr.py @@ -47,7 +47,7 @@ class GR(QuantumCircuit): .. plot:: from qiskit.circuit.library import GR - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import numpy as np circuit = GR(num_qubits=3, theta=np.pi/4, phi=np.pi/2) _generate_circuit_library_visualization(circuit) @@ -101,7 +101,7 @@ class GRX(GR): .. plot:: from qiskit.circuit.library import GRX - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import numpy as np circuit = GRX(num_qubits=3, theta=np.pi/4) _generate_circuit_library_visualization(circuit) @@ -149,7 +149,7 @@ class GRY(GR): .. plot:: from qiskit.circuit.library import GRY - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import numpy as np circuit = GRY(num_qubits=3, theta=np.pi/4) _generate_circuit_library_visualization(circuit) @@ -197,7 +197,7 @@ class GRZ(QuantumCircuit): .. plot:: from qiskit.circuit.library import GRZ - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import numpy as np circuit = GRZ(num_qubits=3, phi=np.pi/2) _generate_circuit_library_visualization(circuit) diff --git a/qiskit/circuit/library/generalized_gates/mcmt.py b/qiskit/circuit/library/generalized_gates/mcmt.py index 1a529b8859e1..c6ec0bda116e 100644 --- a/qiskit/circuit/library/generalized_gates/mcmt.py +++ b/qiskit/circuit/library/generalized_gates/mcmt.py @@ -164,7 +164,7 @@ class MCMTVChain(MCMT): .. plot:: from qiskit.circuit.library import MCMTVChain, ZGate - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = MCMTVChain(ZGate(), 2, 2) _generate_circuit_library_visualization(circuit.decompose()) diff --git a/qiskit/circuit/library/generalized_gates/permutation.py b/qiskit/circuit/library/generalized_gates/permutation.py index 44576518d624..d9151c09f7f7 100644 --- a/qiskit/circuit/library/generalized_gates/permutation.py +++ b/qiskit/circuit/library/generalized_gates/permutation.py @@ -62,7 +62,7 @@ def __init__( .. plot:: from qiskit.circuit.library import Permutation - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization A = [2,4,3,0,1] circuit = Permutation(5, A) _generate_circuit_library_visualization(circuit.decompose()) @@ -130,7 +130,7 @@ def __init__( from qiskit.circuit.quantumcircuit import QuantumCircuit from qiskit.circuit.library import PermutationGate - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization A = [2,4,3,0,1] permutation = PermutationGate(A) circuit = QuantumCircuit(5) diff --git a/qiskit/circuit/library/graph_state.py b/qiskit/circuit/library/graph_state.py index 25a3ccc95a2c..ceefff7971db 100644 --- a/qiskit/circuit/library/graph_state.py +++ b/qiskit/circuit/library/graph_state.py @@ -42,7 +42,7 @@ class GraphState(QuantumCircuit): .. plot:: from qiskit.circuit.library import GraphState - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization import rustworkx as rx G = rx.generators.cycle_graph(5) circuit = GraphState(rx.adjacency_matrix(G)) diff --git a/qiskit/circuit/library/hidden_linear_function.py b/qiskit/circuit/library/hidden_linear_function.py index 4742145ab51f..1140f1866f08 100644 --- a/qiskit/circuit/library/hidden_linear_function.py +++ b/qiskit/circuit/library/hidden_linear_function.py @@ -56,7 +56,7 @@ class HiddenLinearFunction(QuantumCircuit): .. plot:: from qiskit.circuit.library import HiddenLinearFunction - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization A = [[1, 1, 0], [1, 0, 1], [0, 1, 1]] circuit = HiddenLinearFunction(A) _generate_circuit_library_visualization(circuit) diff --git a/qiskit/circuit/library/iqp.py b/qiskit/circuit/library/iqp.py index e18c49d531d0..db65fbe294ad 100644 --- a/qiskit/circuit/library/iqp.py +++ b/qiskit/circuit/library/iqp.py @@ -47,7 +47,7 @@ class IQP(QuantumCircuit): .. plot:: from qiskit.circuit.library import IQP - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]] circuit = IQP(A) _generate_circuit_library_visualization(circuit.decompose()) diff --git a/qiskit/circuit/library/phase_estimation.py b/qiskit/circuit/library/phase_estimation.py index d513bf2ad3af..3311adf46324 100644 --- a/qiskit/circuit/library/phase_estimation.py +++ b/qiskit/circuit/library/phase_estimation.py @@ -74,7 +74,7 @@ def __init__( from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import PhaseEstimation - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization unitary = QuantumCircuit(2) unitary.x(0) unitary.y(1) diff --git a/qiskit/circuit/library/quantum_volume.py b/qiskit/circuit/library/quantum_volume.py index 43340dfff3ce..54a1b30dbec7 100644 --- a/qiskit/circuit/library/quantum_volume.py +++ b/qiskit/circuit/library/quantum_volume.py @@ -43,7 +43,7 @@ class QuantumVolume(QuantumCircuit): .. plot:: from qiskit.circuit.library import QuantumVolume - from qiskit.tools.jupyter.library import _generate_circuit_library_visualization + from qiskit.visualization.library import _generate_circuit_library_visualization circuit = QuantumVolume(5, 6, seed=10, classical_permutation=False) _generate_circuit_library_visualization(circuit.decompose()) diff --git a/qiskit/providers/__init__.py b/qiskit/providers/__init__.py index d7a52193dd15..5b9e8eb0477e 100644 --- a/qiskit/providers/__init__.py +++ b/qiskit/providers/__init__.py @@ -462,13 +462,12 @@ def get_translation_stage_plugin(self): handles submitting the circuits to the backend to be executed and returning a :class:`~qiskit.providers.Job` object. Depending on the type of backend this typically involves serializing the circuit object into the API format used by a -backend. For example, on IBMQ backends from the ``qiskit-ibmq-provider`` +backend. For example, on IBM backends from the ``qiskit-ibm-provider`` package this involves converting from a quantum circuit and options into a -`qobj `__ JSON payload and submitting -that to the IBM Quantum API. Since every backend interface is different (and -in the case of the local simulators serialization may not be needed) it is -expected that the backend's :obj:`~qiskit.providers.BackendV2.run` method will -handle this conversion. +:mod:`.qpy` payload embedded in JSON and submitting that to the IBM Quantum +API. Since every backend interface is different (and in the case of the local +simulators serialization may not be needed) it is expected that the backend's +:obj:`~qiskit.providers.BackendV2.run` method will handle this conversion. An example run method would be something like:: diff --git a/qiskit/providers/fake_provider/__init__.py b/qiskit/providers/fake_provider/__init__.py index 943869114f85..dae7311c68e0 100644 --- a/qiskit/providers/fake_provider/__init__.py +++ b/qiskit/providers/fake_provider/__init__.py @@ -65,21 +65,8 @@ Please note that the simulation is done using a noise model generated from system snapshots obtained in the past (sometimes a few years ago) and the results are not representative of the latest behaviours of the real quantum system which the fake backend is mimicking. If you want to - run noisy simulations to compare with the real quantum system, please follow steps below to - generate a simulator mimics a real quantum system with the latest calibration results. - - .. code-block:: python - - from qiskit.providers.ibmq import IBMQ - from qiskit.providers.aer import AerSimulator - - # get a real backend from a real provider - provider = IBMQ.load_account() - backend = provider.get_backend('ibmq_manila') - - # generate a simulator that mimics the real quantum system with the latest calibration results - backend_sim = AerSimulator.from_backend(backend) - + run noisy simulations to compare with the real quantum system you will need to create a noise + model from the current properties of the backend manually. Fake Providers ============== diff --git a/qiskit/test/__init__.py b/qiskit/test/__init__.py index 362eea2ba0ee..09a9a6c22d0f 100644 --- a/qiskit/test/__init__.py +++ b/qiskit/test/__init__.py @@ -13,6 +13,6 @@ """Functionality and helpers for testing Qiskit.""" from .base import QiskitTestCase -from .decorators import requires_aer_provider, online_test, slow_test +from .decorators import requires_aer_provider, slow_test from .reference_circuits import ReferenceCircuits from .utils import Path diff --git a/qiskit/test/base.py b/qiskit/test/base.py index 1dde885bd67f..067717b61e80 100644 --- a/qiskit/test/base.py +++ b/qiskit/test/base.py @@ -192,8 +192,6 @@ def tearDown(self): @classmethod def setUpClass(cls): super().setUpClass() - # Determines if the TestCase is using IBMQ credentials. - cls.using_ibmq_credentials = False # Set logging to file and stdout if the LOG_LEVEL envar is set. cls.log = logging.getLogger(cls.__name__) if os.getenv("LOG_LEVEL"): diff --git a/qiskit/test/decorators.py b/qiskit/test/decorators.py index a15ab9ccc361..c4ca9c67459f 100644 --- a/qiskit/test/decorators.py +++ b/qiskit/test/decorators.py @@ -15,7 +15,6 @@ import collections.abc import functools -import os import socket import sys from typing import Union, Callable, Type, Iterable @@ -99,91 +98,6 @@ def _wrapper(*args, **kwargs): return _wrapper -def _get_credentials(): - """Finds the credentials for a specific test and options. - - Returns: - Credentials: set of credentials - - Raises: - SkipTest: when credentials can't be found - """ - try: - from qiskit.providers.ibmq.credentials import Credentials, discover_credentials - except ImportError as ex: - raise unittest.SkipTest( - "qiskit-ibmq-provider could not be found, " - "and is required for executing online tests. " - 'To install, run "pip install qiskit-ibmq-provider" ' - "or check your installation." - ) from ex - - if os.getenv("IBMQ_TOKEN") and os.getenv("IBMQ_URL"): - return Credentials(os.getenv("IBMQ_TOKEN"), os.getenv("IBMQ_URL")) - elif os.getenv("QISKIT_TESTS_USE_CREDENTIALS_FILE"): - # Attempt to read the standard credentials. - discovered_credentials = discover_credentials() - - if discovered_credentials: - # Decide which credentials to use for testing. - if len(discovered_credentials) > 1: - raise unittest.SkipTest( - "More than 1 credential set found, use: " - "IBMQ_TOKEN and IBMQ_URL env variables to " - "set credentials explicitly" - ) - - # Use the first available credentials. - return list(discovered_credentials.values())[0] - raise unittest.SkipTest( - "No IBMQ credentials found for running the test. This is required for running online tests." - ) - - -def online_test(func): - """Decorator that signals that the test uses the network (and the online API): - - It involves: - * determines if the test should be skipped by checking environment - variables. - * if the `USE_ALTERNATE_ENV_CREDENTIALS` environment variable is - set, it reads the credentials from an alternative set of environment - variables. - * if the test is not skipped, it reads `qe_token` and `qe_url` from - `Qconfig.py`, environment variables or qiskitrc. - * if the test is not skipped, it appends `qe_token` and `qe_url` as - arguments to the test function. - - Args: - func (callable): test function to be decorated. - - Returns: - callable: the decorated function. - """ - - @functools.wraps(func) - def _wrapper(self, *args, **kwargs): - # To avoid checking the connection in each test - global HAS_NET_CONNECTION # pylint: disable=global-statement - - if TEST_OPTIONS["skip_online"]: - raise unittest.SkipTest("Skipping online tests") - - if HAS_NET_CONNECTION is None: - HAS_NET_CONNECTION = _has_connection("qiskit.org", 443) - - if not HAS_NET_CONNECTION: - raise unittest.SkipTest("Test requires internet connection.") - - credentials = _get_credentials() - self.using_ibmq_credentials = credentials.is_ibmq() - kwargs.update({"qe_token": credentials.token, "qe_url": credentials.url}) - - return func(self, *args, **kwargs) - - return _wrapper - - def enforce_subclasses_call( methods: Union[str, Iterable[str]], attr: str = "_enforce_subclasses_call_cache" ) -> Callable[[Type], Type]: diff --git a/qiskit/test/ibmq_mock.py b/qiskit/test/ibmq_mock.py deleted file mode 100644 index 73b30f4f44ec..000000000000 --- a/qiskit/test/ibmq_mock.py +++ /dev/null @@ -1,45 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Mock functions for qiskit.IBMQ.""" - -from unittest.mock import MagicMock -import qiskit -from qiskit.providers import fake_provider as backend_mocks - - -def mock_get_backend(backend): - """Replace qiskit.IBMQ with a mock that returns a single backend. - - Note this will set the value of qiskit.IBMQ to a MagicMock object. It is - intended to be run as part of docstrings with jupyter-example in a hidden - cell so that later examples which rely on ibmq devices so that the docs can - be built without requiring configured credentials. If used outside of this - context be aware that you will have to manually restore qiskit.IBMQ the - value to qiskit.providers.ibmq.IBMQ after you finish using your mock. - - Args: - backend (str): The class name as a string for the fake device to - return from the mock IBMQ object. For example, FakeVigo. - Raises: - NameError: If the specified value of backend - """ - mock_ibmq = MagicMock() - mock_provider = MagicMock() - if not hasattr(backend_mocks, backend): - raise NameError( - "The specified backend name is not a valid mock from qiskit.providers.fake_provider." - ) - fake_backend = getattr(backend_mocks, backend)() - mock_provider.get_backend.return_value = fake_backend - mock_ibmq.get_provider.return_value = mock_provider - qiskit.IBMQ = mock_ibmq diff --git a/qiskit/test/mock/__init__.py b/qiskit/test/mock/__init__.py deleted file mode 100644 index 760a0b1772a9..000000000000 --- a/qiskit/test/mock/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -""" -Utilities for mocking the IBMQ provider, including job responses and backends. - -The module includes dummy provider, backends, and jobs. -The purpose of these classes is to fake backends for testing purposes: -testing local timeouts, arbitrary responses or behavior, etc. - -The mock devices are mainly for testing the compiler. -""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import the desired object directly 'qiskit.providers.fake_provider'.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/__init__.py b/qiskit/test/mock/backends/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/almaden/__init__.py b/qiskit/test/mock/backends/almaden/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/almaden/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/armonk/__init__.py b/qiskit/test/mock/backends/armonk/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/armonk/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/athens/__init__.py b/qiskit/test/mock/backends/athens/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/athens/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/belem/__init__.py b/qiskit/test/mock/backends/belem/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/belem/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/boeblingen/__init__.py b/qiskit/test/mock/backends/boeblingen/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/boeblingen/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/bogota/__init__.py b/qiskit/test/mock/backends/bogota/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/bogota/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/brooklyn/__init__.py b/qiskit/test/mock/backends/brooklyn/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/brooklyn/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/burlington/__init__.py b/qiskit/test/mock/backends/burlington/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/burlington/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/cairo/__init__.py b/qiskit/test/mock/backends/cairo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/cairo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/cambridge/__init__.py b/qiskit/test/mock/backends/cambridge/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/cambridge/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/casablanca/__init__.py b/qiskit/test/mock/backends/casablanca/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/casablanca/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/essex/__init__.py b/qiskit/test/mock/backends/essex/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/essex/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/guadalupe/__init__.py b/qiskit/test/mock/backends/guadalupe/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/guadalupe/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/hanoi/__init__.py b/qiskit/test/mock/backends/hanoi/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/hanoi/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/jakarta/__init__.py b/qiskit/test/mock/backends/jakarta/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/jakarta/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/johannesburg/__init__.py b/qiskit/test/mock/backends/johannesburg/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/johannesburg/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/kolkata/__init__.py b/qiskit/test/mock/backends/kolkata/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/kolkata/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/lagos/__init__.py b/qiskit/test/mock/backends/lagos/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/lagos/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/lima/__init__.py b/qiskit/test/mock/backends/lima/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/lima/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/london/__init__.py b/qiskit/test/mock/backends/london/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/london/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/manhattan/__init__.py b/qiskit/test/mock/backends/manhattan/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/manhattan/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/manila/__init__.py b/qiskit/test/mock/backends/manila/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/manila/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/melbourne/__init__.py b/qiskit/test/mock/backends/melbourne/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/melbourne/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/montreal/__init__.py b/qiskit/test/mock/backends/montreal/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/montreal/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/mumbai/__init__.py b/qiskit/test/mock/backends/mumbai/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/mumbai/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/nairobi/__init__.py b/qiskit/test/mock/backends/nairobi/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/nairobi/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/ourense/__init__.py b/qiskit/test/mock/backends/ourense/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/ourense/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/paris/__init__.py b/qiskit/test/mock/backends/paris/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/paris/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/poughkeepsie/__init__.py b/qiskit/test/mock/backends/poughkeepsie/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/poughkeepsie/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/quito/__init__.py b/qiskit/test/mock/backends/quito/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/quito/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rochester/__init__.py b/qiskit/test/mock/backends/rochester/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rochester/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rome/__init__.py b/qiskit/test/mock/backends/rome/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rome/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rueschlikon/__init__.py b/qiskit/test/mock/backends/rueschlikon/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rueschlikon/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/santiago/__init__.py b/qiskit/test/mock/backends/santiago/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/santiago/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/singapore/__init__.py b/qiskit/test/mock/backends/singapore/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/singapore/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/sydney/__init__.py b/qiskit/test/mock/backends/sydney/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/sydney/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/tenerife/__init__.py b/qiskit/test/mock/backends/tenerife/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/tenerife/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/tokyo/__init__.py b/qiskit/test/mock/backends/tokyo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/tokyo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/toronto/__init__.py b/qiskit/test/mock/backends/toronto/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/toronto/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/valencia/__init__.py b/qiskit/test/mock/backends/valencia/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/valencia/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/vigo/__init__.py b/qiskit/test/mock/backends/vigo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/vigo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/washington/__init__.py b/qiskit/test/mock/backends/washington/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/washington/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/yorktown/__init__.py b/qiskit/test/mock/backends/yorktown/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/yorktown/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/tools/__init__.py b/qiskit/tools/__init__.py index 6bddd22ba889..38354279117a 100644 --- a/qiskit/tools/__init__.py +++ b/qiskit/tools/__init__.py @@ -29,16 +29,9 @@ Monitoring ---------- -A helper module to get IBM backend information and submitted job status. - -.. autofunction:: job_monitor -.. autofunction:: backend_monitor -.. autofunction:: backend_overview - .. automodule:: qiskit.tools.events """ from .parallel import parallel_map -from .monitor import job_monitor, backend_monitor, backend_overview from .events import progressbar diff --git a/qiskit/tools/jupyter/__init__.py b/qiskit/tools/jupyter/__init__.py deleted file mode 100644 index 6bc05d46f743..000000000000 --- a/qiskit/tools/jupyter/__init__.py +++ /dev/null @@ -1,138 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -""" -=========================================== -Jupyter Tools (:mod:`qiskit.tools.jupyter`) -=========================================== - -.. currentmodule:: qiskit.tools.jupyter - -A Collection of Jupyter magic functions and tools -that extend the functionality of Qiskit. - -Overview of all available backends -================================== - -.. code-block:: - - from qiskit.providers.ibmq import IBMQ - import qiskit.tools.jupyter - %matplotlib inline - - IBMQ.load_account() - - %qiskit_backend_overview - - -Detailed information on a single backend -======================================== - -.. code-block:: - - from qiskit.providers.ibmq import IBMQ - import qiskit.tools.jupyter - %matplotlib inline - - IBMQ.load_account() - provider = IBMQ.get_provider(hub='ibm-q') - backend = provider.get_backend('ibmq_vigo') - backend - - -Load Qiskit Job Watcher -======================= - -.. code-block:: - - import qiskit.tools.jupyter - %qiskit_job_watcher - - -HTMLProgressBar -=============== - -.. code-block:: - - import numpy as np - from qiskit.tools.parallel import parallel_map - import qiskit.tools.jupyter - - %qiskit_progress_bar - parallel_map(np.sin, np.linspace(0,10,100)); - - -Qiskit version table -==================== - -.. code-block:: - - import qiskit.tools.jupyter - %qiskit_version_table - - -Qiskit copyright -================ - -.. code-block:: - - import qiskit.tools.jupyter - %qiskit_copyright - -Monospaced output -================= - -.. code-block:: - - import qiskit.tools.jupyter - %monospaced_output - -""" -import warnings - -from IPython import get_ipython -from qiskit.providers.fake_provider import FakeBackend -from qiskit.utils import optionals as _optionals -from .jupyter_magics import ProgressBarMagic, StatusMagic -from .progressbar import HTMLProgressBar -from .version_table import VersionTable -from .copyright import Copyright -from .monospace import MonospacedOutput -from .job_watcher import JobWatcher, JobWatcherMagic - -_IP = get_ipython() -if _IP is not None: - _IP.register_magics(ProgressBarMagic) - _IP.register_magics(VersionTable) - _IP.register_magics(MonospacedOutput) - _IP.register_magics(Copyright) - _IP.register_magics(JobWatcherMagic) - if _optionals.HAS_MATPLOTLIB: - from .backend_overview import BackendOverview - from .backend_monitor import _backend_monitor - - _IP.register_magics(BackendOverview) - if _optionals.HAS_IBMQ: - from qiskit.providers.ibmq import IBMQBackend # pylint: disable=no-name-in-module - - HTML_FORMATTER = _IP.display_formatter.formatters["text/html"] - # Make _backend_monitor the html repr for IBM Q backends - HTML_FORMATTER.for_type(IBMQBackend, _backend_monitor) - HTML_FORMATTER.for_type(FakeBackend, _backend_monitor) - else: - warnings.warn( - "matplotlib can't be found, ensure you have matplotlib and other " - "visualization dependencies installed. You can run " - "'!pip install qiskit-terra[visualization]' to install it from " - "jupyter", - RuntimeWarning, - ) diff --git a/qiskit/tools/jupyter/backend_monitor.py b/qiskit/tools/jupyter/backend_monitor.py deleted file mode 100644 index ecb401521caf..000000000000 --- a/qiskit/tools/jupyter/backend_monitor.py +++ /dev/null @@ -1,588 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module for monitoring backends.""" - -import types -import math -import datetime -from IPython.display import display -import matplotlib.pyplot as plt -from matplotlib.patches import Circle -import ipywidgets as widgets -from qiskit.exceptions import QiskitError -from qiskit.visualization.gate_map import plot_gate_map, plot_error_map -from qiskit.providers.fake_provider import FakeBackend - -try: - from qiskit.providers.ibmq import IBMQBackend -except ImportError: - pass - -MONTH_NAMES = { - 1: "Jan.", - 2: "Feb.", - 3: "Mar.", - 4: "Apr.", - 5: "May", - 6: "June", - 7: "July", - 8: "Aug.", - 9: "Sept.", - 10: "Oct.", - 11: "Nov.", - 12: "Dec.", -} - - -def _load_jobs_data(self, change): - """Loads backend jobs data""" - if change["new"] == 4 and not self._did_jobs: - self._did_jobs = True - year = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - month = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - week = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - self.children[4].children = [year, month, week] - self.children[4].set_title(0, "Year") - self.children[4].set_title(1, "Month") - self.children[4].set_title(2, "Week") - self.children[4].selected_index = 1 - _build_job_history(self.children[4], self._backend) - - -def _backend_monitor(backend): - """A private function to generate a monitor widget - for a IBMQ backend repr. - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Raises: - QiskitError: Input is not an IBMQBackend - """ - if not isinstance(backend, IBMQBackend) and not isinstance(backend, FakeBackend): - raise QiskitError("Input variable is not of type IBMQBackend.") - title_style = "style='color:#ffffff;background-color:#000000;padding-top: 1%;" - title_style += "padding-bottom: 1%;padding-left: 1%; margin-top: 0px'" - title_html = f"

{backend.name()}

" - - details = [config_tab(backend)] - - tab_contents = ["Configuration"] - - # Empty jobs tab widget - jobs = widgets.Tab(layout=widgets.Layout(max_height="620px")) - - if not backend.configuration().simulator: - tab_contents.extend(["Qubit Properties", "Multi-Qubit Gates", "Error Map", "Job History"]) - - details.extend([qubits_tab(backend), gates_tab(backend), detailed_map(backend), jobs]) - - tabs = widgets.Tab(layout=widgets.Layout(overflow_y="scroll")) - tabs.children = details - for i in range(len(details)): - tabs.set_title(i, tab_contents[i]) - - # Make backend accessible to tabs widget - tabs._backend = backend - tabs._did_jobs = False - tabs._update = types.MethodType(_load_jobs_data, tabs) - - tabs.observe(tabs._update, names="selected_index") - - title_widget = widgets.HTML(value=title_html, layout=widgets.Layout(margin="0px 0px 0px 0px")) - - bmonitor = widgets.VBox( - [title_widget, tabs], - layout=widgets.Layout( - border="4px solid #000000", max_height="650px", min_height="650px", overflow_y="hidden" - ), - ) - display(bmonitor) - - -def config_tab(backend): - """The backend configuration widget. - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Returns: - grid: A GridBox widget. - """ - status = backend.status().to_dict() - config = backend.configuration().to_dict() - - config_dict = {**status, **config} - - upper_list = ["n_qubits"] - - if "quantum_volume" in config.keys(): - if config["quantum_volume"]: - upper_list.append("quantum_volume") - - upper_list.extend( - [ - "operational", - "status_msg", - "pending_jobs", - "backend_version", - "basis_gates", - "max_shots", - "max_experiments", - ] - ) - - lower_list = list(set(config_dict.keys()).difference(upper_list)) - # Remove gates because they are in a different tab - lower_list.remove("gates") - # Look for hamiltonian - if "hamiltonian" in lower_list: - htex = config_dict["hamiltonian"]["h_latex"] - config_dict["hamiltonian"] = "$$%s$$" % htex - - upper_str = "" - upper_str += """""" - - footer = "
" - - # Upper HBox widget data - - upper_str += "PropertyValue" - for key in upper_list: - upper_str += "{}{}".format( - key, - config_dict[key], - ) - upper_str += footer - - upper_table = widgets.HTMLMath( - value=upper_str, layout=widgets.Layout(width="100%", grid_area="left") - ) - - image_widget = widgets.Output( - layout=widgets.Layout( - display="flex-inline", - grid_area="right", - padding="10px 10px 10px 10px", - width="auto", - max_height="325px", - align_items="center", - ) - ) - - if not config["simulator"]: - with image_widget: - qubit_size = 24 - if config["n_qubits"] > 20: - qubit_size = 34 - gate_map = plot_gate_map(backend, qubit_size=qubit_size) - display(gate_map) - plt.close(gate_map) - - lower_str = "" - lower_str += """""" - lower_str += "" - for key in lower_list: - if key != "name": - lower_str += f"" - lower_str += footer - - lower_table = widgets.HTMLMath( - value=lower_str, layout=widgets.Layout(width="auto", grid_area="bottom") - ) - - grid = widgets.GridBox( - children=[upper_table, image_widget, lower_table], - layout=widgets.Layout( - grid_template_rows="auto auto", - grid_template_columns="31% 23% 23% 23%", - grid_template_areas=""" - "left right right right" - "bottom bottom bottom bottom" - """, - grid_gap="0px 0px", - ), - ) - - return grid - - -def qubits_tab(backend): - """The qubits properties widget - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Returns: - VBox: A VBox widget. - """ - props = backend.properties() - - header_html = "
{key}: {value}
" - update_date = props.last_update_date.strftime("%a %d %B %Y at %H:%M %Z") - header_html = header_html.format(key="last_update_date", value=update_date) - - update_date_widget = widgets.HTML(value=header_html) - - qubit_html = "
{key}{config_dict[key]}
" - qubit_html += """""" - - qubit_html += "" - qubit_footer = "
FrequencyT1T2
" - - gate_error_title = "" - - for index, qubit_data in enumerate(props.qubits): - name = "Q%s" % index - gate_data = [gate for gate in props.gates if gate.qubits == [index]] - - cal_data = dict.fromkeys(["T1", "T2", "frequency", "readout_error"], "Unknown") - for nduv in qubit_data: - if nduv.name in cal_data: - cal_data[nduv.name] = str(round(nduv.value, 5)) + " " + nduv.unit - - gate_names = [] - gate_error = [] - for gd in gate_data: - if gd.gate in ["id"]: - continue - try: - gate_error.append(str(round(props.gate_error(gd.gate, index), 5))) - gate_names.append(gd.gate.upper()) - except QiskitError: - pass - - if not gate_error_title: - for gname in gate_names: - gate_error_title += f"{gname}" - qubit_html += gate_error_title + "Readout error" - - qubit_html += f"{name}" - qubit_html += ( - f"{cal_data['frequency']}{cal_data['T1']}{cal_data['T2']}" - ) - for gerror in gate_error: - qubit_html += f"{gerror}" - qubit_html += f"{cal_data['readout_error']}" - - qubit_html += qubit_footer - - qubit_widget = widgets.HTML(value=qubit_html) - - out = widgets.VBox([update_date_widget, qubit_widget]) - - return out - - -def gates_tab(backend): - """The multiple qubit gate error widget. - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Returns: - VBox: A VBox widget. - """ - props = backend.properties() - - multi_qubit_gates = [g for g in props.gates if len(g.qubits) > 1] - - header_html = "
{key}: {value}
" - header_html = header_html.format(key="last_update_date", value=props.last_update_date) - - update_date_widget = widgets.HTML(value=header_html, layout=widgets.Layout(grid_area="top")) - - gate_html = "" - gate_html += """""" - - gate_html += "" - gate_footer = "
TypeGate error
" - - # Split gates into two columns - left_num = math.ceil(len(multi_qubit_gates) / 3) - mid_num = math.ceil((len(multi_qubit_gates) - left_num) / 2) - - left_table = gate_html - - for qub in range(left_num): - gate = multi_qubit_gates[qub] - qubits = gate.qubits - ttype = gate.gate - error = round(props.gate_error(gate.gate, qubits), 5) - - left_table += "%s" - left_table += "%s%s" - left_table = left_table % (f"{ttype}{qubits[0]}_{qubits[1]}", ttype, error) - left_table += gate_footer - - middle_table = gate_html - - for qub in range(left_num, left_num + mid_num): - gate = multi_qubit_gates[qub] - qubits = gate.qubits - ttype = gate.gate - error = round(props.gate_error(gate.gate, qubits), 5) - - middle_table += "%s" - middle_table += "%s%s" - middle_table = middle_table % (f"{ttype}{qubits[0]}_{qubits[1]}", ttype, error) - middle_table += gate_footer - - right_table = gate_html - - for qub in range(left_num + mid_num, len(multi_qubit_gates)): - gate = multi_qubit_gates[qub] - qubits = gate.qubits - ttype = gate.gate - error = round(props.gate_error(gate.gate, qubits), 5) - - right_table += "%s" - right_table += "%s%s" - right_table = right_table % (f"{ttype}{qubits[0]}_{qubits[1]}", ttype, error) - right_table += gate_footer - - left_table_widget = widgets.HTML(value=left_table, layout=widgets.Layout(grid_area="left")) - middle_table_widget = widgets.HTML( - value=middle_table, layout=widgets.Layout(grid_area="middle") - ) - right_table_widget = widgets.HTML(value=right_table, layout=widgets.Layout(grid_area="right")) - - grid = widgets.GridBox( - children=[update_date_widget, left_table_widget, middle_table_widget, right_table_widget], - layout=widgets.Layout( - grid_template_rows="auto auto", - grid_template_columns="33% 33% 33%", - grid_template_areas=""" - "top top top" - "left middle right" - """, - grid_gap="0px 0px", - ), - ) - - return grid - - -def detailed_map(backend): - """Widget for displaying detailed noise map. - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Returns: - GridBox: Widget holding noise map images. - """ - error_widget = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center") - ) - with error_widget: - display(plot_error_map(backend, figsize=(11, 9), show_title=False)) - return error_widget - - -def job_history(backend): - """Widget for displaying job history - - Args: - backend (IBMQBackend | FakeBackend): The backend. - - Returns: - Tab: A tab widget for history images. - """ - year = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - month = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - week = widgets.Output( - layout=widgets.Layout(display="flex-inline", align_items="center", min_height="400px") - ) - - tabs = widgets.Tab(layout=widgets.Layout(max_height="620px")) - tabs.children = [year, month, week] - tabs.set_title(0, "Year") - tabs.set_title(1, "Month") - tabs.set_title(2, "Week") - tabs.selected_index = 1 - - _build_job_history(tabs, backend) - return tabs - - -def _build_job_history(tabs, backend): - - past_year_date = datetime.datetime.now() - datetime.timedelta(days=365) - date_filter = {"creationDate": {"gt": past_year_date.isoformat()}} - jobs = backend.jobs(limit=None, db_filter=date_filter) - - with tabs.children[0]: - year_plot = plot_job_history(jobs, interval="year") - display(year_plot) - plt.close(year_plot) - - with tabs.children[1]: - month_plot = plot_job_history(jobs, interval="month") - display(month_plot) - plt.close(month_plot) - - with tabs.children[2]: - week_plot = plot_job_history(jobs, interval="week") - display(week_plot) - plt.close(week_plot) - - -def plot_job_history(jobs, interval="year"): - """Plots the job history of the user from the given list of jobs. - - Args: - jobs (list): A list of jobs with type IBMQjob. - interval (str): Interval over which to examine. - - Returns: - fig: A Matplotlib figure instance. - """ - - def get_date(job): - """Returns a datetime object from a IBMQJob instance. - - Args: - job (IBMQJob): A job. - - Returns: - dt: A datetime object. - """ - creation_date = job.creation_date() - - if isinstance(creation_date, datetime.datetime): - return creation_date - - return datetime.datetime.strptime(creation_date, "%Y-%m-%dT%H:%M:%S.%fZ") - - current_time = datetime.datetime.now() - - if interval == "year": - bins = [(current_time - datetime.timedelta(days=k * 365 / 12)) for k in range(12)] - elif interval == "month": - bins = [(current_time - datetime.timedelta(days=k)) for k in range(30)] - elif interval == "week": - bins = [(current_time - datetime.timedelta(days=k)) for k in range(7)] - - binned_jobs = [0] * len(bins) - - if interval == "year": - for job in jobs: - for ind, dat in enumerate(bins): - date = get_date(job) - if date.month == dat.month: - binned_jobs[ind] += 1 - break - else: - continue - else: - for job in jobs: - for ind, dat in enumerate(bins): - date = get_date(job) - if date.day == dat.day and date.month == dat.month: - binned_jobs[ind] += 1 - break - else: - continue - - nz_bins = [] - nz_idx = [] - for ind, val in enumerate(binned_jobs): - if val != 0: - nz_idx.append(ind) - nz_bins.append(val) - - total_jobs = sum(binned_jobs) - - colors = ["#003f5c", "#ffa600", "#374c80", "#ff764a", "#7a5195", "#ef5675", "#bc5090"] - - if interval == "year": - labels = [f"{str(bins[b].year)[2:]}-{MONTH_NAMES[bins[b].month]}" for b in nz_idx] - else: - labels = [f"{MONTH_NAMES[bins[b].month]}-{bins[b].day}" for b in nz_idx] - fig, ax = plt.subplots(1, 1, figsize=(5.5, 5.5)) - ax.pie( - nz_bins[::-1], - labels=labels, - colors=colors, - textprops={"fontsize": 14}, - rotatelabels=True, - counterclock=False, - radius=1, - ) - ax.add_artist(Circle((0, 0), 0.7, color="white", zorder=1)) - ax.text(0, 0, total_jobs, horizontalalignment="center", verticalalignment="center", fontsize=26) - return fig diff --git a/qiskit/tools/jupyter/backend_overview.py b/qiskit/tools/jupyter/backend_overview.py deleted file mode 100644 index f72ad8ba1938..000000000000 --- a/qiskit/tools/jupyter/backend_overview.py +++ /dev/null @@ -1,322 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module for monitoring backends.""" - -import time -import threading -import types -from IPython.display import display -from IPython.core.magic import line_magic, Magics, magics_class -from IPython.core import magic_arguments -import matplotlib.pyplot as plt -import ipywidgets as widgets -from qiskit.tools.monitor.overview import get_unique_backends -from qiskit.visualization.gate_map import plot_gate_map - - -@magics_class -class BackendOverview(Magics): - """A class of status magic functions.""" - - @line_magic - @magic_arguments.magic_arguments() - @magic_arguments.argument( - "-i", "--interval", type=float, default=60, help="Interval for status check." - ) - def qiskit_backend_overview(self, line=""): - """A Jupyter magic function to monitor backends.""" - args = magic_arguments.parse_argstring(self.qiskit_backend_overview, line) - - unique_hardware_backends = get_unique_backends() - _value = "

Backend Overview

" - backend_title = widgets.HTML(value=_value, layout=widgets.Layout(margin="0px 0px 0px 0px")) - - build_back_widgets = [backend_widget(b) for b in unique_hardware_backends] - - _backends = [] - # Sort backends by operational or not - oper_ord_backends = [] - for n, back in enumerate(unique_hardware_backends): - if back.status().operational: - oper_ord_backends = [build_back_widgets[n]] + oper_ord_backends - _backends = [back] + _backends - else: - oper_ord_backends = oper_ord_backends + [build_back_widgets[n]] - _backends = _backends + [back] - - qubit_label = widgets.Label(value="Num. Qubits") - qv_label = widgets.Label(value="Quantum Vol.") - pend_label = widgets.Label( - value="Pending Jobs", layout=widgets.Layout(margin="5px 0px 0px 0px") - ) - least_label = widgets.Label( - value="Least Busy", layout=widgets.Layout(margin="10px 0px 0px 0px") - ) - oper_label = widgets.Label( - value="Operational", layout=widgets.Layout(margin="5px 0px 0px 0px") - ) - t12_label = widgets.Label( - value="Avg. T1 / T2", layout=widgets.Layout(margin="10px 0px 0px 0px") - ) - cx_label = widgets.Label( - value="Avg. CX Err.", layout=widgets.Layout(margin="8px 0px 0px 0px") - ) - meas_label = widgets.Label( - value="Avg. Meas. Err.", layout=widgets.Layout(margin="8px 0px 0px 0px") - ) - - labels_widget = widgets.VBox( - [ - qubit_label, - qv_label, - pend_label, - oper_label, - least_label, - t12_label, - cx_label, - meas_label, - ], - layout=widgets.Layout(margin="295px 0px 0px 0px", min_width="100px"), - ) - - backend_grid = GridBox_with_thread( - children=oper_ord_backends, - layout=widgets.Layout( - grid_template_columns="250px " * len(unique_hardware_backends), - grid_template_rows="auto", - grid_gap="0px 25px", - ), - ) - - backend_grid._backends = _backends # pylint: disable=attribute-defined-outside-init - backend_grid._update = types.MethodType( # pylint: disable=attribute-defined-outside-init - update_backend_info, backend_grid - ) - - backend_grid._thread = threading.Thread( # pylint: disable=attribute-defined-outside-init - target=backend_grid._update, args=(args.interval,) - ) - backend_grid._thread.start() - - back_box = widgets.HBox([labels_widget, backend_grid]) - - back_monitor = widgets.VBox([backend_title, back_box]) - display(back_monitor) - - -class GridBox_with_thread(widgets.GridBox): # pylint: disable=invalid-name - """A GridBox that will close an attached thread""" - - def __del__(self): - """Object disposal""" - if hasattr(self, "_thread"): - try: - self._thread.do_run = False - self._thread.join() - except Exception: # pylint: disable=broad-except - pass - self.close() - - -def backend_widget(backend): - """Creates a backend widget.""" - config = backend.configuration().to_dict() - props = backend.properties().to_dict() - - name = widgets.HTML(value=f"

{backend.name()}

", layout=widgets.Layout()) - - num_qubits = config["n_qubits"] - - qv_val = "-" - if "quantum_volume" in config.keys(): - if config["quantum_volume"]: - qv_val = config["quantum_volume"] - - qubit_count = widgets.HTML( - value=f"
{num_qubits}
", - layout=widgets.Layout(justify_content="center"), - ) - - qv_value = widgets.HTML( - value=f"
{qv_val}
", - layout=widgets.Layout(justify_content="center"), - ) - - cmap = widgets.Output( - layout=widgets.Layout( - min_width="250px", - max_width="250px", - max_height="250px", - min_height="250px", - justify_content="center", - align_items="center", - margin="0px 0px 0px 0px", - ) - ) - - with cmap: - _cmap_fig = plot_gate_map(backend, plot_directed=False, label_qubits=False) - if _cmap_fig is not None: - display(_cmap_fig) - # Prevents plot from showing up twice. - plt.close(_cmap_fig) - - pending = generate_jobs_pending_widget() - - is_oper = widgets.HTML(value="
", layout=widgets.Layout(justify_content="center")) - - least_busy = widgets.HTML(value="
", layout=widgets.Layout(justify_content="center")) - - t1_units = props["qubits"][0][0]["unit"] - avg_t1 = round(sum(q[0]["value"] for q in props["qubits"]) / num_qubits, 1) - avg_t2 = round(sum(q[1]["value"] for q in props["qubits"]) / num_qubits, 1) - t12_widget = widgets.HTML( - value=f"
{avg_t1} / {avg_t2} {t1_units}
", - layout=widgets.Layout(), - ) - - avg_cx_err = "NA" - if config["coupling_map"]: - sum_cx_err = 0 - num_cx = 0 - for gate in props["gates"]: - if gate["gate"] == "cx": - for param in gate["parameters"]: - if param["name"] == "gate_error": - # Value == 1.0 means gate effectively off - if param["value"] != 1.0: - sum_cx_err += param["value"] - num_cx += 1 - if num_cx > 0: - avg_cx_err = round(sum_cx_err / num_cx, 4) - - cx_widget = widgets.HTML(value=f"
{avg_cx_err}
", layout=widgets.Layout()) - - avg_meas_err = 0 - for qub in props["qubits"]: - for item in qub: - if item["name"] == "readout_error": - avg_meas_err += item["value"] - avg_meas_err = round(avg_meas_err / num_qubits, 4) - meas_widget = widgets.HTML(value=f"
{avg_meas_err}
", layout=widgets.Layout()) - - out = widgets.VBox( - [ - name, - cmap, - qubit_count, - qv_value, - pending, - is_oper, - least_busy, - t12_widget, - cx_widget, - meas_widget, - ], - layout=widgets.Layout(display="inline-flex", flex_flow="column", align_items="center"), - ) - - out._is_alive = True - return out - - -def update_backend_info(self, interval=60): - """Updates the monitor info - Called from another thread. - """ - my_thread = threading.current_thread() - current_interval = 0 - started = False - all_dead = False - stati = [None] * len(self._backends) - while getattr(my_thread, "do_run", True) and not all_dead: - if current_interval == interval or started is False: - for ind, back in enumerate(self._backends): - _value = self.children[ind].children[2].value - _head = _value.split("")[0] - try: - _status = back.status() - stati[ind] = _status - except Exception: # pylint: disable=broad-except - self.children[ind].children[2].value = _value.replace( - _head, "
" - ) - self.children[ind]._is_alive = False - else: - self.children[ind]._is_alive = True - self.children[ind].children[2].value = _value.replace(_head, "
") - - idx = list(range(len(self._backends))) - pending = [s.pending_jobs for s in stati] - _, least_idx = zip(*sorted(zip(pending, idx))) - - # Make sure least pending is operational - for ind in least_idx: - if stati[ind].operational: - least_pending_idx = ind - break - - for var in idx: - if var == least_pending_idx: - self.children[var].children[6].value = "
True
" - else: - self.children[var].children[6].value = "
False
" - - self.children[var].children[4].children[1].max = max( - self.children[var].children[4].children[1].max, pending[var] + 10 - ) - self.children[var].children[4].children[1].value = pending[var] - if stati[var].operational: - self.children[var].children[5].value = "
True
" - else: - self.children[var].children[5].value = "
False
" - - started = True - current_interval = 0 - time.sleep(1) - all_dead = not any(wid._is_alive for wid in self.children) - current_interval += 1 - - -def generate_jobs_pending_widget(): - """Generates a jobs_pending progress bar widget.""" - pbar = widgets.IntProgress( - value=0, - min=0, - max=50, - description="", - orientation="horizontal", - layout=widgets.Layout(max_width="180px"), - ) - pbar.style.bar_color = "#71cddd" - - pbar_current = widgets.Label(value=str(pbar.value), layout=widgets.Layout(min_width="auto")) - pbar_max = widgets.Label(value=str(pbar.max), layout=widgets.Layout(min_width="auto")) - - def _on_max_change(change): - pbar_max.value = str(change["new"]) - - def _on_val_change(change): - pbar_current.value = str(change["new"]) - - pbar.observe(_on_max_change, names="max") - pbar.observe(_on_val_change, names="value") - - jobs_widget = widgets.HBox( - [pbar_current, pbar, pbar_max], - layout=widgets.Layout(max_width="250px", min_width="250px", justify_content="center"), - ) - - return jobs_widget diff --git a/qiskit/tools/jupyter/copyright.py b/qiskit/tools/jupyter/copyright.py deleted file mode 100644 index d759a6ab5f4f..000000000000 --- a/qiskit/tools/jupyter/copyright.py +++ /dev/null @@ -1,42 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. -# pylint: disable=unused-argument - -"""A module for monitoring backends.""" - -import datetime -from IPython.display import HTML, display -from IPython.core.magic import line_magic, Magics, magics_class - - -@magics_class -class Copyright(Magics): - """A class of status magic functions.""" - - @line_magic - def qiskit_copyright(self, line="", cell=None): - """A Jupyter magic function return qiskit copyright""" - now = datetime.datetime.now() - - html = "
" - html += "

This code is a part of Qiskit

" - html += "

© Copyright IBM 2017, %s.

" % now.year - html += "

This code is licensed under the Apache License, Version 2.0. You may
" - html += "obtain a copy of this license in the LICENSE.txt file in the root directory
" - html += "of this source tree or at http://www.apache.org/licenses/LICENSE-2.0." - - html += "

Any modifications or derivative works of this code must retain this
" - html += "copyright notice, and modified files need to carry a notice indicating
" - html += "that they have been altered from the originals.

" - html += "
" - return display(HTML(html)) diff --git a/qiskit/tools/jupyter/job_watcher.py b/qiskit/tools/jupyter/job_watcher.py deleted file mode 100644 index 7ad6f7014569..000000000000 --- a/qiskit/tools/jupyter/job_watcher.py +++ /dev/null @@ -1,167 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. -# pylint: disable=unused-argument - -"""A module for the job watcher""" - -from IPython.core.magic import line_magic, Magics, magics_class -from qiskit.tools.events.pubsub import Subscriber -from qiskit.utils import optionals as _optionals - -from .job_widgets import build_job_viewer, make_clear_button, make_labels, create_job_widget -from .watcher_monitor import _job_monitor - - -@_optionals.HAS_IBMQ.require_in_instance -class JobWatcher(Subscriber): - """An IBM Q job watcher.""" - - def __init__(self): - super().__init__() - self.jobs = [] - self._init_subscriber() - self.job_viewer = None - self._clear_button = make_clear_button(self) - self._labels = make_labels() - self.refresh_viewer() - - def refresh_viewer(self): - """Refreshes the job viewer.""" - if self.job_viewer is not None: - self.job_viewer.children[0].children = [self._clear_button, self._labels] + list( - reversed(self.jobs) - ) - - def stop_viewer(self): - """Stops the job viewer.""" - if self.job_viewer: - self.job_viewer.close() - self.job_viewer = None - - def start_viewer(self): - """Starts the job viewer""" - self.job_viewer = build_job_viewer() - self.refresh_viewer() - - def update_single_job(self, update_info): - """Update a single job instance - - Args: - update_info (tuple): Updated job info. - """ - job_id = update_info[0] - found_job = False - ind = None - for idx, job in enumerate(self.jobs): - if job.job_id == job_id: - found_job = True - ind = idx - break - if found_job: - job_wid = self.jobs[ind] - # update status - if update_info[1] == "DONE": - stat = f"{update_info[1]}" - elif update_info[1] == "ERROR": - stat = f"{update_info[1]}" - elif update_info[1] == "CANCELLED": - stat = f"{update_info[1]}" - else: - stat = update_info[1] - job_wid.children[3].value = stat - # update queue - if update_info[2] == 0: - queue = "-" - else: - queue = str(update_info[2]) - job_wid.children[4].value = queue - # update msg - job_wid.children[5].value = update_info[3] - - def cancel_job(self, job_id): - """Cancels a job in the watcher - - Args: - job_id (str): Job id to remove. - - Raises: - Exception: Job id not found. - """ - from qiskit.providers.ibmq.job.exceptions import ( # pylint: disable=no-name-in-module - IBMQJobApiError, - ) - - do_pop = False - ind = None - for idx, job in enumerate(self.jobs): - if job.job_id == job_id: - do_pop = True - ind = idx - break - if not do_pop: - raise Exception("job_id not found") - if "CANCELLED" not in self.jobs[ind].children[3].value: - try: - self.jobs[ind].job.cancel() - status = self.jobs[ind].job.status() - except IBMQJobApiError: - pass - else: - self.update_single_job((self.jobs[ind].job_id, status.name, 0, status.value)) - - def clear_done(self): - """Clears the done jobs from the list.""" - _temp_jobs = [] - do_refresh = False - for job in self.jobs: - job_str = job.children[3].value - if not (("DONE" in job_str) or ("CANCELLED" in job_str) or ("ERROR" in job_str)): - _temp_jobs.append(job) - else: - job.close() - do_refresh = True - if do_refresh: - self.jobs = _temp_jobs - self.refresh_viewer() - - def _init_subscriber(self): - def _add_job(job): - status = job.status() - job_widget = create_job_widget( - self, job, job.backend(), status.name, job.queue_position(), status.value - ) - self.jobs.append(job_widget) - self.refresh_viewer() - _job_monitor(job, status, self) - - self.subscribe("ibmq.job.start", _add_job) - - -@magics_class -class JobWatcherMagic(Magics): - """A class for enabling/disabling the job watcher.""" - - @line_magic - def qiskit_job_watcher(self, line="", cell=None): - """A Jupyter magic function to enable job watcher.""" - _JOB_WATCHER.stop_viewer() - _JOB_WATCHER.start_viewer() - - @line_magic - def qiskit_disable_job_watcher(self, line="", cell=None): - """A Jupyter magic function to disable job watcher.""" - _JOB_WATCHER.stop_viewer() - - -if _optionals.HAS_IBMQ: - # The Jupyter job watcher instance - _JOB_WATCHER = JobWatcher() diff --git a/qiskit/tools/jupyter/job_widgets.py b/qiskit/tools/jupyter/job_widgets.py deleted file mode 100644 index f854d5ee1031..000000000000 --- a/qiskit/tools/jupyter/job_widgets.py +++ /dev/null @@ -1,160 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module of widgets for job tracking""" - -import ipywidgets as widgets -from IPython.display import display, Javascript - - -def make_clear_button(watcher): - """Makes the clear button - - Args: - watcher (widget): The watcher widget instance. - - Returns: - widget: The clear button widget. - """ - clear = widgets.Button( - description="Clear", - button_style="primary", - layout=widgets.Layout(width="70px", grid_area="right", padding="0px 0px 0px 0px"), - ) - - def on_clear_button_clicked(_): - watcher.clear_done() - - clear.on_click(on_clear_button_clicked) - - clear_button = widgets.GridBox( - children=[clear], - layout=widgets.Layout( - width="100%", - grid_template_columns="20% 20% 20% 20% 20%", - grid_template_areas=""" - ". . . . right " - """, - ), - ) - return clear_button - - -def make_labels(): - """Makes the labels widget. - - Returns: - widget: The labels widget. - """ - labels0 = widgets.HTML(value="
Job ID
", layout=widgets.Layout(width="190px")) - labels1 = widgets.HTML(value="
Backend
", layout=widgets.Layout(width="145px")) - labels2 = widgets.HTML(value="
Status
", layout=widgets.Layout(width="95px")) - labels3 = widgets.HTML(value="
Queue
", layout=widgets.Layout(width="70px")) - labels4 = widgets.HTML(value="
Message
") - - labels = widgets.HBox( - children=[labels0, labels1, labels2, labels3, labels4], - layout=widgets.Layout(width="600px", margin="0px 0px 0px 37px"), - ) - return labels - - -def create_job_widget(watcher, job, backend, status="", queue_pos=None, msg=""): - """Creates a widget corresponding to a particular job instance. - - Args: - watcher (widget): The job watcher instance. - job (IBMQJob): The job. - backend (str): The backend the job is running on. - status (str): The job status. - queue_pos (int): Queue position, if any. - msg (str): Job message, if any. - - Returns: - widget: The job widget - """ - job_id = job.job_id() - - id_label = widgets.HTML(value=f"{job_id}", layout=widgets.Layout(width="190px")) - backend_label = widgets.HTML(value=f"{backend}", layout=widgets.Layout(width="145px")) - status_label = widgets.HTML(value=f"{status}", layout=widgets.Layout(width="95px")) - if queue_pos is None: - queue_pos = "-" - else: - queue_pos = str(queue_pos) - queue_label = widgets.HTML(value=f"{queue_pos}", layout=widgets.Layout(width="70px")) - - msg_label = widgets.HTML( - value=f"

{msg}

", - layout=widgets.Layout(overflow_x="scroll"), - ) - - close_button = widgets.Button( - button_style="", icon="close", layout=widgets.Layout(width="32px", margin="0px 5px 0px 0px") - ) - close_button.style.button_color = "white" - - def cancel_on_click(_): - watcher.cancel_job(job_id) - - close_button.on_click(cancel_on_click) - - job_grid = widgets.HBox( - children=[close_button, id_label, backend_label, status_label, queue_label, msg_label], - layout=widgets.Layout(min_width="700px", max_width="700px"), - ) - job_grid.job_id = job_id - job_grid.job = job - return job_grid - - -def build_job_viewer(): - """Builds the job viewer widget - - Returns: - widget: Job viewer. - """ - acc = widgets.Accordion( - children=[widgets.VBox(layout=widgets.Layout(max_width="710px", min_width="710px"))], - layout=widgets.Layout( - width="auto", - max_width="750px", - max_height="500px", - overflow_y="scroll", - overflow_x="hidden", - ), - ) - acc.set_title(0, "IBMQ Jobs") - acc.selected_index = None - acc.layout.visibility = "hidden" - display(acc) - acc._dom_classes = ["job_widget"] - display( - Javascript( - """ - const isLab = window['Jupyter'] === undefined; - const notebook = document.querySelector( isLab ? 'div.jp-Notebook' : '#site'); - const jobWidget = document.querySelector('div.job_widget'); - notebook.prepend(jobWidget); - jobWidget.style.zIndex = '999'; - jobWidget.style.position = isLab ? 'sticky' : 'fixed'; - jobWidget.style.boxShadow = '5px 5px 5px -3px black'; - jobWidget.style.opacity = '0.95'; - if (isLab) { - jobWidget.style.top = '0'; - jobWidget.style.left = '0'; - } - """ - ) - ) - acc.layout.visibility = "visible" - return acc diff --git a/qiskit/tools/jupyter/jupyter_magics.py b/qiskit/tools/jupyter/jupyter_magics.py deleted file mode 100644 index 5fc9d92b7bb6..000000000000 --- a/qiskit/tools/jupyter/jupyter_magics.py +++ /dev/null @@ -1,190 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module of magic functions""" - -import time -import threading -from IPython import get_ipython -from IPython.display import display -from IPython.core import magic_arguments -from IPython.core.magic import cell_magic, line_magic, Magics, magics_class, register_line_magic - -from qiskit.utils import optionals as _optionals -from qiskit.utils.deprecation import deprecate_func -import qiskit -from qiskit.tools.events.progressbar import TextProgressBar -from .progressbar import HTMLProgressBar -from .library import circuit_library_widget - - -def _html_checker(job_var, interval, status, header, _interval_set=False): - """Internal function that updates the status - of a HTML job monitor. - - Args: - job_var (BaseJob): The job to keep track of. - interval (int): The status check interval - status (widget): HTML ipywidget for output to screen - header (str): String representing HTML code for status. - _interval_set (bool): Was interval set by user? - """ - job_status = job_var.status() - job_status_name = job_status.name - job_status_msg = job_status.value - status.value = header % (job_status_msg) - while job_status_name not in ["DONE", "CANCELLED"]: - time.sleep(interval) - job_status = job_var.status() - job_status_name = job_status.name - job_status_msg = job_status.value - if job_status_name == "ERROR": - break - if job_status_name == "QUEUED": - job_status_msg += " (%s)" % job_var.queue_position() - if job_var.queue_position() is None: - interval = 2 - elif not _interval_set: - interval = max(job_var.queue_position(), 2) - else: - if not _interval_set: - interval = 2 - status.value = header % (job_status_msg) - - status.value = header % (job_status_msg) - - -@magics_class -class StatusMagic(Magics): - """A class of status magic functions.""" - - @cell_magic - @magic_arguments.magic_arguments() - @magic_arguments.argument( - "-i", "--interval", type=float, default=None, help="Interval for status check." - ) - @_optionals.HAS_IPYWIDGETS.require_in_call - def qiskit_job_status(self, line="", cell=None): - """A Jupyter magic function to check the status of a Qiskit job instance.""" - import ipywidgets as widgets - - args = magic_arguments.parse_argstring(self.qiskit_job_status, line) - - if args.interval is None: - args.interval = 2 - _interval_set = False - else: - _interval_set = True - - # Split cell lines to get LHS variables - cell_lines = cell.split("\n") - line_vars = [] - for cline in cell_lines: - if "=" in cline and "==" not in cline: - line_vars.append(cline.replace(" ", "").split("=")[0]) - elif ".append(" in cline: - line_vars.append(cline.replace(" ", "").split("(")[0]) - - # Execute the cell - self.shell.ex(cell) - - # Look for all vars that are BaseJob instances - jobs = [] - for var in line_vars: - iter_var = False - if "#" not in var: - # The line var is a list or array, but we cannot parse the index - # so just iterate over the whole array for jobs. - if "[" in var: - var = var.split("[")[0] - iter_var = True - elif ".append" in var: - var = var.split(".append")[0] - iter_var = True - - if iter_var: - for item in self.shell.user_ns[var]: - if isinstance(item, qiskit.providers.job.Job): - jobs.append(item) - else: - if isinstance(self.shell.user_ns[var], qiskit.providers.job.Job): - jobs.append(self.shell.user_ns[var]) - - # Must have one job class - if not any(jobs): - raise Exception("Cell must contain at least one variable of BaseJob type.") - - # List index of job if checking status of multiple jobs. - multi_job = False - if len(jobs) > 1: - multi_job = True - - job_checkers = [] - # Loop over every BaseJob that was found. - for idx, job_var in enumerate(jobs): - style = "font-size:16px;" - if multi_job: - idx_str = "[%s]" % idx - else: - idx_str = "" - header = f"

Job Status {idx_str}: %s

" - status = widgets.HTML(value=header % job_var.status().value) - - thread = threading.Thread( - target=_html_checker, args=(job_var, args.interval, status, header, _interval_set) - ) - thread.start() - job_checkers.append(status) - - # Group all HTML widgets into single vertical layout - box = widgets.VBox(job_checkers) - display(box) - - -@magics_class -class ProgressBarMagic(Magics): - """A class of progress bar magic functions.""" - - @line_magic - @magic_arguments.magic_arguments() - @magic_arguments.argument( - "-t", "--type", type=str, default="html", help="Type of progress bar, 'html' or 'text'." - ) - def qiskit_progress_bar(self, line="", cell=None): # pylint: disable=unused-argument - """A Jupyter magic function to generate progressbar.""" - args = magic_arguments.parse_argstring(self.qiskit_progress_bar, line) - if args.type == "html": - pbar = HTMLProgressBar() - elif args.type == "text": - pbar = TextProgressBar() - else: - raise qiskit.QiskitError("Invalid progress bar type.") - - return pbar - - -if _optionals.HAS_MATPLOTLIB and get_ipython(): - - @register_line_magic - @deprecate_func( - since="0.25.0", - additional_msg="This was originally only for internal documentation and is no longer used.", - ) - def circuit_library_info(circuit: qiskit.QuantumCircuit) -> None: - """Displays library information for a quantum circuit. - - Args: - circuit: Input quantum circuit. - """ - shell = get_ipython() - circ = shell.ev(circuit) - circuit_library_widget(circ) diff --git a/qiskit/tools/jupyter/library.py b/qiskit/tools/jupyter/library.py deleted file mode 100644 index 57a27ece8cdc..000000000000 --- a/qiskit/tools/jupyter/library.py +++ /dev/null @@ -1,189 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -# pylint: disable=invalid-name,no-name-in-module,ungrouped-imports - -"""A circuit library widget module""" - -import ipywidgets as wid -from IPython.display import display -from qiskit import QuantumCircuit -from qiskit.utils import optionals as _optionals -from qiskit.utils.deprecation import deprecate_func - - -@_optionals.HAS_MATPLOTLIB.require_in_call -def _generate_circuit_library_visualization(circuit: QuantumCircuit): - import matplotlib.pyplot as plt - - circuit = circuit.decompose() - ops = circuit.count_ops() - num_nl = circuit.num_nonlocal_gates() - _fig, (ax0, ax1) = plt.subplots(2, 1) - circuit.draw("mpl", ax=ax0) - ax1.axis("off") - ax1.grid(visible=None) - ax1.table( - [[circuit.name], [circuit.width()], [circuit.depth()], [sum(ops.values())], [num_nl]], - rowLabels=["Circuit Name", "Width", "Depth", "Total Gates", "Non-local Gates"], - ) - plt.tight_layout() - plt.show() - - -@deprecate_func( - since="0.25.0", - additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.", - package_name="qiskit-terra", -) -def circuit_data_table(circuit: QuantumCircuit) -> wid.HTML: - """Create a HTML table widget for a given quantum circuit. - - Args: - circuit: Input quantum circuit. - - Returns: - Output widget. - """ - - circuit = circuit.decompose() - ops = circuit.count_ops() - num_nl = circuit.num_nonlocal_gates() - - html = "" - html += """""" - html += f"" - html += f"" - html += f"" - html += f"" - html += f"" - html += "
{circuit.name}
Width{circuit.width()}
Depth{circuit.depth()}
Total Gates{sum(ops.values())}
Non-local Gates{num_nl}
" - - out_wid = wid.HTML(html) - return out_wid - - -head_style = ( - "font-family: IBM Plex Sans, Arial, Helvetica, sans-serif;" - " font-size: 20px; font-weight: medium;" -) - -property_label = wid.HTML( - f"

Circuit Properties

", - layout=wid.Layout(margin="0px 0px 10px 0px"), -) - - -@deprecate_func( - since="0.25.0", - additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.", - package_name="qiskit-terra", -) -def properties_widget(circuit: QuantumCircuit) -> wid.VBox: - """Create a HTML table widget with header for a given quantum circuit. - - Args: - circuit: Input quantum circuit. - - Returns: - Output widget. - """ - properties = wid.VBox( - children=[property_label, circuit_data_table(circuit)], - layout=wid.Layout(width="40%", height="auto"), - ) - return properties - - -@deprecate_func( - since="0.25.0", - additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.", - package_name="qiskit-terra", -) -def circuit_diagram_widget() -> wid.Box: - """Create a circuit diagram widget. - - Returns: - Output widget. - """ - # The max circuit height corresponds to a 20Q circuit with flat - # classical register. - top_out = wid.Output( - layout=wid.Layout( - width="100%", - height="auto", - max_height="1000px", - overflow="hidden scroll", - ) - ) - - top = wid.Box(children=[top_out], layout=wid.Layout(width="100%", height="auto")) - - return top - - -@deprecate_func( - since="0.25.0", - additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.", - package_name="qiskit-terra", -) -def circuit_library_widget(circuit: QuantumCircuit) -> None: - """Create a circuit library widget. - - Args: - circuit: Input quantum circuit. - """ - sep_length = str(min(20, 495)) - - # The separator widget - sep = wid.HTML( - f"
", - layout=wid.Layout(height="auto", max_height="495px", margin="40px 0px 0px 20px"), - ) - bottom = wid.HBox( - children=[properties_widget(circuit), sep], - layout=wid.Layout(max_height="550px", height="auto"), - ) - - top = circuit_diagram_widget() - - with top.children[0]: - display(circuit.decompose().draw(output="mpl")) - - display(wid.VBox(children=[top, bottom], layout=wid.Layout(width="100%", height="auto"))) diff --git a/qiskit/tools/jupyter/monospace.py b/qiskit/tools/jupyter/monospace.py deleted file mode 100644 index 0ff0b99c8bfb..000000000000 --- a/qiskit/tools/jupyter/monospace.py +++ /dev/null @@ -1,29 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2020. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. -# pylint: disable=unused-argument - -"""A Jupyter magic to choose a real monospaced fonts, if available.""" - -from IPython.display import HTML, display -from IPython.core.magic import line_magic, Magics, magics_class - - -@magics_class -class MonospacedOutput(Magics): - """A class for setting "Courier New" for output code.""" - - @line_magic - def monospaced_output(self, line="", cell=None): - """A Jupyter magic function to set "Courier New" for output code.""" - html = """""" - display(HTML(html)) diff --git a/qiskit/tools/jupyter/progressbar.py b/qiskit/tools/jupyter/progressbar.py deleted file mode 100644 index 06531935d2de..000000000000 --- a/qiskit/tools/jupyter/progressbar.py +++ /dev/null @@ -1,122 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -# This file is part of QuTiP: Quantum Toolbox in Python. -# -# Copyright (c) 2011 and later, Paul D. Nation and Robert J. Johansson. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# 3. Neither the name of the QuTiP: Quantum Toolbox in Python nor the names -# of its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -############################################################################### - -"""Progress bars module""" - -import time - -from qiskit.tools.events.progressbar import BaseProgressBar -from qiskit.utils import optionals as _optionals - - -@_optionals.HAS_IPYWIDGETS.require_in_instance -class HTMLProgressBar(BaseProgressBar): - """ - A simple HTML progress bar for using in IPython notebooks. - """ - - def __init__(self): - super().__init__() - self.progress_bar = None - self.label = None - self.box = None - self._init_subscriber() - - def _init_subscriber(self): - def _initialize_progress_bar(num_tasks): - """When an event of compilation starts, this function will be called, and - will initialize the progress bar. - - Args: - num_tasks: Number of compilation tasks the progress bar will track - """ - self.start(num_tasks) - - self.subscribe("terra.parallel.start", _initialize_progress_bar) - - def _update_progress_bar(progress): - """When an event of compilation completes, this function will be called, and - will update the progress bar indication. - - Args: - progress: Number of tasks completed - """ - self.update(progress) - - self.subscribe("terra.parallel.done", _update_progress_bar) - - def _finish_progress_bar(): - """When an event of compilation finishes (meaning that there's no more circuits to - compile), this function will be called, unsubscribing from all events and - finishing the progress bar.""" - self.unsubscribe("terra.parallel.start", _initialize_progress_bar) - self.unsubscribe("terra.parallel.done", _update_progress_bar) - self.unsubscribe("terra.parallel.finish", _finish_progress_bar) - self.finished() - - self.subscribe("terra.parallel.finish", _finish_progress_bar) - - def start(self, iterations): - import ipywidgets as widgets - from IPython.display import display - - self.touched = True - self.iter = int(iterations) - self.t_start = time.time() - self.progress_bar = widgets.IntProgress(min=0, max=self.iter, value=0) - self.progress_bar.bar_style = "info" - self.label = widgets.HTML() - self.box = widgets.VBox(children=[self.label, self.progress_bar]) - display(self.box) - - def update(self, n): - self.progress_bar.value += 1 - lbl = "Completed %s/%s: Est. remaining time: %s." - self.label.value = lbl % (n, self.iter, self.time_remaining_est(n)) - - def finished(self): - self.t_done = time.time() - self.progress_bar.bar_style = "success" - self.label.value = "Elapsed time: %s" % self.time_elapsed() diff --git a/qiskit/tools/jupyter/version_table.py b/qiskit/tools/jupyter/version_table.py deleted file mode 100644 index 9d54ed080946..000000000000 --- a/qiskit/tools/jupyter/version_table.py +++ /dev/null @@ -1,67 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2021. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. -# pylint: disable=unused-argument - -"""A module for monitoring backends.""" - -import time -from sys import modules -from IPython.display import HTML, display -from IPython.core.magic import line_magic, Magics, magics_class -import qiskit -from qiskit.utils import local_hardware_info - - -@magics_class -class VersionTable(Magics): - """A class of status magic functions.""" - - @line_magic - def qiskit_version_table(self, line="", cell=None): - """ - Print an HTML-formatted table with version numbers for Qiskit and its - dependencies. This should make it possible to reproduce the environment - and the calculation later on. - """ - html = "

Version Information

" - html += "" - html += "" - - packages = {"qiskit": qiskit.__version__} - qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module} - - for qiskit_module in qiskit_modules: - packages[qiskit_module] = getattr(modules[qiskit_module], "__version__", None) - - for name, version in packages.items(): - if version: - html += f"" - - html += "" - - local_hw_info = local_hardware_info() - sys_info = [ - ("Python version", local_hw_info["python_version"]), - ("Python compiler", local_hw_info["python_compiler"]), - ("Python build", local_hw_info["python_build"]), - ("OS", "%s" % local_hw_info["os"]), - ("CPUs", "%s" % local_hw_info["cpus"]), - ("Memory (Gb)", "%s" % local_hw_info["memory"]), - ] - - for name, version in sys_info: - html += f"" - - html += "" % time.strftime("%a %b %d %H:%M:%S %Y %Z") - html += "
SoftwareVersion
{name}{version}
System information
{name}{version}
%s
" - - return display(HTML(html)) diff --git a/qiskit/tools/jupyter/watcher_monitor.py b/qiskit/tools/jupyter/watcher_monitor.py deleted file mode 100644 index 7d12dfc9bd03..000000000000 --- a/qiskit/tools/jupyter/watcher_monitor.py +++ /dev/null @@ -1,74 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module of widgets for job monitoring""" -import sys -import time -import threading - - -def _job_monitor(job, status, watcher): - """Monitor the status of a IBMQJob instance. - - Args: - job (BaseJob): Job to monitor. - status (Enum): Job status. - watcher (JobWatcher): Job watcher instance - """ - thread = threading.Thread(target=_job_checker, args=(job, status, watcher)) - thread.start() - - -def _job_checker(job, status, watcher): - """A simple job status checker - - Args: - job (BaseJob): The job to check. - status (Enum): Job status. - watcher (JobWatcher): Job watcher instance - - """ - prev_status_name = None - prev_queue_pos = None - interval = 2 - exception_count = 0 - - while status.name not in ["DONE", "CANCELLED", "ERROR"]: - time.sleep(interval) - try: - status = job.status() - exception_count = 0 - - if status.name == "QUEUED": - queue_pos = job.queue_position() - if queue_pos != prev_queue_pos: - - update_info = (job.job_id(), status.name, queue_pos, status.value) - - watcher.update_single_job(update_info) - interval = max(queue_pos, 2) - prev_queue_pos = queue_pos - - elif status.name != prev_status_name: - update_info = (job.job_id(), status.name, 0, status.value) - - watcher.update_single_job(update_info) - interval = 2 - prev_status_name = status.name - - # pylint: disable=broad-except - except Exception: - exception_count += 1 - if exception_count == 5: - update_info = (job.job_id(), "NA", 0, "Could not query job.") - watcher.update_single_job(update_info) - sys.exit() diff --git a/qiskit/tools/monitor/__init__.py b/qiskit/tools/monitor/__init__.py deleted file mode 100644 index cd0f22b90e48..000000000000 --- a/qiskit/tools/monitor/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module for monitoring jobs, backends, etc.""" - -from .job_monitor import job_monitor -from .overview import backend_monitor, backend_overview diff --git a/qiskit/tools/monitor/job_monitor.py b/qiskit/tools/monitor/job_monitor.py deleted file mode 100644 index 3dabf5e2296b..000000000000 --- a/qiskit/tools/monitor/job_monitor.py +++ /dev/null @@ -1,107 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - - -"""A module for monitoring various qiskit functionality""" - -import sys -import time - - -def _text_checker( - job, interval, _interval_set=False, quiet=False, output=sys.stdout, line_discipline="\r" -): - """A text-based job status checker - - Args: - job (BaseJob): The job to check. - interval (int): The interval at which to check. - _interval_set (bool): Was interval time set by user? - quiet (bool): If True, do not print status messages. - output (file): The file like object to write status messages to. - By default this is sys.stdout. - line_discipline (string): character emitted at start of a line of job monitor output, - This defaults to \\r. - - """ - status = job.status() - msg = status.value - prev_msg = msg - msg_len = len(msg) - - if not quiet: - print("{}{}: {}".format(line_discipline, "Job Status", msg), end="", file=output) - while status.name not in ["DONE", "CANCELLED", "ERROR"]: - time.sleep(interval) - status = job.status() - msg = status.value - - if status.name == "QUEUED": - msg += " (%s)" % job.queue_position() - if job.queue_position() is None: - interval = 2 - elif not _interval_set: - interval = max(job.queue_position(), 2) - else: - if not _interval_set: - interval = 2 - - # Adjust length of message so there are no artifacts - if len(msg) < msg_len: - msg += " " * (msg_len - len(msg)) - elif len(msg) > msg_len: - msg_len = len(msg) - - if msg != prev_msg and not quiet: - print("{}{}: {}".format(line_discipline, "Job Status", msg), end="", file=output) - prev_msg = msg - if not quiet: - print("", file=output) - - -def job_monitor(job, interval=None, quiet=False, output=sys.stdout, line_discipline="\r"): - """Monitor the status of a IBMQJob instance. - - Args: - 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. - By default this is sys.stdout. - line_discipline (string): character emitted at start of a line of job monitor output, - This defaults to \\r. - - Examples: - - .. code-block:: python - - 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) - """ - if interval is None: - _interval_set = False - interval = 5 - else: - _interval_set = True - - _text_checker( - job, interval, _interval_set, quiet=quiet, output=output, line_discipline=line_discipline - ) diff --git a/qiskit/tools/monitor/overview.py b/qiskit/tools/monitor/overview.py deleted file mode 100644 index 41853fb3ad26..000000000000 --- a/qiskit/tools/monitor/overview.py +++ /dev/null @@ -1,247 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""A module for viewing the details of all available devices. -""" - -import math -from qiskit.exceptions import QiskitError, MissingOptionalLibraryError - - -def get_unique_backends(): - """Gets the unique backends that are available. - - Returns: - list: Unique available backends. - - Raises: - QiskitError: No backends available. - MissingOptionalLibraryError: If qiskit-ibmq-provider is not installed - """ - try: - from qiskit.providers.ibmq import IBMQ - except ImportError as ex: - raise MissingOptionalLibraryError( - libname="qiskit-ibmq-provider", - name="get_unique_backends", - pip_install="pip install qiskit-ibmq-provider", - ) from ex - backends = [] - for provider in IBMQ.providers(): - for backend in provider.backends(): - backends.append(backend) - unique_hardware_backends = [] - unique_names = [] - for back in backends: - if back.name() not in unique_names and not back.configuration().simulator: - unique_hardware_backends.append(back) - unique_names.append(back.name()) - if not unique_hardware_backends: - raise QiskitError("No backends available.") - return unique_hardware_backends - - -def backend_monitor(backend): - """Monitor a single IBMQ backend. - - Args: - backend (IBMQBackend): Backend to monitor. - Raises: - QiskitError: Input is not a IBMQ backend. - MissingOptionalLibraryError: If qiskit-ibmq-provider is not installed - - Examples: - .. code-block:: python - - from qiskit.providers.ibmq import IBMQ - from qiskit.tools.monitor import backend_monitor - provider = IBMQ.get_provider(hub='ibm-q') - backend_monitor(provider.backends.ibmq_lima) - """ - try: - from qiskit.providers.ibmq import IBMQBackend - except ImportError as ex: - raise MissingOptionalLibraryError( - libname="qiskit-ibmq-provider", - name="backend_monitor", - pip_install="pip install qiskit-ibmq-provider", - ) from ex - - if not isinstance(backend, IBMQBackend): - raise QiskitError("Input variable is not of type IBMQBackend.") - config = backend.configuration().to_dict() - status = backend.status().to_dict() - config_dict = {**status, **config} - - print(backend.name()) - print("=" * len(backend.name())) - print("Configuration") - print("-" * 13) - offset = " " - - upper_list = [ - "n_qubits", - "operational", - "status_msg", - "pending_jobs", - "backend_version", - "basis_gates", - "local", - "simulator", - ] - - lower_list = list(set(config_dict.keys()).difference(upper_list)) - # Remove gates because they are in a different tab - lower_list.remove("gates") - for item in upper_list + lower_list: - print(offset + item + ":", config_dict[item]) - - # Stop here if simulator - if config["simulator"]: - return - - print() - props = backend.properties() - qubit_header = None - sep = " / " - - for index, qubit_data in enumerate(props.qubits): - name = "Q%s" % index - gate_data = [gate for gate in props.gates if gate.qubits == [index]] - - cal_data = dict.fromkeys(["T1", "T2", "frequency", "readout_error"], "Unknown") - for nduv in qubit_data: - if nduv.name in cal_data: - cal_data[nduv.name] = format(nduv.value, ".5f") + " " + nduv.unit - - gate_names = [] - gate_error = [] - for gd in gate_data: - if gd.gate in ["id"]: - continue - try: - gate_error.append(format(props.gate_error(gd.gate, index), ".5f")) - gate_names.append(gd.gate.upper() + " err") - except QiskitError: - pass - - if not qubit_header: - qubit_header = ( - "Qubits [Name / Freq / T1 / T2" + sep.join([""] + gate_names) + " / Readout err]" - ) - print(qubit_header) - print("-" * len(qubit_header)) - - qstr = sep.join( - [name, cal_data["frequency"], cal_data["T1"], cal_data["T2"]] - + gate_error - + [cal_data["readout_error"]] - ) - - print(offset + qstr) - - print() - multi_qubit_gates = [g for g in props.gates if len(g.qubits) > 1] - multi_header = "Multi-Qubit Gates [Name / Type / Gate Error]" - print(multi_header) - print("-" * len(multi_header)) - - for gate in multi_qubit_gates: - qubits = gate.qubits - ttype = gate.gate - error = "Unknown" - try: - error = format(props.gate_error(gate.gate, qubits), ".5f") - except QiskitError: - pass - mstr = sep.join([f"{ttype}{qubits[0]}_{qubits[1]}", ttype, str(error)]) - print(offset + mstr) - - -def backend_overview(): - """Gives overview information on all the IBMQ - backends that are available. - - Examples: - - .. code-block:: python - - from qiskit.providers.ibmq import IBMQ - from qiskit.tools.monitor import backend_overview - provider = IBMQ.get_provider(hub='ibm-q') - backend_overview() - """ - unique_hardware_backends = get_unique_backends() - _backends = [] - # Sort backends by operational or not - for idx, back in enumerate(unique_hardware_backends): - if back.status().operational: - _backends = [back] + _backends - else: - _backends = _backends + [back] - - stati = [back.status() for back in _backends] - idx = list(range(len(_backends))) - pending = [s.pending_jobs for s in stati] - _, least_idx = zip(*sorted(zip(pending, idx))) - - # Make sure least pending is operational - for ind in least_idx: - if stati[ind].operational: - least_pending_idx = ind - break - - num_rows = math.ceil(len(_backends) / 3) - - count = 0 - num_backends = len(_backends) - for _ in range(num_rows): - max_len = 0 - str_list = [""] * 8 - for idx in range(3): - offset = " " * 10 if idx else "" - config = _backends[count].configuration().to_dict() - props = _backends[count].properties().to_dict() - num_qubits = config["n_qubits"] - str_list[0] += " " * (max_len - len(str_list[0])) + offset - str_list[0] += _backends[count].name() - - str_list[1] += " " * (max_len - len(str_list[1])) + offset - str_list[1] += "-" * len(_backends[count].name()) - - str_list[2] += " " * (max_len - len(str_list[2])) + offset - str_list[2] += "Num. Qubits: %s" % config["n_qubits"] - - str_list[3] += " " * (max_len - len(str_list[3])) + offset - str_list[3] += "Pending Jobs: %s" % stati[count].pending_jobs - - str_list[4] += " " * (max_len - len(str_list[4])) + offset - str_list[4] += "Least busy: %s" % (count == least_pending_idx) - - str_list[5] += " " * (max_len - len(str_list[5])) + offset - str_list[5] += "Operational: %s" % stati[count].operational - - str_list[6] += " " * (max_len - len(str_list[6])) + offset - str_list[6] += "Avg. T1: %s" % round( - sum(q[0]["value"] for q in props["qubits"]) / num_qubits, 1 - ) - str_list[7] += " " * (max_len - len(str_list[7])) + offset - str_list[7] += "Avg. T2: %s" % round( - sum(q[1]["value"] for q in props["qubits"]) / num_qubits, 1 - ) - count += 1 - if count == num_backends: - break - max_len = max(len(s) for s in str_list) - - print("\n".join(str_list)) - print("\n" * 2) diff --git a/qiskit/visualization/library.py b/qiskit/visualization/library.py new file mode 100644 index 000000000000..5832a475f8fd --- /dev/null +++ b/qiskit/visualization/library.py @@ -0,0 +1,37 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2017, 2018. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +# pylint: disable=invalid-name,no-name-in-module,ungrouped-imports + +"""A circuit library visualization""" + +from qiskit import QuantumCircuit +from qiskit.utils import optionals as _optionals + + +@_optionals.HAS_MATPLOTLIB.require_in_call +def _generate_circuit_library_visualization(circuit: QuantumCircuit): + import matplotlib.pyplot as plt + + circuit = circuit.decompose() + ops = circuit.count_ops() + num_nl = circuit.num_nonlocal_gates() + _fig, (ax0, ax1) = plt.subplots(2, 1) + circuit.draw("mpl", ax=ax0) + ax1.axis("off") + ax1.grid(visible=None) + ax1.table( + [[circuit.name], [circuit.width()], [circuit.depth()], [sum(ops.values())], [num_nl]], + rowLabels=["Circuit Name", "Width", "Depth", "Total Gates", "Non-local Gates"], + ) + plt.tight_layout() + plt.show() diff --git a/releasenotes/notes/remove-ibmq-4bb57a04991da9af.yaml b/releasenotes/notes/remove-ibmq-4bb57a04991da9af.yaml new file mode 100644 index 000000000000..831b55ea9fdf --- /dev/null +++ b/releasenotes/notes/remove-ibmq-4bb57a04991da9af.yaml @@ -0,0 +1,34 @@ +--- +upgrade: + - | + The deprecated ``qiskit.IBMQ`` object hase been removed. This alias object + was marked as deprecated in the 0.23.0 release. This alias object lazily + redirected attribute access to ``qiskit.providers.ibmq.IBMQ``. As the + ``qiskit-ibmq-provider`` package has now been retired and superseded by + ``qiskit-ibm-provider`` package which maintains its own namespace + maintaining this alias is no longer relevant. If you + were relying on the ``qiskit.IBMQ`` alias you should migrate your usage to + the ``qiskit-ibm-provider`` package, see the + `migration guide `__ + for more details. + - | + Removed the deprecated module ``qiskit.tools.jupyter`` which previously + included jupyter magics and widgets for interactively visualizing some data + from Qiskit. This module was deprecated in Qiskit 0.46.0. Most of this + functionality was directly tied to the legacy ``qiskit-ibmq-provider`` + package and was no longer valid so the module was removed. Similar + functionality is available from the ``qiskit_ibm_provider.jupyter`` module + in the `qiskit-ibm-provider __` package. + - | + Removed the deprecated module ``qiskit.tools.monitor`` which previously + included tools for tracking :class:`.JobV1` job instances, primarily from + the legacy ``qiskit-ibm-provider`` package. This module was marked as + deprecated in Qiskit 0.46.0. It is being removed because it was directly + tied to the legacy ``qiskit-ibm-provider`` package. + - | + Removed the deprecated import path ``qiskit.test.mock`` which previously was + used to redirect imports for the mock backends to their newer location in + the :mod:`qiskit.providers.fake_provider`. This module was marked as + deprecated in Qiskit 0.37.0. If you were using this module you should update + your imports from ``qiskit.test.mock`` to + :mod:`qiskit.providers.fake_provider` instead. diff --git a/requirements-optional.txt b/requirements-optional.txt index 0e94040e69c1..36985cdd7cd9 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -8,12 +8,9 @@ # Test-runner enhancements. fixtures testtools -jupyter # Interactivity. -ipykernel ipython -ipywidgets>=7.3.0 matplotlib>=3.3 pillow>=4.2.1 pydot diff --git a/test/python/mock/test_mock_module_deprecation.py b/test/python/mock/test_mock_module_deprecation.py deleted file mode 100644 index d2355c84717b..000000000000 --- a/test/python/mock/test_mock_module_deprecation.py +++ /dev/null @@ -1,28 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Test for deprecation of qiskit.test.mock module.""" -from qiskit.test import QiskitTestCase - - -class MockModuleDeprecationTest(QiskitTestCase): - """Test for deprecation of qiskit.test.mock module.""" - - def test_deprecated_mock_module(self): - """Test that the mock module is deprecated.""" - # pylint: disable=unused-import,no-name-in-module - with self.assertWarns(DeprecationWarning): - from qiskit.test.mock import FakeWashington - with self.assertWarns(DeprecationWarning): - from qiskit.test.mock.backends import FakeWashington - with self.assertWarns(DeprecationWarning): - from qiskit.test.mock.backends.washington import FakeWashington diff --git a/test/python/notebooks/test_backend_tools.ipynb b/test/python/notebooks/test_backend_tools.ipynb deleted file mode 100644 index d2d892b9cd56..000000000000 --- a/test/python/notebooks/test_backend_tools.ipynb +++ /dev/null @@ -1,156 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "ExecuteTime": { - "end_time": "2019-08-09T09:29:08.426863Z", - "start_time": "2019-08-09T09:29:08.423361Z" - } - }, - "outputs": [], - "source": [ - "import os\n", - "import sys\n", - "\n", - "cwd = os.getcwd()\n", - "qiskit_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(cwd))))\n", - "sys.path.append(qiskit_dir)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "ExecuteTime": { - "end_time": "2019-08-09T09:29:08.669360Z", - "start_time": "2019-08-09T09:29:08.612812Z" - } - }, - "outputs": [], - "source": [ - "from qiskit import IBMQ\n", - "from qiskit.tools.jupyter import *" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "ExecuteTime": { - "end_time": "2019-08-09T09:29:11.253688Z", - "start_time": "2019-08-09T09:29:08.791274Z" - } - }, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "IBMQ.load_account()" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "ExecuteTime": { - "end_time": "2019-08-09T09:29:25.505599Z", - "start_time": "2019-08-09T09:29:11.266347Z" - } - }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "99942fff1dc24cdf9a105c018f6a1260", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "VBox(children=(HTML(value=\"

=3.8 on osx and windows", - ) - def test_jupyter_jobs_pbars(self): - """Test Jupyter progress bars and job status functionality""" - self._execute_notebook(os.path.join(self.notebook_dir, "test_pbar_status.ipynb")) - - @unittest.skipIf(not optionals.HAS_MATPLOTLIB, "matplotlib not available.") - @slow_test - def test_backend_tools(self): - """Test Jupyter backend tools.""" - self._execute_notebook(os.path.join(self.notebook_dir, "test_backend_tools.ipynb")) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/test/python/tools/monitor/__init__.py b/test/python/tools/monitor/__init__.py deleted file mode 100644 index 146d5c0e0b91..000000000000 --- a/test/python/tools/monitor/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Tests for backend monitor-related functionality.""" diff --git a/test/python/tools/monitor/test_backend_monitor.py b/test/python/tools/monitor/test_backend_monitor.py deleted file mode 100644 index a2c4802802e6..000000000000 --- a/test/python/tools/monitor/test_backend_monitor.py +++ /dev/null @@ -1,103 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Tests for the wrapper functionality.""" - -import sys -import unittest -from unittest.mock import patch -from unittest.mock import MagicMock -from io import StringIO - -import qiskit -from qiskit import providers -from qiskit.tools.monitor import backend_overview, backend_monitor -from qiskit.test import QiskitTestCase -from qiskit.providers.fake_provider import FakeProviderFactory, FakeBackend, FakeVigo - - -class TestBackendOverview(QiskitTestCase): - """Tools test case.""" - - def _restore_ibmq(self): - if not self.import_error: - qiskit.IBMQ = self.ibmq_back - else: - del qiskit.IBMQ - if self.prov_backup: - providers.ibmq = self.prov_backup - else: - del providers.ibmq - - def _restore_ibmq_mod(self): - if self.ibmq_module_backup is not None: - sys.modules["qiskit.providers.ibmq"] = self.ibmq_module_backup - else: - sys.modules.pop("qiskit.providers.ibmq") - - def setUp(self): - super().setUp() - ibmq_mock = MagicMock() - ibmq_mock.IBMQBackend = FakeBackend - if "qiskit.providers.ibmq" in sys.modules: - self.ibmq_module_backup = sys.modules["qiskit.providers.ibmq"] - else: - self.ibmq_module_backup = None - sys.modules["qiskit.providers.ibmq"] = ibmq_mock - self.addCleanup(self._restore_ibmq_mod) - - if hasattr(qiskit, "IBMQ"): - self.import_error = False - else: - self.import_error = True - qiskit.IBMQ = None - self.ibmq_back = qiskit.IBMQ - qiskit.IBMQ = FakeProviderFactory() - self.addCleanup(self._restore_ibmq) - if hasattr(providers, "ibmq"): - self.prov_backup = providers.ibmq - else: - self.prov_backup = None - providers.ibmq = MagicMock() - - @patch("qiskit.tools.monitor.overview.get_unique_backends", return_value=[FakeVigo()]) - def test_backend_overview(self, _): - """Test backend_overview""" - with patch("sys.stdout", new=StringIO()) as fake_stdout: - backend_overview() - stdout = fake_stdout.getvalue() - self.assertIn("Operational:", stdout) - self.assertIn("Avg. T1:", stdout) - self.assertIn("Num. Qubits:", stdout) - - @patch("qiskit.tools.monitor.overview.get_unique_backends", return_value=[FakeVigo()]) - def test_backend_monitor(self, _): - """Test backend_monitor""" - for back in [FakeVigo()]: - if not back.configuration().simulator: - backend = back - break - with patch("sys.stdout", new=StringIO()) as fake_stdout: - backend_monitor(backend) - - stdout = fake_stdout.getvalue() - self.assertIn("Configuration", stdout) - self.assertIn("Qubits [Name / Freq / T1 / T2 / ", stdout) - for gate in backend.properties().gates: - if gate.gate not in ["id"] and len(gate.qubits) == 1: - self.assertIn(gate.gate.upper() + " err", stdout) - self.assertIn("Readout err", stdout) - self.assertIn("Multi-Qubit Gates [Name / Type / Gate Error]", stdout) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/test/python/tools/monitor/test_job_monitor.py b/test/python/tools/monitor/test_job_monitor.py deleted file mode 100644 index 17409ac1022a..000000000000 --- a/test/python/tools/monitor/test_job_monitor.py +++ /dev/null @@ -1,43 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Tests for the wrapper functionality.""" - -import io -import unittest -from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit -from qiskit import BasicAer -from qiskit import execute -from qiskit.tools.monitor import job_monitor -from qiskit.test import QiskitTestCase - - -class TestJobMonitor(QiskitTestCase): - """Tools test case.""" - - def test_job_monitor(self): - """Test job_monitor""" - qreg = QuantumRegister(2) - creg = ClassicalRegister(2) - qc = QuantumCircuit(qreg, creg) - qc.h(qreg[0]) - qc.cx(qreg[0], qreg[1]) - qc.measure(qreg, creg) - backend = BasicAer.get_backend("qasm_simulator") - job_sim = execute([qc] * 10, backend) - output = io.StringIO() - job_monitor(job_sim, output=output) - self.assertEqual(job_sim.status().name, "DONE") - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/tools/update_fake_backends.py b/tools/update_fake_backends.py index 32f26a1c2411..415a5c68fd55 100755 --- a/tools/update_fake_backends.py +++ b/tools/update_fake_backends.py @@ -19,7 +19,7 @@ import json import os -from qiskit.providers.ibmq import IBMQ +from qiskit_ibm_provider import IBMProvider from qiskit.circuit.parameterexpression import ParameterExpression @@ -57,9 +57,7 @@ def _main(): parser.add_argument("--hub", type=str, default=None) parser.add_argument("--group", type=str, default=None) args = parser.parse_args() - provider = IBMQ.load_account() - if args.hub or args.group or args.project: - provider = IBMQ.get_provider(hub=args.hub, group=args.group, project=args.project) + provider = IBMProvider() ibmq_backends = provider.backends() for backend in ibmq_backends: raw_name = backend.name()