Skip to content

Commit

Permalink
Merge branch 'main' into set-active-flag-session
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 authored Jul 1, 2024
2 parents 2c1e8ff + c607150 commit eda57d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
14 changes: 4 additions & 10 deletions qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
from .utils.result_decoder import ResultDecoder
from .utils.queueinfo import QueueInfo
from .utils.deprecation import deprecate_function
from .api.clients import RuntimeClient
from .api.exceptions import RequestsApiError
from .api.client_parameters import ClientParameters
Expand Down Expand Up @@ -319,10 +320,7 @@ def wait_for_final_state( # pylint: disable=arguments-differ
self,
timeout: Optional[float] = None,
) -> None:
"""Use the websocket server to wait for the final the state of a job.
The server will remain open if the job is still running and the connection will
be terminated once the job completes. Then update and return the status of the job.
"""Poll for the job status from the API until the status is in a final state.
Args:
timeout: Seconds to wait for the job. If ``None``, wait indefinitely.
Expand All @@ -332,12 +330,6 @@ def wait_for_final_state( # pylint: disable=arguments-differ
"""
try:
start_time = time.time()
if self._status not in self.JOB_FINAL_STATES and not self._is_streaming():
self._ws_client_future = self._executor.submit(self._start_websocket_client)
if self._is_streaming():
self._ws_client_future.result(timeout)
# poll for status after stream has closed until status is final
# because status doesn't become final as soon as stream closes
status = self.status()
while status not in self.JOB_FINAL_STATES:
elapsed_time = time.time() - start_time
Expand Down Expand Up @@ -368,6 +360,7 @@ def backend(self, timeout: Optional[float] = None) -> Optional[Backend]:
raise IBMRuntimeError(f"Failed to get job backend: {err}") from None
return self._backend

@deprecate_function("stream_results()", "0.25", "", stacklevel=1)
def stream_results(
self, callback: Callable, decoder: Optional[Type[ResultDecoder]] = None
) -> None:
Expand Down Expand Up @@ -398,6 +391,7 @@ def stream_results(
decoder=decoder,
)

@deprecate_function("interim_results()", "0.25", "", stacklevel=1)
def interim_results(self, decoder: Optional[Type[ResultDecoder]] = None) -> Any:
"""Return the interim results of the job.
Expand Down
14 changes: 4 additions & 10 deletions qiskit_ibm_runtime/runtime_job_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
RuntimeJobTimeoutError,
)
from .utils.result_decoder import ResultDecoder
from .utils.deprecation import deprecate_function
from .api.clients import RuntimeClient
from .api.exceptions import RequestsApiError
from .api.client_parameters import ClientParameters
Expand Down Expand Up @@ -236,10 +237,7 @@ def wait_for_final_state( # pylint: disable=arguments-differ
self,
timeout: Optional[float] = None,
) -> None:
"""Use the websocket server to wait for the final the state of a job.
The server will remain open if the job is still running and the connection will
be terminated once the job completes. Then update and return the status of the job.
"""Poll for the job status from the API until the status is in a final state.
Args:
timeout: Seconds to wait for the job. If ``None``, wait indefinitely.
Expand All @@ -249,12 +247,6 @@ def wait_for_final_state( # pylint: disable=arguments-differ
"""
try:
start_time = time.time()
if self._status not in self.JOB_FINAL_STATES and not self._is_streaming():
self._ws_client_future = self._executor.submit(self._start_websocket_client)
if self._is_streaming():
self._ws_client_future.result(timeout)
# poll for status after stream has closed until status is final
# because status doesn't become final as soon as stream closes
status = self.status()
while status not in self.JOB_FINAL_STATES:
elapsed_time = time.time() - start_time
Expand Down Expand Up @@ -285,6 +277,7 @@ def backend(self, timeout: Optional[float] = None) -> Optional[Backend]:
raise IBMRuntimeError(f"Failed to get job backend: {err}") from None
return self._backend

@deprecate_function("stream_results()", "0.25", "", stacklevel=1)
def stream_results(
self, callback: Callable, decoder: Optional[Type[ResultDecoder]] = None
) -> None:
Expand Down Expand Up @@ -315,6 +308,7 @@ def stream_results(
decoder=decoder,
)

@deprecate_function("interim_results()", "0.25", "", stacklevel=1)
def interim_results(self, decoder: Optional[Type[ResultDecoder]] = None) -> Any:
"""Return the interim results of the job.
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/1776.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:meth:`qiskit_ibm_runtime.RuntimeJobV2.interim_results` and :meth:`qiskit_ibm_runtime.RuntimeJobV2.stream_results`
are now both deprecated.

0 comments on commit eda57d5

Please sign in to comment.