Skip to content

Commit

Permalink
Merge af42e4a into bb6adfe
Browse files Browse the repository at this point in the history
  • Loading branch information
merav-aharoni committed Nov 15, 2023
2 parents bb6adfe + af42e4a commit 5754da1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion qiskit_ibm_provider/api/clients/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Client for accessing IBM Quantum runtime service."""

import logging
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union
from datetime import datetime as python_datetime
from requests import Response

Expand Down Expand Up @@ -111,6 +111,7 @@ def program_run(
session_id: Optional[str] = None,
job_tags: Optional[List[str]] = None,
max_execution_time: Optional[int] = None,
session_time: Optional[Union[int, str]] = None,
start_session: Optional[bool] = False,
) -> Dict:
"""Run the specified program.
Expand All @@ -126,6 +127,9 @@ def program_run(
job_tags: Tags to be assigned to the job.
max_execution_time: Maximum execution time in seconds.
start_session: Set to True to explicitly start a runtime session. Defaults to False.
session_time: max_time: (EXPERIMENTAL setting, can break between releases without warning)
Maximum amount of time, a runtime session can be open before being
forcibly closed. Can be specified as seconds (int) or a string like "2h 30m 40s".
Returns:
JSON response.
Expand All @@ -144,6 +148,7 @@ def program_run(
job_tags=job_tags,
max_execution_time=max_execution_time,
start_session=start_session,
session_time=session_time,
**hgp_dict
)

Expand Down
5 changes: 5 additions & 0 deletions qiskit_ibm_provider/api/rest/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def program_run(
session_id: Optional[str] = None,
job_tags: Optional[List[str]] = None,
max_execution_time: Optional[int] = None,
session_time: Optional[Union[int, str]] = None,
start_session: Optional[bool] = False,
) -> Dict:
"""Execute the program.
Expand All @@ -98,6 +99,9 @@ def program_run(
job_tags: Tags to be assigned to the job.
max_execution_time: Maximum execution time in seconds.
start_session: Set to True to explicitly start a runtime session. Defaults to False.
session_time: max_time: (EXPERIMENTAL setting, can break between releases without warning)
Maximum amount of time, a runtime session can be open before being
forcibly closed. Can be specified as seconds (int) or a string like "2h 30m 40s".
Returns:
JSON response.
Expand All @@ -121,6 +125,7 @@ def program_run(
payload["cost"] = max_execution_time
if start_session:
payload["start_session"] = start_session
payload["session_time"] = session_time
if all([hub, group, project]):
payload["hub"] = hub
payload["group"] = group
Expand Down
6 changes: 3 additions & 3 deletions qiskit_ibm_provider/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,11 @@ def _runtime_run(
if not session.active:
raise RuntimeError(f"The session {session.session_id} is closed.")
session_id = session.session_id
max_execution_time = session._max_time
session_time = session._max_time
start_session = session_id is None
else:
session_id = None
max_execution_time = None
session_time = None
start_session = False

try:
Expand All @@ -533,7 +533,7 @@ def _runtime_run(
job_tags=job_tags,
session_id=session_id,
start_session=start_session,
max_execution_time=max_execution_time,
session_time=session_time,
image=image,
)
except RequestsApiError as ex:
Expand Down

0 comments on commit 5754da1

Please sign in to comment.