Skip to content

Commit

Permalink
Changes following implementation of Session in qiskit-ibm-provider (#…
Browse files Browse the repository at this point in the history
…1053)

* Use 'converters' from qiskit-ibm-provider

* Removed runtime_session.py and import it from qiskit-ibm-provider

* Remove unused self._circuits_map

* Fixed documentation

---------

Co-authored-by: Kevin Tian <[email protected]>
  • Loading branch information
merav-aharoni and kt474 authored Sep 7, 2023
1 parent d745ba5 commit 7752b68
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 260 deletions.
5 changes: 3 additions & 2 deletions qiskit_ibm_runtime/api/rest/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

from qiskit_ibm_provider.api.rest.base import RestAdapterBase
from qiskit_ibm_provider.api.rest.program_job import ProgramJob
from qiskit_ibm_provider.api.rest.runtime_session import RuntimeSession
from qiskit_ibm_provider.utils import local_to_utc

from .program import Program
from .runtime_session import RuntimeSession
from ...utils import RuntimeEncoder
from ...utils.converters import local_to_utc
from .cloud_backend import CloudBackend

logger = logging.getLogger(__name__)
Expand Down
40 changes: 0 additions & 40 deletions qiskit_ibm_runtime/api/rest/runtime_session.py

This file was deleted.

3 changes: 2 additions & 1 deletion qiskit_ibm_runtime/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
defaults_from_server_data,
properties_from_server_data,
)
from qiskit_ibm_provider.utils import local_to_utc

from qiskit_ibm_runtime import ( # pylint: disable=unused-import,cyclic-import
qiskit_runtime_service,
)
Expand All @@ -52,7 +54,6 @@
from .utils.backend_converter import (
convert_to_target,
)
from .utils.converters import local_to_utc

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from qiskit.providers.job import JobV1 as Job

# pylint: disable=unused-import,cyclic-import
from qiskit_ibm_provider.utils import validate_job_tags
from qiskit_ibm_provider.utils import validate_job_tags, utc_to_local
from qiskit_ibm_runtime import qiskit_runtime_service

from .constants import API_TO_JOB_ERROR_MESSAGE, API_TO_JOB_STATUS, DEFAULT_DECODERS
Expand All @@ -44,7 +44,6 @@
from .api.clients import RuntimeClient, RuntimeWebsocketClient, WebsocketClientCloseCode
from .exceptions import IBMError
from .api.exceptions import RequestsApiError
from .utils.converters import utc_to_local
from .api.client_parameters import ClientParameters
from .utils.utils import CallableStr
from .utils.deprecation import issue_deprecation_msg
Expand Down
11 changes: 4 additions & 7 deletions qiskit_ibm_runtime/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
from functools import wraps
from contextvars import ContextVar

from qiskit.circuit import QuantumCircuit
from qiskit_ibm_provider.utils.converters import hms_to_seconds

from qiskit_ibm_runtime import QiskitRuntimeService
from .runtime_job import RuntimeJob
from .runtime_program import ParameterNamespace
from .program.result_decoder import ResultDecoder
from .ibm_backend import IBMBackend
from .utils.converters import hms_to_seconds
from .utils.deprecation import issue_deprecation_msg
from .exceptions import IBMInputValueError

Expand Down Expand Up @@ -62,12 +61,13 @@ class Session:
with Session(backend="ibmq_qasm_simulator") as session:
sampler = Sampler(session=session, options=options)
job = sampler.run(circ)
job = sampler.run(ReferenceCircuits.bell())
print(f"Sampler job ID: {job.job_id()}")
print(f"Sampler job result:" {job.result()})
print(f"Sampler job result: {job.result()}")
# Close the session only if all jobs are finished and
# you don't need to run more in the session.
session.close()
"""

def __init__(
Expand Down Expand Up @@ -122,9 +122,6 @@ def __init__(

self._session_id: Optional[str] = None
self._active = True

self._circuits_map: Dict[str, QuantumCircuit] = {}

self._max_time = (
max_time
if max_time is None or isinstance(max_time, int)
Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
to_python_identifier
"""

from .converters import (
from qiskit_ibm_provider.utils.converters import (
utc_to_local,
local_to_utc,
seconds_to_duration,
Expand Down
160 changes: 0 additions & 160 deletions qiskit_ibm_runtime/utils/converters.py

This file was deleted.

47 changes: 0 additions & 47 deletions test/unit/test_utils_converters.py

This file was deleted.

0 comments on commit 7752b68

Please sign in to comment.