1414import os
1515
1616from typing import Optional , List , Dict
17- from dotenv import dotenv_values
18-
19- from .scaleway_device import ScalewayDevice
20- from .scaleway_client import QaaSClient
2117
18+ from scaleway_qaas_client import QaaSClient
2219
23- _ENDPOINT_URL = "https://api.scaleway.com/qaas/v1alpha1"
20+ from . scaleway_device import ScalewayDevice
2421
2522
2623class ScalewayQuantumService :
@@ -39,27 +36,19 @@ def __init__(
3936 Returns:
4037 ScalewayDevice: The device that match the given name. None if no match.
4138 """
42- env_token = dotenv_values ().get ("CIRQ_SCALEWAY_API_TOKEN" ) or os .getenv (
43- "CIRQ_SCALEWAY_API_TOKEN"
44- )
45- env_project_id = dotenv_values ().get ("CIRQ_SCALEWAY_PROJECT_ID" ) or os .getenv (
46- "CIRQ_SCALEWAY_PROJECT_ID"
47- )
48- env_api_url = dotenv_values ().get ("CIRQ_SCALEWAY_API_URL" ) or os .getenv (
49- "CIRQ_SCALEWAY_API_URL"
50- )
39+ secret_key = secret_key or os .getenv ("CIRQ_SCALEWAY_SECRET_KEY" )
40+ project_id = project_id or os .getenv ("CIRQ_SCALEWAY_PROJECT_ID" )
41+ url = url or os .getenv ("CIRQ_SCALEWAY_API_URL" )
5142
52- token = secret_key or env_token
53- if token is None :
43+ if secret_key is None :
5444 raise Exception ("secret_key is missing" )
5545
56- project_id = project_id or env_project_id
5746 if project_id is None :
5847 raise Exception ("project_id is missing" )
5948
60- api_url = url or env_api_url or _ENDPOINT_URL
61-
62- self . __client = QaaSClient ( url = api_url , token = token , project_id = project_id )
49+ self . __client = QaaSClient (
50+ url = url , secret_key = secret_key , project_id = project_id
51+ )
6352
6453 def device (self , name : str ) -> ScalewayDevice :
6554 """Returns a device matching the specified name.
@@ -97,20 +86,16 @@ def devices(self, name: Optional[str] = None, **kwargs) -> List[ScalewayDevice]:
9786 if kwargs .get ("min_num_qubits" ) is not None :
9887 filters ["min_num_qubits" ] = kwargs .pop ("min_num_qubits" , None )
9988
100- json_resp = self .__client .list_platforms (name )
89+ platforms = self .__client .list_platforms (name )
10190
102- for platform_dict in json_resp [ " platforms" ] :
103- backend_name = platform_dict . get ( " backend_name" )
91+ for platform in platforms :
92+ backend_name = platform . backend_name
10493
10594 if backend_name == "qsim" :
10695 scaleway_platforms .append (
10796 ScalewayDevice (
10897 client = self .__client ,
109- id = platform_dict .get ("id" ),
110- name = platform_dict .get ("name" ),
111- version = platform_dict .get ("version" ),
112- num_qubits = platform_dict .get ("max_qubit_count" ),
113- metadata = platform_dict .get ("metadata" , None ),
98+ platform = platform ,
11499 )
115100 )
116101
0 commit comments