diff --git a/qiskit_ibm_runtime/__init__.py b/qiskit_ibm_runtime/__init__.py index 07096f3eb..bb3963f49 100644 --- a/qiskit_ibm_runtime/__init__.py +++ b/qiskit_ibm_runtime/__init__.py @@ -181,6 +181,7 @@ def result_callback(job_id, result): from .runtime_options import RuntimeOptions from .utils.json import RuntimeEncoder, RuntimeDecoder from .session import Session # pylint: disable=cyclic-import +from .batch import Batch # pylint: disable=cyclic-import from .exceptions import * from .utils.utils import setup_logger diff --git a/qiskit_ibm_runtime/batch.py b/qiskit_ibm_runtime/batch.py new file mode 100644 index 000000000..6947ddc81 --- /dev/null +++ b/qiskit_ibm_runtime/batch.py @@ -0,0 +1,21 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2023. +# +# 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. + +"""Qiskit Runtime batch mode.""" + +from .session import Session + + +class Batch(Session): + """Class for creating a batch mode in Qiskit Runtime.""" + + pass diff --git a/releasenotes/notes/batch-class-b7a3befcfce8860e.yaml b/releasenotes/notes/batch-class-b7a3befcfce8860e.yaml new file mode 100644 index 000000000..8e2bf7e06 --- /dev/null +++ b/releasenotes/notes/batch-class-b7a3befcfce8860e.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + There is a new class, :class:`qiskit_ibm_runtime.Batch` that currently works + the same way as :class:`qiskit_ibm_runtime.Session` but will later be updated + to better support submitting multiple jobs at once. diff --git a/test/unit/test_batch.py b/test/unit/test_batch.py new file mode 100644 index 000000000..a27eca479 --- /dev/null +++ b/test/unit/test_batch.py @@ -0,0 +1,35 @@ +# 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. + +"""Tests for Batch class.""" + +from unittest.mock import patch + +from qiskit_ibm_runtime import Batch +import qiskit_ibm_runtime.session as session_pkg +from ..ibm_test_case import IBMTestCase + + +class TestBatch(IBMTestCase): + """Class for testing the Session class.""" + + def tearDown(self) -> None: + super().tearDown() + session_pkg._DEFAULT_SESSION.set(None) + + @patch("qiskit_ibm_runtime.session.QiskitRuntimeService", autospec=True) + def test_default_batch(self, mock_service): + """Test using default batch mode.""" + mock_service.global_service = None + batch = Batch(backend="ibm_gotham") + self.assertIsNotNone(batch.service) + mock_service.assert_called_once()