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

Instance & channel_strategy validation #1233

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,17 @@ def _validate_channel_strategy(self) -> None:
instance do not match.

"""
qctrl_enabled = self._api_client.cloud_instance()
if self._channel_strategy == "q-ctrl":
qctrl_enabled = self._api_client.cloud_instance()
if not qctrl_enabled:
raise IBMNotAuthorizedError(
"This account is not authorized to use ``q-ctrl`` as a channel strategy."
"This account is not authorized to use q-ctrl as a channel strategy."
)
else:
if qctrl_enabled:
raise IBMNotAuthorizedError(
"The instance passed in is only compatible with the q-ctrl channel strategy. "
"Please try passing in channel_strategy='q-ctrl'."
)

def _discover_cloud_backends(self) -> Dict[str, "ibm_backend.IBMBackend"]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
If a cloud instance that is `q-ctrl` enabled is used while `q-ctrl` is not
passed in as the `channel_strategy`, an error will be raised.
4 changes: 4 additions & 0 deletions test/unit/mock/fake_runtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ def set_job_classes(self, classes):
classes = [classes]
self._job_classes = classes

def cloud_instance(self):
"""Return whether or not channel_strategy q-ctrl is enabled."""
return False

def set_final_status(self, final_status):
"""Set job status to passed in final status instantly."""
self._final_status = final_status
Expand Down
Loading