iqm-client 28.0.0__py3-none-any.whl → 29.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,13 +13,13 @@
13
13
  # limitations under the License.
14
14
  """Demonstrates executing a quantum circuit on an IQM quantum computer.
15
15
 
16
- Set the IQM_SERVER_URL environment variable before running this script.
16
+ Set the STATION_CONTROL_URL environment variable before running this script.
17
17
  Also, if the server you are running against requires authentication you will also have to set
18
18
  IQM_AUTH_SERVER, and either IQM_TOKENS_FILE or both of IQM_AUTH_USERNAME and IQM_AUTH_PASSWORD.
19
19
 
20
20
  E.g.
21
21
 
22
- export IQM_SERVER_URL="https://example.com/cocos"
22
+ export STATION_CONTROL_URL="https://example.com/station"
23
23
  export IQM_AUTH_SERVER="https://example.com/auth"
24
24
  export IQM_TOKENS_FILE="/path/to/my/tokens.json"
25
25
  """
@@ -45,7 +45,7 @@ def demo_run_circuit() -> None:
45
45
  print("Original circuit:\n")
46
46
  print(circuit)
47
47
 
48
- sampler = IQMSampler(os.environ["IQM_SERVER_URL"])
48
+ sampler = IQMSampler(os.environ["STATION_CONTROL_URL"])
49
49
 
50
50
  circuit_routed, _, _ = sampler.device.route_circuit(circuit)
51
51
  circuit_decomposed = sampler.device.decompose_circuit(circuit_routed)
iqm/iqm_client/api.py CHANGED
@@ -15,149 +15,54 @@
15
15
 
16
16
  from enum import Enum, auto
17
17
  from posixpath import join
18
- import warnings
19
18
 
20
19
 
21
20
  class APIEndpoint(Enum):
22
21
  """Supported API endpoints."""
23
22
 
24
- CONFIGURATION = auto()
25
- SUBMIT_JOB = auto()
26
- GET_JOB_REQUEST_PARAMETERS = auto()
27
23
  GET_JOB_RESULT = auto()
28
- GET_JOB_STATUS = auto()
24
+ GET_JOB_REQUEST_PARAMETERS = auto()
29
25
  GET_JOB_CALIBRATION_SET_ID = auto()
30
26
  GET_JOB_CIRCUITS_BATCH = auto()
31
- GET_JOB_TIMELINE = auto()
32
27
  GET_JOB_ERROR_LOG = auto()
28
+ SUBMIT_JOB = auto()
33
29
  GET_JOB_COUNTS = auto()
30
+ GET_JOB_STATUS = auto()
31
+ GET_JOB_TIMELINE = auto()
34
32
  ABORT_JOB = auto()
35
- DELETE_JOB = auto()
36
- HEALTH = auto()
37
- ABOUT = auto()
38
- CLIENT_LIBRARIES = auto()
39
-
40
- # Calibration and Calibration Service endpoints
41
- CALIBRATION_SERVICE_CONFIGURATION = auto()
42
- QUANTUM_ARCHITECTURE = auto()
43
- STATIC_QUANTUM_ARCHITECTURE = auto()
44
- CHANNEL_PROPERTIES = auto()
45
- QUALITY_METRICS_LATEST = auto()
46
- QUALITY_METRICS = auto()
47
- QUALITY_METRICS_MONITORING = auto()
48
- CALIBRATED_GATES = auto()
49
- START_CALIBRATION_JOB = auto()
50
- ABORT_CALIBRATION_JOB = auto()
51
- CALIBRATION_SERVICE_JOBS = auto()
52
- CALIBRATION = auto()
53
-
54
-
55
- class APIVariant(Enum):
56
- """Supported API versions and variants."""
57
-
58
- V1 = "V1" # QCCSW Cocos-based circuits execution
59
- V2 = "V2" # Station-Control-based circuits execution
60
- RESONANCE_COCOS_V1 = "RESONANCE_COCOS_V1" # IQM Resonance Cocos API
61
33
 
62
34
 
63
35
  class APIConfig:
64
36
  """Provides supported API endpoints for a given API variant."""
65
37
 
66
- def __init__(self, variant: APIVariant, iqm_server_url: str):
38
+ def __init__(self, station_control_url: str):
67
39
  """Args:
68
- variant: API variant.
69
- iqm_server_url: URL of the IQM server,
70
- e.g. https://test.qc.iqm.fi/cocos or https://cocos.resonance.meetiqm.com/garnet for .V1
71
- or https://test.qc.iqm.fi for .V2
40
+ station_control_url: URL of the IQM server,
41
+ e.g. https://test.qc.iqm.fi/station or https://cocos.resonance.meetiqm.com/garnet
72
42
 
73
43
  """
74
- self.variant = variant
75
-
76
- # V1 API is deprecated and will be removed in a future release.
77
- # V2 API is supported by the QCCSW starting with version 3.3.0.
78
- if self.variant == APIVariant.V1:
79
- warnings.warn(
80
- "The V1 API is deprecated and will be removed in a future release. Please use the V2 API instead.",
81
- DeprecationWarning,
82
- )
83
-
84
- self.iqm_server_url = iqm_server_url
44
+ self.station_control_url = station_control_url
85
45
  self.urls = self._get_api_urls()
86
46
 
87
- def _get_api_urls(self) -> dict[APIEndpoint, str]:
47
+ @staticmethod
48
+ def _get_api_urls() -> dict[APIEndpoint, str]:
88
49
  """Returns:
89
50
  Relative URLs for each supported API endpoints.
90
51
 
91
52
  """
92
- if self.variant == APIVariant.RESONANCE_COCOS_V1:
93
- return {
94
- APIEndpoint.SUBMIT_JOB: "jobs",
95
- APIEndpoint.GET_JOB_RESULT: "jobs/%s",
96
- APIEndpoint.GET_JOB_STATUS: "jobs/%s/status",
97
- APIEndpoint.GET_JOB_COUNTS: "jobs/%s/counts",
98
- APIEndpoint.ABORT_JOB: "jobs/%s/abort",
99
- APIEndpoint.QUANTUM_ARCHITECTURE: "quantum-architecture",
100
- APIEndpoint.STATIC_QUANTUM_ARCHITECTURE: "api/v1/quantum-architecture",
101
- APIEndpoint.CALIBRATED_GATES: "api/v1/calibration/%s/gates",
102
- APIEndpoint.CLIENT_LIBRARIES: "info/client-libraries",
103
- }
104
- if self.variant == APIVariant.V1:
105
- return {
106
- APIEndpoint.CONFIGURATION: "configuration",
107
- APIEndpoint.QUALITY_METRICS_LATEST: "calibration/metrics/latest",
108
- APIEndpoint.QUALITY_METRICS: "calibration/metrics/%s",
109
- APIEndpoint.SUBMIT_JOB: "jobs",
110
- APIEndpoint.GET_JOB_RESULT: "jobs/%s",
111
- APIEndpoint.GET_JOB_STATUS: "jobs/%s/status",
112
- APIEndpoint.GET_JOB_COUNTS: "jobs/%s/counts",
113
- APIEndpoint.ABORT_JOB: "jobs/%s/abort",
114
- APIEndpoint.ABORT_CALIBRATION_JOB: "jobs/%s/abort",
115
- APIEndpoint.DELETE_JOB: "jobs/%s",
116
- APIEndpoint.QUANTUM_ARCHITECTURE: "quantum-architecture",
117
- APIEndpoint.STATIC_QUANTUM_ARCHITECTURE: "api/v1/quantum-architecture",
118
- APIEndpoint.CALIBRATED_GATES: "api/v1/calibration/%s/gates",
119
- APIEndpoint.QUALITY_METRICS_MONITORING: "api/v1/monitor/calibration/metrics",
120
- APIEndpoint.HEALTH: "health",
121
- APIEndpoint.ABOUT: "about",
122
- APIEndpoint.CLIENT_LIBRARIES: "info/client-libraries",
123
- APIEndpoint.START_CALIBRATION_JOB: "calibration/run",
124
- APIEndpoint.CALIBRATION_SERVICE_CONFIGURATION: "calibration/configuration",
125
- APIEndpoint.CALIBRATION_SERVICE_JOBS: "calibration/jobs",
126
- APIEndpoint.CALIBRATION: "api/v1/calibration/%s",
127
- APIEndpoint.GET_JOB_ERROR_LOG: "jobs/%s/error_log",
128
- }
129
- if self.variant == APIVariant.V2:
130
- return {
131
- # TODO SW-1387: Use station/v1 API
132
- APIEndpoint.GET_JOB_REQUEST_PARAMETERS: "station/jobs/%s/request_parameters",
133
- APIEndpoint.CONFIGURATION: "cocos/configuration",
134
- APIEndpoint.QUALITY_METRICS_LATEST: "cocos/calibration/metrics/latest",
135
- APIEndpoint.QUALITY_METRICS: "cocos/calibration/metrics/%s",
136
- APIEndpoint.SUBMIT_JOB: "station/circuits",
137
- APIEndpoint.GET_JOB_RESULT: "station/jobs/%s/measurements",
138
- APIEndpoint.GET_JOB_STATUS: "station/jobs/%s/status",
139
- APIEndpoint.GET_JOB_CALIBRATION_SET_ID: "station/jobs/%s/calibration_set_id",
140
- APIEndpoint.GET_JOB_CIRCUITS_BATCH: "station/jobs/%s/circuits_batch",
141
- APIEndpoint.GET_JOB_TIMELINE: "station/jobs/%s/timeline",
142
- APIEndpoint.GET_JOB_ERROR_LOG: "station/jobs/%s/error_log",
143
- APIEndpoint.GET_JOB_COUNTS: "station/circuits/%s/counts",
144
- APIEndpoint.ABORT_JOB: "station/jobs/%s/abort",
145
- APIEndpoint.ABORT_CALIBRATION_JOB: "cocos/jobs/%s/abort",
146
- APIEndpoint.DELETE_JOB: "station/jobs/%s",
147
- APIEndpoint.QUANTUM_ARCHITECTURE: "cocos/quantum-architecture",
148
- APIEndpoint.STATIC_QUANTUM_ARCHITECTURE: "cocos/api/v1/quantum-architecture",
149
- APIEndpoint.CHANNEL_PROPERTIES: "station/channel-properties",
150
- APIEndpoint.CALIBRATED_GATES: "cocos/api/v1/calibration/%s/gates",
151
- APIEndpoint.QUALITY_METRICS_MONITORING: "cocos/api/v1/monitor/calibration/metrics",
152
- APIEndpoint.HEALTH: "cocos/health",
153
- APIEndpoint.ABOUT: "cocos/about",
154
- APIEndpoint.CLIENT_LIBRARIES: "info/client-libraries",
155
- APIEndpoint.START_CALIBRATION_JOB: "cocos/calibration/run",
156
- APIEndpoint.CALIBRATION_SERVICE_CONFIGURATION: "cocos/calibration/configuration",
157
- APIEndpoint.CALIBRATION_SERVICE_JOBS: "cocos/calibration/jobs",
158
- APIEndpoint.CALIBRATION: "cocos/api/v1/calibration/%s",
159
- }
160
- raise ValueError(f"Unsupported API variant: {self.variant}")
53
+ return {
54
+ # TODO SW-1434: Use StationControlClient methods for communication instead of REST endpoints
55
+ APIEndpoint.GET_JOB_RESULT: "jobs/%s/measurements",
56
+ APIEndpoint.GET_JOB_REQUEST_PARAMETERS: "jobs/%s/request_parameters",
57
+ APIEndpoint.GET_JOB_CALIBRATION_SET_ID: "jobs/%s/calibration_set_id",
58
+ APIEndpoint.GET_JOB_CIRCUITS_BATCH: "jobs/%s/circuits_batch",
59
+ APIEndpoint.GET_JOB_ERROR_LOG: "jobs/%s/error_log",
60
+ APIEndpoint.SUBMIT_JOB: "circuits",
61
+ APIEndpoint.GET_JOB_COUNTS: "circuits/%s/counts",
62
+ APIEndpoint.GET_JOB_STATUS: "jobs/%s/status",
63
+ APIEndpoint.GET_JOB_TIMELINE: "jobs/%s/timeline",
64
+ APIEndpoint.ABORT_JOB: "jobs/%s/abort",
65
+ }
161
66
 
162
67
  def is_supported(self, endpoint: APIEndpoint) -> bool:
163
68
  """Args:
@@ -182,6 +87,4 @@ class APIConfig:
182
87
 
183
88
  """
184
89
  url = self.urls.get(endpoint)
185
- if url is None:
186
- raise ValueError(f"Unsupported API endpoint: {endpoint}")
187
- return join(self.iqm_server_url, url % args)
90
+ return join(self.station_control_url, url % args)
@@ -300,7 +300,7 @@ class TokenClient(TokenProviderInterface):
300
300
  if access_token is None:
301
301
  # Failed to get valid access token using username and password, raise an error
302
302
  raise ClientAuthenticationError("Getting access token from auth server failed")
303
- return str(access_token) # acces token can not be None here
303
+ return str(access_token) # access token can not be None here
304
304
 
305
305
  def close(self) -> None:
306
306
  """Close authentication session"""