Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle maintenance message #2100

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

"""Qiskit runtime service."""

import json
import logging
import traceback
import warnings
Expand Down Expand Up @@ -161,14 +160,8 @@ def __init__(
self._client_params.url = auth_client.current_service_urls()["services"]["runtime"]
self._client_params.token = auth_client.current_access_token()
self._api_client = RuntimeClient(self._client_params)
try:
self._hgps = self._initialize_hgps(auth_client)
except json.decoder.JSONDecodeError:
raise IBMApiError(
"Unexpected response received from server. "
"Please check if the service is in maintenance mode "
"https://docs.quantum.ibm.com/announcements/service-alerts."
)
self._hgps = self._initialize_hgps(auth_client)

self._backend_allowed_list = sorted(
set(sum([hgp.backends for hgp in self._hgps.values()], []))
)
Expand Down Expand Up @@ -275,6 +268,10 @@ def _authenticate_ibm_quantum_account(self, client_params: ClientParameters) ->
Authentication client.
"""
version_info = self._check_api_version(client_params)

if "ERROR" in version_info and version_info["ERROR"]["name"] == "MAINTENANCE": # type: ignore
raise IBMApiError(version_info["ERROR"]["message"]) # type: ignore

# Check the URL is a valid authentication URL.
if not version_info["new_api"] or "api-auth" not in version_info:
raise IBMInputValueError(
Expand Down
Loading