diff --git a/client/qiskit_serverless/core/clients/serverless_client.py b/client/qiskit_serverless/core/clients/serverless_client.py index b154ac148..ac823ffe2 100644 --- a/client/qiskit_serverless/core/clients/serverless_client.py +++ b/client/qiskit_serverless/core/clients/serverless_client.py @@ -100,7 +100,7 @@ def __init__( # pylint: disable=too-many-positional-arguments version: Optional[str] = None, token: Optional[str] = None, instance: Optional[str] = None, - channel: str = Channel.IBM_QUANTUM.value, + channel: str = Channel.IBM_QUANTUM_PLATFORM.value, ): """ Initializes the ServerlessClient instance. @@ -133,7 +133,7 @@ def __init__( # pylint: disable=too-many-positional-arguments except ValueError as error: raise ValueError( "Your channel value is not correct. Use one of the available channels: " - f"{Channel.LOCAL.value}, {Channel.IBM_QUANTUM.value}, " + f"{Channel.LOCAL.value}, " f"{Channel.IBM_CLOUD.value}, {Channel.IBM_QUANTUM_PLATFORM.value}" ) from error @@ -613,7 +613,7 @@ def __init__( token: Optional[str] = None, name: Optional[str] = None, instance: Optional[str] = None, - channel: str = Channel.IBM_QUANTUM.value, + channel: str = Channel.IBM_QUANTUM_PLATFORM.value, ): """ Initialize a client with access to an IBMQ-provided remote cluster. @@ -674,7 +674,7 @@ def _discover_account( except ValueError as error: raise ValueError( "Your channel value is not correct. Use one of the available channels: " - f"{Channel.LOCAL.value}, {Channel.IBM_QUANTUM.value}, " + f"{Channel.LOCAL.value}, " f"{Channel.IBM_CLOUD.value}, {Channel.IBM_QUANTUM_PLATFORM.value}" ) from error @@ -714,7 +714,7 @@ def save_account( name: Optional[str] = None, overwrite: Optional[bool] = False, instance: Optional[str] = None, - channel: str = Channel.IBM_QUANTUM.value, + channel: str = Channel.IBM_QUANTUM_PLATFORM.value, ) -> None: """ Save the account to disk for future use. diff --git a/client/qiskit_serverless/core/enums.py b/client/qiskit_serverless/core/enums.py index d8bfad352..8b1d355ae 100644 --- a/client/qiskit_serverless/core/enums.py +++ b/client/qiskit_serverless/core/enums.py @@ -10,6 +10,5 @@ class Channel(str, Enum): """ LOCAL = "local" - IBM_QUANTUM = "ibm_quantum" IBM_CLOUD = "ibm_cloud" IBM_QUANTUM_PLATFORM = "ibm_quantum_platform" diff --git a/client/requirements.txt b/client/requirements.txt index d2116191c..783308c78 100644 --- a/client/requirements.txt +++ b/client/requirements.txt @@ -2,7 +2,7 @@ ray[default]>=2.30, <3 requests>=2.32.2, <3 importlib-metadata>=5.2.0, <9 qiskit[qpy-compat]>=1.4, <3 -qiskit-ibm-runtime~=0.40.1 +qiskit-ibm-runtime>=0.40.1, <1 # Make sure ray node and notebook node have the same version of cloudpickle cloudpickle==2.2.1 tqdm>=4.66.3, <5 diff --git a/client/tests/core/test_ibm_serverless_client.py b/client/tests/core/test_ibm_serverless_client.py index 28f21c373..99cd75798 100644 --- a/client/tests/core/test_ibm_serverless_client.py +++ b/client/tests/core/test_ibm_serverless_client.py @@ -18,7 +18,6 @@ from qiskit_serverless import IBMServerlessClient from qiskit_serverless.core.enums import Channel -from qiskit_serverless.exception import QiskitServerlessException class TestIBMServerlessClient(unittest.TestCase): @@ -39,7 +38,6 @@ def test_save_load_account(self, mock_file_path, mock_verify_credentials): mock_file_path.return_value = temp_file.name channels_to_test = [ - Channel.IBM_QUANTUM.value, Channel.IBM_CLOUD.value, Channel.IBM_QUANTUM_PLATFORM.value, ] @@ -64,44 +62,14 @@ def test_save_load_account(self, mock_file_path, mock_verify_credentials): self.assertEqual(client.account.token, use_token) self.assertEqual(client.account.instance, use_instance) - @patch("qiskit_ibm_runtime.accounts.management._DEFAULT_ACCOUNT_CONFIG_JSON_FILE") - def test_save_wrong_instance(self, mock_file_path): - """Test saving with wrong instance format (ibm_quantum channel).""" - - # Save config in a temporary file - with tempfile.NamedTemporaryFile() as temp_file: - mock_file_path.return_value = temp_file.name - - use_channel = Channel.IBM_QUANTUM.value - use_instance = "wrong_ibm_quantum_instance" - use_token = "save_token" - use_name = f"test_save_account_{uuid.uuid4().hex}" - - with self.assertRaisesRegex( - QiskitServerlessException, - r"Invalid format in account inputs - 'Invalid `instance` value\. " - "Expected hub/group/project format, got wrong_ibm_quantum_instance'", - ): - - IBMServerlessClient.save_account( - token=use_token, - name=use_name, - instance=use_instance, - channel=use_channel, - ) - - def test_init_wrong_instance(self): - """Test initializing account with wrong instance format (ibm_quantum channel).""" + def test_ibm_quantum_channel(self): + """Test error raised when initializing account with `ibm_quantum` channel.""" - use_channel = Channel.IBM_QUANTUM.value - use_instance = "wrong_ibm_quantum_instance" + use_channel = "ibm_quantum" + use_instance = "h/g/p" use_token = "save_token" - with self.assertRaisesRegex( - QiskitServerlessException, - r"Invalid format in account inputs - 'Invalid `instance` value\. " - "Expected hub/group/project format, got wrong_ibm_quantum_instance'", - ): + with self.assertRaisesRegex(ValueError, r"Your channel value is not correct"): IBMServerlessClient( channel=use_channel, instance=use_instance, token=use_token diff --git a/client/tests/core/test_job.py b/client/tests/core/test_job.py index d78a64a98..10208bc64 100644 --- a/client/tests/core/test_job.py +++ b/client/tests/core/test_job.py @@ -91,7 +91,9 @@ def test_update_sub_status(self, job_env_variables): @patch("requests.get", Mock(return_value=ResponseMock())) def test_filtered_logs(self): """Tests job filtered log.""" - client = ServerlessClient(host="host", token="token", version="version") + client = ServerlessClient( + host="host", token="token", instance="crn", version="version" + ) client.logs = MagicMock( return_value="This is the line 1\nThis is the second line\nOK. This is the last line.\n", # pylint: disable=line-too-long ) @@ -108,7 +110,9 @@ def test_filtered_logs(self): @patch("requests.get", Mock(return_value=ResponseMock())) def test_error_message(self): """Tests job filtered log.""" - client = ServerlessClient(host="host", token="token", version="version") + client = ServerlessClient( + host="host", token="token", instance="crn", version="version" + ) client.status = MagicMock( return_value="ERROR", ) diff --git a/tests/basic/01_running_program.py b/tests/basic/01_running_program.py index e48301e44..49f34889a 100644 --- a/tests/basic/01_running_program.py +++ b/tests/basic/01_running_program.py @@ -7,6 +7,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/basic/02_arguments_and_results.py b/tests/basic/02_arguments_and_results.py index 383a7cdd3..d279faec4 100644 --- a/tests/basic/02_arguments_and_results.py +++ b/tests/basic/02_arguments_and_results.py @@ -14,6 +14,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/basic/03_dependencies.py b/tests/basic/03_dependencies.py index 1666440cf..a44b0d5e6 100644 --- a/tests/basic/03_dependencies.py +++ b/tests/basic/03_dependencies.py @@ -15,6 +15,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/basic/04_distributed_workloads.py b/tests/basic/04_distributed_workloads.py index 910f1e744..001809757 100644 --- a/tests/basic/04_distributed_workloads.py +++ b/tests/basic/04_distributed_workloads.py @@ -6,6 +6,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/basic/05_retrieving_past_results.py b/tests/basic/05_retrieving_past_results.py index 9401ee023..adb2a027d 100644 --- a/tests/basic/05_retrieving_past_results.py +++ b/tests/basic/05_retrieving_past_results.py @@ -6,6 +6,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/basic/06_function.py b/tests/basic/06_function.py index 1481f2d07..14e228d53 100644 --- a/tests/basic/06_function.py +++ b/tests/basic/06_function.py @@ -4,6 +4,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) help = """ diff --git a/tests/docker/conftest.py b/tests/docker/conftest.py index fda2e3492..6b3ae4971 100644 --- a/tests/docker/conftest.py +++ b/tests/docker/conftest.py @@ -44,6 +44,7 @@ def set_up_serverless_client(): serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", connection_url), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) # Initialize serverless folder for current user diff --git a/tests/experimental/file_download.py b/tests/experimental/file_download.py index 658740577..290fae3f2 100644 --- a/tests/experimental/file_download.py +++ b/tests/experimental/file_download.py @@ -6,6 +6,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/experimental/manage_data_directory.py b/tests/experimental/manage_data_directory.py index 9abbf563d..75ecd4e4a 100644 --- a/tests/experimental/manage_data_directory.py +++ b/tests/experimental/manage_data_directory.py @@ -6,6 +6,7 @@ serverless = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(serverless) diff --git a/tests/experimental/running_programs_using_decorators.py b/tests/experimental/running_programs_using_decorators.py index b831df49f..4f4f5651f 100644 --- a/tests/experimental/running_programs_using_decorators.py +++ b/tests/experimental/running_programs_using_decorators.py @@ -16,6 +16,7 @@ provider = ServerlessClient( token=os.environ.get("GATEWAY_TOKEN", "awesome_token"), host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"), + instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"), ) print(provider)