pasqal-cloud 0.20.4.dev0__tar.gz → 0.20.6__tar.gz
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.
- {pasqal_cloud-0.20.4.dev0/pasqal_cloud.egg-info → pasqal_cloud-0.20.6}/PKG-INFO +11 -5
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/README.md +6 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/__init__.py +75 -5
- pasqal_cloud-0.20.6/pasqal_cloud/_version.py +2 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/batch.py +1 -2
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/client.py +96 -26
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/endpoints.py +10 -3
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/errors.py +27 -0
- pasqal_cloud-0.20.6/pasqal_cloud/project.py +8 -0
- pasqal_cloud-0.20.6/pasqal_cloud/utils/__init__.py +3 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/jsend.py +1 -0
- pasqal_cloud-0.20.6/pasqal_cloud/utils/mock_server.py +293 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6/pasqal_cloud.egg-info}/PKG-INFO +11 -5
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud.egg-info/SOURCES.txt +2 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/setup.py +1 -1
- pasqal_cloud-0.20.4.dev0/pasqal_cloud/_version.py +0 -2
- pasqal_cloud-0.20.4.dev0/pasqal_cloud/utils/__init__.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/LICENSE +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/MANIFEST.in +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/authentication.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/__init__.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/__init__.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/base_config.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_free.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_fresnel.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_tn.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/result_type.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/device_types.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/emulator_types.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/job.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/py.typed +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/constants.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/filters.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/responses.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/retry.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/utils/strenum.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/workload.py +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud.egg-info/dependency_links.txt +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud.egg-info/requires.txt +4 -4
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud.egg-info/top_level.txt +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pyproject.toml +0 -0
- {pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pasqal-cloud
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.6
|
|
4
4
|
Summary: Software development kit for Pasqal cloud platform.
|
|
5
5
|
Home-page: https://github.com/pasqal-io/pasqal-cloud
|
|
6
6
|
Maintainer: Pasqal Cloud Services
|
|
@@ -15,18 +15,18 @@ Requires-Dist: auth0-python<4.0.0,>=3.23.1
|
|
|
15
15
|
Requires-Dist: requests<3.0.0,>=2.25.1
|
|
16
16
|
Requires-Dist: pyjwt[crypto]<3.0.0,>=2.5.0
|
|
17
17
|
Requires-Dist: pydantic<3.0.0,>=2.6.0
|
|
18
|
+
Requires-Dist: requests-mock==1.12.1
|
|
18
19
|
Provides-Extra: dev
|
|
19
|
-
Requires-Dist: types-requests==2.31.0.1; extra == "dev"
|
|
20
|
-
Requires-Dist: ruff==0.6.9; extra == "dev"
|
|
21
20
|
Requires-Dist: mypy==1.10.0; extra == "dev"
|
|
21
|
+
Requires-Dist: types-requests==2.31.0.1; extra == "dev"
|
|
22
22
|
Requires-Dist: pytest-cov==5.0.0; extra == "dev"
|
|
23
23
|
Requires-Dist: pytest==8.1.1; extra == "dev"
|
|
24
|
-
Requires-Dist:
|
|
24
|
+
Requires-Dist: ruff==0.6.9; extra == "dev"
|
|
25
25
|
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
|
|
26
27
|
Requires-Dist: mkdocstrings-python==1.13.0; extra == "docs"
|
|
27
28
|
Requires-Dist: mkdocs==1.6.1; extra == "docs"
|
|
28
29
|
Requires-Dist: mkdocs-material==9.5.50; extra == "docs"
|
|
29
|
-
Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
|
|
30
30
|
Dynamic: classifier
|
|
31
31
|
Dynamic: description
|
|
32
32
|
Dynamic: description-content-type
|
|
@@ -346,6 +346,12 @@ sdk.get_device_specs_dict()
|
|
|
346
346
|
The method returns a dict object mapping a device type to a serialized device specs. These specs can be used
|
|
347
347
|
to instantiate a `Device` instance in the `Pulser` library.
|
|
348
348
|
|
|
349
|
+
### Use the pasqal-cloud SDK behind a proxy
|
|
350
|
+
|
|
351
|
+
The pasqal-cloud SDK uses the [`requests` library](https://requests.readthedocs.io/en/latest/) to make HTTP calls to Pasqal's cloud APIs.
|
|
352
|
+
|
|
353
|
+
Please refer to the [requests documentation](https://requests.readthedocs.io/en/latest/user/advanced/#proxies) to use the SDK behind a proxy. Be sure to set the HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY environment variables to route traffic through your proxy. If your proxy uses a self-signed certificate, the certificate authority must be included in your CA bundle. One way to do it is to set the environment variable REQUESTS_CA_BUNDLE to the path of the file containing the certificate authority.
|
|
354
|
+
|
|
349
355
|
### Target different API endpoints
|
|
350
356
|
|
|
351
357
|
This is intended for the package developers or users which were given access to non-prod
|
|
@@ -304,6 +304,12 @@ sdk.get_device_specs_dict()
|
|
|
304
304
|
The method returns a dict object mapping a device type to a serialized device specs. These specs can be used
|
|
305
305
|
to instantiate a `Device` instance in the `Pulser` library.
|
|
306
306
|
|
|
307
|
+
### Use the pasqal-cloud SDK behind a proxy
|
|
308
|
+
|
|
309
|
+
The pasqal-cloud SDK uses the [`requests` library](https://requests.readthedocs.io/en/latest/) to make HTTP calls to Pasqal's cloud APIs.
|
|
310
|
+
|
|
311
|
+
Please refer to the [requests documentation](https://requests.readthedocs.io/en/latest/user/advanced/#proxies) to use the SDK behind a proxy. Be sure to set the HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY environment variables to route traffic through your proxy. If your proxy uses a self-signed certificate, the certificate authority must be included in your CA bundle. One way to do it is to set the environment variable REQUESTS_CA_BUNDLE to the path of the file containing the certificate authority.
|
|
312
|
+
|
|
307
313
|
### Target different API endpoints
|
|
308
314
|
|
|
309
315
|
This is intended for the package developers or users which were given access to non-prod
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import time
|
|
15
15
|
from datetime import datetime, timedelta, timezone
|
|
16
|
-
from typing import Any, Dict, List, Optional, Union
|
|
16
|
+
from typing import Any, Dict, List, Optional, Type, Union
|
|
17
17
|
from uuid import UUID
|
|
18
18
|
from warnings import simplefilter, warn
|
|
19
19
|
|
|
@@ -45,12 +45,15 @@ from pasqal_cloud.errors import (
|
|
|
45
45
|
JobCreationError,
|
|
46
46
|
JobFetchingError,
|
|
47
47
|
OnlyCompleteOrOpenCanBeSet,
|
|
48
|
+
ProjectFetchingError,
|
|
49
|
+
ProjectNotFoundError,
|
|
48
50
|
RebatchError,
|
|
49
51
|
WorkloadCancellingError,
|
|
50
52
|
WorkloadCreationError,
|
|
51
53
|
WorkloadFetchingError,
|
|
52
54
|
)
|
|
53
55
|
from pasqal_cloud.job import CreateJob, Job
|
|
56
|
+
from pasqal_cloud.project import Project
|
|
54
57
|
from pasqal_cloud.utils.constants import ( # noqa: F401
|
|
55
58
|
BatchStatus,
|
|
56
59
|
JobStatus,
|
|
@@ -117,6 +120,7 @@ class SDK:
|
|
|
117
120
|
auth0: Optional[Auth0Conf] = None,
|
|
118
121
|
webhook: Optional[str] = None,
|
|
119
122
|
project_id: Optional[str] = None,
|
|
123
|
+
client_class: Type[Client] = Client,
|
|
120
124
|
):
|
|
121
125
|
"""
|
|
122
126
|
This class provides helper methods to call the Pasqal Cloud endpoints.
|
|
@@ -144,10 +148,12 @@ class SDK:
|
|
|
144
148
|
endpoints: Endpoints targeted of the public apis.
|
|
145
149
|
auth0: Auth0Config object to define the auth0 tenant to target.
|
|
146
150
|
project_id: ID of the owner project of the batch.
|
|
151
|
+
client_class: client class used to determine authentification \
|
|
152
|
+
and endpoints targeted by the SDK
|
|
147
153
|
"""
|
|
148
154
|
_check_sdk_version()
|
|
149
155
|
|
|
150
|
-
self._client =
|
|
156
|
+
self._client = client_class(
|
|
151
157
|
project_id=project_id,
|
|
152
158
|
username=username,
|
|
153
159
|
password=password,
|
|
@@ -155,6 +161,7 @@ class SDK:
|
|
|
155
161
|
endpoints=endpoints,
|
|
156
162
|
auth0=auth0,
|
|
157
163
|
)
|
|
164
|
+
|
|
158
165
|
self.batches: Dict[str, Batch] = {}
|
|
159
166
|
self.workloads: Dict[str, Workload] = {}
|
|
160
167
|
self.webhook = webhook
|
|
@@ -162,6 +169,14 @@ class SDK:
|
|
|
162
169
|
def user_token(self) -> Union[str, None]:
|
|
163
170
|
return self._client.user_token()
|
|
164
171
|
|
|
172
|
+
@property
|
|
173
|
+
def project_id(self) -> Union[str, None]:
|
|
174
|
+
return self._client._project_id
|
|
175
|
+
|
|
176
|
+
@project_id.setter
|
|
177
|
+
def project_id(self, project_id: str) -> None:
|
|
178
|
+
self._client._project_id = project_id
|
|
179
|
+
|
|
165
180
|
def _get_batch(
|
|
166
181
|
self,
|
|
167
182
|
id: str,
|
|
@@ -175,7 +190,7 @@ class SDK:
|
|
|
175
190
|
self,
|
|
176
191
|
emulator: Optional[EmulatorType],
|
|
177
192
|
device_type: Optional[DeviceTypeName],
|
|
178
|
-
) -> DeviceTypeName:
|
|
193
|
+
) -> Optional[DeviceTypeName]:
|
|
179
194
|
if emulator is not None and device_type is not None:
|
|
180
195
|
raise InvalidDeviceTypeSet
|
|
181
196
|
if emulator is not None:
|
|
@@ -186,10 +201,22 @@ class SDK:
|
|
|
186
201
|
stacklevel=2,
|
|
187
202
|
)
|
|
188
203
|
return DeviceTypeName(str(emulator))
|
|
189
|
-
if emulator is None and device_type is None:
|
|
190
|
-
return DeviceTypeName.FRESNEL
|
|
191
204
|
return device_type
|
|
192
205
|
|
|
206
|
+
def _validate_device_type_choice(
|
|
207
|
+
self, device_type: Optional[DeviceTypeName]
|
|
208
|
+
) -> None:
|
|
209
|
+
if not device_type:
|
|
210
|
+
return
|
|
211
|
+
|
|
212
|
+
if device_type == DeviceTypeName.EMU_TN:
|
|
213
|
+
warn(
|
|
214
|
+
"EMU_TN is deprecated and will be removed in a future"
|
|
215
|
+
" release. Use EMU_MPS instead.",
|
|
216
|
+
DeprecationWarning,
|
|
217
|
+
stacklevel=2,
|
|
218
|
+
)
|
|
219
|
+
|
|
193
220
|
def _validate_open(
|
|
194
221
|
self,
|
|
195
222
|
complete: Optional[bool],
|
|
@@ -255,6 +282,8 @@ class SDK:
|
|
|
255
282
|
device_type = self._validate_device_type(emulator, device_type)
|
|
256
283
|
open = self._validate_open(complete, open)
|
|
257
284
|
|
|
285
|
+
self._validate_device_type_choice(device_type)
|
|
286
|
+
|
|
258
287
|
if fetch_results:
|
|
259
288
|
warn(
|
|
260
289
|
"Argument `fetch_results` is deprecated and will be removed in a"
|
|
@@ -809,3 +838,44 @@ class SDK:
|
|
|
809
838
|
raise BatchSetTagsError(e)
|
|
810
839
|
|
|
811
840
|
return Batch(**resp, _client=self._client)
|
|
841
|
+
|
|
842
|
+
def get_all_projects(
|
|
843
|
+
self,
|
|
844
|
+
) -> list[Project]:
|
|
845
|
+
"""Retrieve all active projects the user is a member of.
|
|
846
|
+
|
|
847
|
+
Returns:
|
|
848
|
+
list[Project]: A list of all active projects that
|
|
849
|
+
the user is a member of.
|
|
850
|
+
|
|
851
|
+
Raises:
|
|
852
|
+
ProjectFetchingError: If fetching projects failed.
|
|
853
|
+
"""
|
|
854
|
+
try:
|
|
855
|
+
response = self._client.get_all_active_projects()
|
|
856
|
+
except HTTPError as e:
|
|
857
|
+
raise ProjectFetchingError(e)
|
|
858
|
+
|
|
859
|
+
return [Project(**project) for project in response]
|
|
860
|
+
|
|
861
|
+
def switch_to_project(self, project_id: str) -> str:
|
|
862
|
+
"""Switch the SDK context to a different project.
|
|
863
|
+
|
|
864
|
+
Args:
|
|
865
|
+
project_id: The ID of the project to switch to.
|
|
866
|
+
|
|
867
|
+
Returns:
|
|
868
|
+
str: The ID of the newly chosen project.
|
|
869
|
+
|
|
870
|
+
Raises:
|
|
871
|
+
ProjectNotFoundError: If the specified project ID doesn't
|
|
872
|
+
exist or isn't accessible to the current user.
|
|
873
|
+
"""
|
|
874
|
+
user_projects = self.get_all_projects()
|
|
875
|
+
|
|
876
|
+
if not any(project.id == project_id for project in user_projects):
|
|
877
|
+
raise ProjectNotFoundError(project_id)
|
|
878
|
+
|
|
879
|
+
self.project_id = project_id
|
|
880
|
+
|
|
881
|
+
return self.project_id
|
|
@@ -120,7 +120,6 @@ class Batch(BaseModel):
|
|
|
120
120
|
def ordered_jobs(self, value: Any) -> None:
|
|
121
121
|
self._ordered_jobs = value
|
|
122
122
|
|
|
123
|
-
# Ticket (#704), to be removed or updated
|
|
124
123
|
@property
|
|
125
124
|
def jobs(self) -> Dict[str, Job]:
|
|
126
125
|
"""Once the 'ordered_jobs' is built, we need to keep the 'jobs' attribute
|
|
@@ -264,7 +263,7 @@ class Batch(BaseModel):
|
|
|
264
263
|
# Private fields are not exposed by the model_fields method, so we need to
|
|
265
264
|
# explicitly add _ordered_jobs to ensure it is copied from the updated_batch
|
|
266
265
|
# model.
|
|
267
|
-
batch_model_fields = [*list(
|
|
266
|
+
batch_model_fields = [*list(Batch.model_fields), "_ordered_jobs"]
|
|
268
267
|
for field in batch_model_fields:
|
|
269
268
|
value = getattr(updated_batch, field)
|
|
270
269
|
setattr(self, field, value)
|
|
@@ -46,10 +46,6 @@ def _skip_ssl_verify() -> bool:
|
|
|
46
46
|
return bool(os.getenv("PASQAL_SKIP_SSL_VERIFY", False))
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
class EmptyFilter:
|
|
50
|
-
pass
|
|
51
|
-
|
|
52
|
-
|
|
53
49
|
class Client:
|
|
54
50
|
authenticator: AuthBase | None
|
|
55
51
|
|
|
@@ -80,6 +76,67 @@ class Client:
|
|
|
80
76
|
self.session = requests.Session()
|
|
81
77
|
self.session.verify = not _skip_ssl_verify()
|
|
82
78
|
|
|
79
|
+
def _get_api_urls(self) -> Dict[str, str]:
|
|
80
|
+
"""Return a dictionary mapping API endpoint names to their URLs."""
|
|
81
|
+
return {
|
|
82
|
+
# Batch endpoints
|
|
83
|
+
"send_batch": f"{self.endpoints.core}/api/v1/batches",
|
|
84
|
+
"get_batch": f"{self.endpoints.core}/api/v2/batches/{{batch_id}}",
|
|
85
|
+
"close_batch": f"{self.endpoints.core}/api/v2/"
|
|
86
|
+
f"batches/{{batch_id}}/complete",
|
|
87
|
+
"cancel_batch": f"{self.endpoints.core}/api/v2/"
|
|
88
|
+
f"batches/{{batch_id}}/cancel",
|
|
89
|
+
"cancel_batches": f"{self.endpoints.core}/api/v1/batches/cancel",
|
|
90
|
+
"rebatch": f"{self.endpoints.core}/api/v1/batches/{{batch_id}}/rebatch",
|
|
91
|
+
"get_batches": f"{self.endpoints.core}/api/v1/batches",
|
|
92
|
+
"add_jobs": f"{self.endpoints.core}/api/v2/batches/{{batch_id}}/jobs",
|
|
93
|
+
"set_batch_tags": f"{self.endpoints.core}/api/v1/batches/{{batch_id}}/tags",
|
|
94
|
+
"cancel_jobs": f"{self.endpoints.core}/api/v2/batches/"
|
|
95
|
+
f"{{batch_id}}/cancel/jobs",
|
|
96
|
+
# Job endpoints
|
|
97
|
+
"get_jobs": f"{self.endpoints.core}/api/v2/jobs",
|
|
98
|
+
"get_job": f"{self.endpoints.core}/api/v2/jobs/{{job_id}}",
|
|
99
|
+
"cancel_job": f"{self.endpoints.core}/api/v2/jobs/{{job_id}}/cancel",
|
|
100
|
+
"get_job_results_link": f"{self.endpoints.core}/api/v1/"
|
|
101
|
+
f"jobs/{{job_id}}/results_link",
|
|
102
|
+
# Workload endpoints
|
|
103
|
+
"send_workload": f"{self.endpoints.core}/api/v1/workloads",
|
|
104
|
+
"get_workload": f"{self.endpoints.core}/api/v2/workloads/{{workload_id}}",
|
|
105
|
+
"cancel_workload": f"{self.endpoints.core}/api/v1/"
|
|
106
|
+
f"workloads/{{workload_id}}/cancel",
|
|
107
|
+
# Device endpoints
|
|
108
|
+
"get_devices_specs": f"{self.endpoints.core}/api/v1/devices/specs",
|
|
109
|
+
"get_public_devices_specs": f"{self.endpoints.core}"
|
|
110
|
+
f"/api/v1/devices/public-specs",
|
|
111
|
+
# Project endpoints
|
|
112
|
+
"get_all_active_projects": f"{self.endpoints.account}/api/v1/projects",
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
def _get_url(self, endpoint_name: str, **kwargs: Any) -> str:
|
|
116
|
+
"""Get the URL for a specific endpoint, with path parameters substituted.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
endpoint_name: The name of the endpoint from _get_api_urls()
|
|
120
|
+
**kwargs: Path parameters to substitute in the URL template
|
|
121
|
+
Possible parameters: batch_id, job_id, workload_id
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
The formatted URL
|
|
125
|
+
"""
|
|
126
|
+
urls = self._get_api_urls()
|
|
127
|
+
if endpoint_name not in urls:
|
|
128
|
+
raise ValueError(
|
|
129
|
+
self.unknown_endpoint_message.format(endpoint=endpoint_name)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
url_template = urls[endpoint_name]
|
|
133
|
+
# Format the URL with any provided path parameters
|
|
134
|
+
return url_template.format(**kwargs)
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def unknown_endpoint_message(self) -> str:
|
|
138
|
+
return "Unknown endpoint: {endpoint}"
|
|
139
|
+
|
|
83
140
|
def user_token(self) -> Union[str, None]:
|
|
84
141
|
return (
|
|
85
142
|
self.authenticator.token_provider.get_token() # type: ignore[attr-defined]
|
|
@@ -238,24 +295,24 @@ class Client:
|
|
|
238
295
|
batch_data.update({"project_id": self.project_id})
|
|
239
296
|
response: Dict[str, Any] = self._authenticated_request(
|
|
240
297
|
"POST",
|
|
241
|
-
|
|
298
|
+
self._get_url("send_batch"),
|
|
242
299
|
batch_data,
|
|
243
300
|
)["data"]
|
|
244
301
|
return response
|
|
245
302
|
|
|
246
303
|
def get_batch(self, batch_id: str) -> Dict[str, Any]:
|
|
247
304
|
response: Dict[str, Any] = self._authenticated_request(
|
|
248
|
-
"GET",
|
|
305
|
+
"GET", self._get_url("get_batch", batch_id=batch_id)
|
|
249
306
|
)["data"]
|
|
250
307
|
return response
|
|
251
308
|
|
|
252
309
|
def get_batch_jobs(self, batch_id: str) -> list[Dict[str, Any]]:
|
|
253
310
|
return self._request_all_pages(
|
|
254
311
|
"GET",
|
|
255
|
-
|
|
312
|
+
self._get_url("get_jobs"),
|
|
256
313
|
params={
|
|
257
314
|
"batch_id": batch_id,
|
|
258
|
-
"order_by": "
|
|
315
|
+
"order_by": "creation_order",
|
|
259
316
|
"order_by_direction": "ASC",
|
|
260
317
|
},
|
|
261
318
|
# The order-by parameters are required to ensure that the jobs appear in
|
|
@@ -268,7 +325,10 @@ class Client:
|
|
|
268
325
|
response.raise_for_status()
|
|
269
326
|
data = response.json()
|
|
270
327
|
return JobResult(
|
|
271
|
-
raw=data.pop("raw", None),
|
|
328
|
+
raw=data.pop("raw", None),
|
|
329
|
+
counter=data.pop("counter", None),
|
|
330
|
+
serialised_results=data.pop("serialised_results", None),
|
|
331
|
+
**data
|
|
272
332
|
)
|
|
273
333
|
|
|
274
334
|
def get_job_results(self, job_id: str) -> Optional[JobResult]:
|
|
@@ -279,7 +339,7 @@ class Client:
|
|
|
279
339
|
Once the presigned-url is obtained, it downloads the result from S3.
|
|
280
340
|
"""
|
|
281
341
|
results_link = self._authenticated_request(
|
|
282
|
-
"GET",
|
|
342
|
+
"GET", self._get_url("get_job_results_link", job_id=job_id)
|
|
283
343
|
)["data"]["results_link"]
|
|
284
344
|
if results_link:
|
|
285
345
|
return self._download_results(results_link)
|
|
@@ -287,20 +347,20 @@ class Client:
|
|
|
287
347
|
|
|
288
348
|
def close_batch(self, batch_id: str) -> Dict[str, Any]:
|
|
289
349
|
response: Dict[str, Any] = self._authenticated_request(
|
|
290
|
-
"PATCH",
|
|
350
|
+
"PATCH", self._get_url("close_batch", batch_id=batch_id)
|
|
291
351
|
)["data"]
|
|
292
352
|
return response
|
|
293
353
|
|
|
294
354
|
def cancel_batch(self, batch_id: str) -> Dict[str, Any]:
|
|
295
355
|
response: Dict[str, Any] = self._authenticated_request(
|
|
296
|
-
"PATCH",
|
|
356
|
+
"PATCH", self._get_url("cancel_batch", batch_id=batch_id)
|
|
297
357
|
)["data"]
|
|
298
358
|
return response
|
|
299
359
|
|
|
300
360
|
def cancel_batches(self, batch_ids: List[str]) -> Dict[str, Any]:
|
|
301
361
|
response: Dict[str, Any] = self._authenticated_request(
|
|
302
362
|
"PATCH",
|
|
303
|
-
|
|
363
|
+
self._get_url("cancel_batches"),
|
|
304
364
|
payload={"batch_ids": batch_ids},
|
|
305
365
|
)["data"]
|
|
306
366
|
return response
|
|
@@ -310,7 +370,7 @@ class Client:
|
|
|
310
370
|
) -> Dict[str, Any]:
|
|
311
371
|
response: Dict[str, Any] = self._authenticated_request(
|
|
312
372
|
"POST",
|
|
313
|
-
|
|
373
|
+
self._get_url("rebatch", batch_id=batch_id),
|
|
314
374
|
params=filters.model_dump(exclude_unset=True),
|
|
315
375
|
)["data"]
|
|
316
376
|
return response
|
|
@@ -322,7 +382,7 @@ class Client:
|
|
|
322
382
|
filters_params.update(pagination_params.model_dump())
|
|
323
383
|
response: JSendPayload = self._authenticated_request(
|
|
324
384
|
"GET",
|
|
325
|
-
|
|
385
|
+
self._get_url("get_jobs"),
|
|
326
386
|
params=filters_params,
|
|
327
387
|
)
|
|
328
388
|
return response
|
|
@@ -334,7 +394,7 @@ class Client:
|
|
|
334
394
|
filters_params.update(pagination_params.model_dump())
|
|
335
395
|
response: JSendPayload = self._authenticated_request(
|
|
336
396
|
"GET",
|
|
337
|
-
|
|
397
|
+
self._get_url("get_batches"),
|
|
338
398
|
params=filters_params,
|
|
339
399
|
)
|
|
340
400
|
return response
|
|
@@ -343,19 +403,19 @@ class Client:
|
|
|
343
403
|
self, batch_id: str, jobs_data: Sequence[Mapping[str, Any]]
|
|
344
404
|
) -> Dict[str, Any]:
|
|
345
405
|
response: Dict[str, Any] = self._authenticated_request(
|
|
346
|
-
"POST",
|
|
406
|
+
"POST", self._get_url("add_jobs", batch_id=batch_id), jobs_data
|
|
347
407
|
)["data"]
|
|
348
408
|
return response
|
|
349
409
|
|
|
350
410
|
def get_job(self, job_id: str) -> Dict[str, Any]:
|
|
351
411
|
response: Dict[str, Any] = self._authenticated_request(
|
|
352
|
-
"GET",
|
|
412
|
+
"GET", self._get_url("get_job", job_id=job_id)
|
|
353
413
|
)["data"]
|
|
354
414
|
return response
|
|
355
415
|
|
|
356
416
|
def cancel_job(self, job_id: str) -> Dict[str, Any]:
|
|
357
417
|
response: Dict[str, Any] = self._authenticated_request(
|
|
358
|
-
"PATCH",
|
|
418
|
+
"PATCH", self._get_url("cancel_job", job_id=job_id)
|
|
359
419
|
)["data"]
|
|
360
420
|
return response
|
|
361
421
|
|
|
@@ -364,7 +424,7 @@ class Client:
|
|
|
364
424
|
) -> Dict[str, Any]:
|
|
365
425
|
response: Dict[str, Any] = self._authenticated_request(
|
|
366
426
|
"PATCH",
|
|
367
|
-
|
|
427
|
+
self._get_url("cancel_jobs", batch_id=batch_id),
|
|
368
428
|
params=filters.model_dump(exclude_unset=True),
|
|
369
429
|
)["data"]
|
|
370
430
|
return response
|
|
@@ -373,27 +433,27 @@ class Client:
|
|
|
373
433
|
workload_data.update({"project_id": self.project_id})
|
|
374
434
|
response: Dict[str, Any] = self._authenticated_request(
|
|
375
435
|
"POST",
|
|
376
|
-
|
|
436
|
+
self._get_url("send_workload"),
|
|
377
437
|
workload_data,
|
|
378
438
|
)["data"]
|
|
379
439
|
return response
|
|
380
440
|
|
|
381
441
|
def get_workload(self, workload_id: str) -> Dict[str, Any]:
|
|
382
442
|
response: Dict[str, Any] = self._authenticated_request(
|
|
383
|
-
"GET",
|
|
443
|
+
"GET", self._get_url("get_workload", workload_id=workload_id)
|
|
384
444
|
)["data"]
|
|
385
445
|
return response
|
|
386
446
|
|
|
387
447
|
def cancel_workload(self, workload_id: str) -> Dict[str, Any]:
|
|
388
448
|
response: Dict[str, Any] = self._authenticated_request(
|
|
389
|
-
"PUT",
|
|
449
|
+
"PUT", self._get_url("cancel_workload", workload_id=workload_id)
|
|
390
450
|
)["data"]
|
|
391
451
|
return response
|
|
392
452
|
|
|
393
453
|
def get_device_specs_dict(self) -> Dict[str, str]:
|
|
394
454
|
if self.authenticator is not None:
|
|
395
455
|
response: Dict[str, str] = self._authenticated_request(
|
|
396
|
-
"GET",
|
|
456
|
+
"GET", self._get_url("get_devices_specs")
|
|
397
457
|
)["data"]
|
|
398
458
|
return response
|
|
399
459
|
return self.get_public_device_specs()
|
|
@@ -401,7 +461,7 @@ class Client:
|
|
|
401
461
|
def get_public_device_specs(self) -> Dict[str, str]:
|
|
402
462
|
response = self.session.request(
|
|
403
463
|
"GET",
|
|
404
|
-
|
|
464
|
+
self._get_url("get_public_devices_specs"),
|
|
405
465
|
)
|
|
406
466
|
response.raise_for_status()
|
|
407
467
|
devices = response.json()["data"]
|
|
@@ -414,7 +474,17 @@ class Client:
|
|
|
414
474
|
) -> Dict[str, str]:
|
|
415
475
|
response: Dict[str, Any] = self._authenticated_request(
|
|
416
476
|
"PATCH",
|
|
417
|
-
|
|
477
|
+
self._get_url("set_batch_tags", batch_id=batch_id),
|
|
418
478
|
tags,
|
|
419
479
|
)["data"]
|
|
420
480
|
return response
|
|
481
|
+
|
|
482
|
+
def get_all_active_projects(
|
|
483
|
+
self,
|
|
484
|
+
) -> List[Dict[str, Any]]:
|
|
485
|
+
response: List[Dict[str, Any]] = self._authenticated_request(
|
|
486
|
+
"GET",
|
|
487
|
+
self._get_url("get_all_active_projects"),
|
|
488
|
+
params={"project_status": "ACTIVE"},
|
|
489
|
+
)["data"]
|
|
490
|
+
return response
|
|
@@ -25,14 +25,21 @@ else:
|
|
|
25
25
|
# Prod Core API URL
|
|
26
26
|
CORE_API_URL: Final[str] = "https://apis.pasqal.cloud/core-fast"
|
|
27
27
|
|
|
28
|
+
ACCOUNT_API_URL: Final[str] = "https://apis.pasqal.cloud/account"
|
|
29
|
+
|
|
28
30
|
PREPROD_CORE_API_URL: Final[str] = "https://apis.preprod.pasqal.cloud/core-fast"
|
|
29
31
|
|
|
32
|
+
PREPROD_ACCOUNT_API_URL: Final[str] = "https://apis.preprod.pasqal.cloud/account"
|
|
33
|
+
|
|
30
34
|
DEV_CORE_API_URL: Final[str] = "https://apis.dev.pasqal.cloud/core-fast"
|
|
31
35
|
|
|
36
|
+
DEV_ACCOUNT_API_URL: Final[str] = "https://apis.dev.pasqal.cloud/account"
|
|
37
|
+
|
|
32
38
|
|
|
33
39
|
@dataclass
|
|
34
40
|
class Endpoints:
|
|
35
41
|
core: str = CORE_API_URL
|
|
42
|
+
account: str = ACCOUNT_API_URL
|
|
36
43
|
|
|
37
44
|
|
|
38
45
|
# ---- Auth0 ----
|
|
@@ -65,9 +72,9 @@ class Auth0Conf:
|
|
|
65
72
|
|
|
66
73
|
|
|
67
74
|
PASQAL_ENDPOINTS = {
|
|
68
|
-
"prod": Endpoints(core=CORE_API_URL),
|
|
69
|
-
"preprod": Endpoints(core=PREPROD_CORE_API_URL),
|
|
70
|
-
"dev": Endpoints(core=DEV_CORE_API_URL),
|
|
75
|
+
"prod": Endpoints(core=CORE_API_URL, account=ACCOUNT_API_URL),
|
|
76
|
+
"preprod": Endpoints(core=PREPROD_CORE_API_URL, account=PREPROD_ACCOUNT_API_URL),
|
|
77
|
+
"dev": Endpoints(core=DEV_CORE_API_URL, account=DEV_ACCOUNT_API_URL),
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
AUTH0_CONFIG = {
|
|
@@ -236,3 +236,30 @@ class InvalidDeviceTypeSet(BaseException):
|
|
|
236
236
|
super().__init__(
|
|
237
237
|
"Only emulator or device_type can be set when creating a batch."
|
|
238
238
|
)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class ProjectException(ExceptionWithResponseContext):
|
|
242
|
+
"""
|
|
243
|
+
Base Exception class for projects
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class ProjectFetchingError(ProjectException):
|
|
248
|
+
"""
|
|
249
|
+
Exception class raised when project fetching failed.
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
def __init__(self, e: HTTPError) -> None:
|
|
253
|
+
super().__init__("Project fetching failed", e)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class ProjectNotFoundError(BaseException):
|
|
257
|
+
"""
|
|
258
|
+
Exception class raised when a Project doesn't
|
|
259
|
+
exist or the user isn't a member of it.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
def __init__(self, project_id: str) -> None:
|
|
263
|
+
super().__init__(
|
|
264
|
+
f"Project ID {project_id} does not exist or you are not a member of it."
|
|
265
|
+
)
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import re
|
|
3
|
+
from typing import Any, Callable, Optional
|
|
4
|
+
from uuid import uuid4
|
|
5
|
+
|
|
6
|
+
import requests_mock
|
|
7
|
+
|
|
8
|
+
from pasqal_cloud.endpoints import Endpoints
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BaseMockServer(abc.ABC):
|
|
12
|
+
"""
|
|
13
|
+
A mock server used as a replacement for the Pasqal HTTP server during testing.
|
|
14
|
+
|
|
15
|
+
Intended use:
|
|
16
|
+
```py
|
|
17
|
+
class MyMockServer(BaseMockServer):
|
|
18
|
+
# Override any endpoints.
|
|
19
|
+
def endpoint_post_batch(self, request: Any, context: Any) -> Any:
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
with MyMockServer():
|
|
23
|
+
client = Client()
|
|
24
|
+
# Perform usual operations on the client
|
|
25
|
+
```
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, endpoints: Optional[Endpoints] = None):
|
|
29
|
+
self.mocker = requests_mock.Mocker()
|
|
30
|
+
self.endpoints = endpoints
|
|
31
|
+
if self.endpoints is None:
|
|
32
|
+
self.endpoints = Endpoints()
|
|
33
|
+
|
|
34
|
+
re_path_variables = re.compile("{([a-z_]+)}")
|
|
35
|
+
|
|
36
|
+
# Install mocks for each endpoint.
|
|
37
|
+
for method, relative_url, impl in [
|
|
38
|
+
("POST", "/api/v1/batches", self.endpoint_post_batch),
|
|
39
|
+
("GET", "/api/v2/batches/{batch_id}", self.endpoint_get_batch),
|
|
40
|
+
(
|
|
41
|
+
"GET",
|
|
42
|
+
"/api/v1/jobs/{job_id}/results_link",
|
|
43
|
+
self.endpoint_get_job_results,
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
"PATCH",
|
|
47
|
+
"/api/v2/batches/{batch_id}/complete",
|
|
48
|
+
self.endpoint_patch_complete_batch,
|
|
49
|
+
),
|
|
50
|
+
(
|
|
51
|
+
"PATCH",
|
|
52
|
+
"/api/v2/batches/{batch_id}/cancel",
|
|
53
|
+
self.endpoint_patch_cancel_batch,
|
|
54
|
+
),
|
|
55
|
+
("PATCH", "/api/v2/batches/cancel", self.endpoint_patch_cancel_batches),
|
|
56
|
+
("POST", "/api/v1/batches/{batch_id}/rebatch", self.endpoint_post_rebatch),
|
|
57
|
+
("GET", "/api/v2/jobs", self.endpoint_get_jobs),
|
|
58
|
+
("PATCH", "/api/v2/jobs/{job_id}/cancel", self.endpoint_cancel_job),
|
|
59
|
+
(
|
|
60
|
+
"PATCH",
|
|
61
|
+
"/api/v2/batches/{batch_id}/cancel/jobs",
|
|
62
|
+
self.endpoint_cancel_jobs,
|
|
63
|
+
),
|
|
64
|
+
("POST", "/api/v1/workloads", self.endpoint_post_workload),
|
|
65
|
+
("GET", "/api/v2/workloads/{workload_id}", self.endpoint_get_workload),
|
|
66
|
+
(
|
|
67
|
+
"PUT",
|
|
68
|
+
"/api/v1/workloads/{workload_id}/cancel",
|
|
69
|
+
self.endpoint_put_cancel_workload,
|
|
70
|
+
),
|
|
71
|
+
("GET", "/api/v1/devices/specs", self.endpoint_get_devices_specs),
|
|
72
|
+
(
|
|
73
|
+
"GET",
|
|
74
|
+
"/api/v1/devices/public-specs",
|
|
75
|
+
self.endpoint_get_devices_public_specs,
|
|
76
|
+
),
|
|
77
|
+
]:
|
|
78
|
+
# Rewrite /foo/bar/{ga}/bu into /foo/bar/[^\]*/ga/bu.
|
|
79
|
+
rewritten_relative_url = re.sub(
|
|
80
|
+
pattern=re_path_variables,
|
|
81
|
+
repl=lambda m: f"(?P<{m.group(1)}>[^\\\\]*)",
|
|
82
|
+
string=relative_url,
|
|
83
|
+
)
|
|
84
|
+
escaped_full_url = re.escape(self.endpoints.core) + rewritten_relative_url
|
|
85
|
+
compiled_full_url = re.compile(escaped_full_url)
|
|
86
|
+
|
|
87
|
+
# Extract variables from path into `matches`.
|
|
88
|
+
def wrapper(
|
|
89
|
+
request: Any,
|
|
90
|
+
context: Any,
|
|
91
|
+
# Force capture from current loop iteration.
|
|
92
|
+
impl: Callable[[Any, Any, list[str]], Any] = impl,
|
|
93
|
+
compiled_full_url: re.Pattern[str] = compiled_full_url,
|
|
94
|
+
) -> Any:
|
|
95
|
+
matches: list[str] = compiled_full_url.findall(request.url)
|
|
96
|
+
return impl(request, context, matches)
|
|
97
|
+
|
|
98
|
+
self.mocker.request(method=method, url=compiled_full_url, json=wrapper)
|
|
99
|
+
self.mocker.request(
|
|
100
|
+
method="POST",
|
|
101
|
+
url="https://authenticate.pasqal.cloud/oauth/token",
|
|
102
|
+
json=self.endpoint_post_authenticate_token,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def __enter__(self) -> None:
|
|
106
|
+
self.mocker.__enter__()
|
|
107
|
+
|
|
108
|
+
def __exit__(self, type: Any, value: Any, traceback: Any) -> None:
|
|
109
|
+
self.mocker.__exit__(type, value, traceback)
|
|
110
|
+
|
|
111
|
+
def endpoint_post_authenticate_token(self, request: Any, context: Any) -> Any: # noqa: ARG002
|
|
112
|
+
"""
|
|
113
|
+
Mock for POST https://authenticate.pasqal.cloud/oauth/token
|
|
114
|
+
"""
|
|
115
|
+
token = "mock-token-" + str(uuid4())
|
|
116
|
+
return {
|
|
117
|
+
"expires-in": 100000000,
|
|
118
|
+
"access_token": token,
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
def endpoint_post_batch(
|
|
122
|
+
self, request: Any, context: Any, matches: list[str]
|
|
123
|
+
) -> Any:
|
|
124
|
+
"""
|
|
125
|
+
Mock for POST /api/v1/batches
|
|
126
|
+
|
|
127
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_all_batches_api_v1_batches_get/ .
|
|
128
|
+
""" # noqa: E501
|
|
129
|
+
raise NotImplementedError
|
|
130
|
+
|
|
131
|
+
def endpoint_get_batch(self, request: Any, context: Any, matches: list[str]) -> Any:
|
|
132
|
+
"""
|
|
133
|
+
Mock for GET /api/v1/batches/{batch_id}
|
|
134
|
+
|
|
135
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_batch_api_v2_batches__batch_id__get/ .
|
|
136
|
+
""" # noqa: E501
|
|
137
|
+
raise NotImplementedError
|
|
138
|
+
|
|
139
|
+
def endpoint_get_job_results(
|
|
140
|
+
self, request: Any, context: Any, matches: list[str]
|
|
141
|
+
) -> Any:
|
|
142
|
+
"""
|
|
143
|
+
Mock for GET /api/v1/jobs/{job_id}/results_link
|
|
144
|
+
|
|
145
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_job_results_link_api_v1_jobs__job_id__results_link_get/
|
|
146
|
+
"""
|
|
147
|
+
raise NotImplementedError
|
|
148
|
+
|
|
149
|
+
def endpoint_patch_complete_batch(
|
|
150
|
+
self, request: Any, context: Any, matches: list[str]
|
|
151
|
+
) -> Any:
|
|
152
|
+
"""
|
|
153
|
+
Mock for PATCH /api/v2/batches/{batch_id}/complete
|
|
154
|
+
|
|
155
|
+
See https://docs.pasqal.com/cloud/api/core/operations/complete_batch_api_v2_batches__batch__id__complete_patch/
|
|
156
|
+
"""
|
|
157
|
+
raise NotImplementedError
|
|
158
|
+
|
|
159
|
+
def endpoint_patch_cancel_batch(
|
|
160
|
+
self, request: Any, context: Any, matches: list[str]
|
|
161
|
+
) -> Any:
|
|
162
|
+
"""
|
|
163
|
+
Mock for PATCH /api/v2/batches/{batch_id}/cancel
|
|
164
|
+
|
|
165
|
+
See https://docs.pasqal.com/cloud/api/core/operations/cancel_batch_api_v2_batches__batch__id__cancel_patch/
|
|
166
|
+
"""
|
|
167
|
+
raise NotImplementedError
|
|
168
|
+
|
|
169
|
+
def endpoint_patch_cancel_batches(
|
|
170
|
+
self, request: Any, context: Any, matches: list[str]
|
|
171
|
+
) -> Any:
|
|
172
|
+
"""
|
|
173
|
+
Mock for PATCH /api/v2/batches/cancel
|
|
174
|
+
|
|
175
|
+
See https://docs.pasqal.com/cloud/api/core/operations/cancel_batches_api_v1_batches_cancel_patch
|
|
176
|
+
"""
|
|
177
|
+
raise NotImplementedError
|
|
178
|
+
|
|
179
|
+
def endpoint_post_rebatch(
|
|
180
|
+
self, request: Any, context: Any, matches: list[str]
|
|
181
|
+
) -> Any:
|
|
182
|
+
"""
|
|
183
|
+
Mock for POST /api/v2/batches/{batch_id}/rebatch
|
|
184
|
+
|
|
185
|
+
See https://docs.pasqal.com/cloud/api/core/operations/rebatch_jobs_api_v1_batches__batch__id__rebatch_post
|
|
186
|
+
"""
|
|
187
|
+
raise NotImplementedError
|
|
188
|
+
|
|
189
|
+
def endpoint_get_jobs(self, request: Any, context: Any, matches: list[str]) -> Any:
|
|
190
|
+
"""
|
|
191
|
+
Mock for GET /api/v2/jobs
|
|
192
|
+
|
|
193
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_jobs_api_v2_jobs_get
|
|
194
|
+
"""
|
|
195
|
+
raise NotImplementedError
|
|
196
|
+
|
|
197
|
+
def endpoint_get_batches(
|
|
198
|
+
self, request: Any, context: Any, matches: list[str]
|
|
199
|
+
) -> Any:
|
|
200
|
+
"""
|
|
201
|
+
Mock for GET /api/v1/batches
|
|
202
|
+
|
|
203
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_all_batches_api_v1_batches_get
|
|
204
|
+
"""
|
|
205
|
+
raise NotImplementedError
|
|
206
|
+
|
|
207
|
+
def endpoint_add_jobs(self, request: Any, context: Any, matches: list[str]) -> Any:
|
|
208
|
+
"""
|
|
209
|
+
Mock for POST /api/v2/batches/{batch_id}/jobs
|
|
210
|
+
|
|
211
|
+
See https://docs.pasqal.com/cloud/api/core/operations/add_jobs_api_v2_batches__batch__id__jobs_post
|
|
212
|
+
"""
|
|
213
|
+
raise NotImplementedError
|
|
214
|
+
|
|
215
|
+
def endpoint_cancel_job(
|
|
216
|
+
self, request: Any, context: Any, matches: list[str]
|
|
217
|
+
) -> Any:
|
|
218
|
+
"""
|
|
219
|
+
Mock for PATCH /api/v2/jobs/{job_id}/cancel
|
|
220
|
+
|
|
221
|
+
See https://docs.pasqal.com/cloud/api/core/operations/cancel_job_api_v2_jobs__job_id__cancel_patch
|
|
222
|
+
"""
|
|
223
|
+
raise NotImplementedError
|
|
224
|
+
|
|
225
|
+
def endpoint_cancel_jobs(
|
|
226
|
+
self, request: Any, context: Any, matches: list[str]
|
|
227
|
+
) -> Any:
|
|
228
|
+
"""
|
|
229
|
+
Mock for PATCH /api/v2/batches/{batch_id}/cancel/jobs
|
|
230
|
+
|
|
231
|
+
See https://docs.pasqal.com/cloud/api/core/operations/cancel_jobs_api_v2_batches__batch__id__cancel_jobs_patch
|
|
232
|
+
"""
|
|
233
|
+
raise NotImplementedError
|
|
234
|
+
|
|
235
|
+
def endpoint_post_workload(
|
|
236
|
+
self, request: Any, context: Any, matches: list[str]
|
|
237
|
+
) -> Any:
|
|
238
|
+
"""
|
|
239
|
+
Mock for POST /api/v1/workloads
|
|
240
|
+
|
|
241
|
+
See https://docs.pasqal.com/cloud/api/core/operations/create_workload_api_v1_workloads_post
|
|
242
|
+
"""
|
|
243
|
+
raise NotImplementedError
|
|
244
|
+
|
|
245
|
+
def endpoint_get_workload(
|
|
246
|
+
self, request: Any, context: Any, matches: list[str]
|
|
247
|
+
) -> Any:
|
|
248
|
+
"""
|
|
249
|
+
Mock for GET /api/v1/workloads/{workload_id}
|
|
250
|
+
|
|
251
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_workload_api_v2_workloads__workload_id__get
|
|
252
|
+
"""
|
|
253
|
+
raise NotImplementedError
|
|
254
|
+
|
|
255
|
+
def endpoint_put_cancel_workload(
|
|
256
|
+
self, request: Any, context: Any, matches: list[str]
|
|
257
|
+
) -> Any:
|
|
258
|
+
"""
|
|
259
|
+
Mock for PUT /api/v1/workloads/{workload_id}/cancel
|
|
260
|
+
|
|
261
|
+
See https://docs.pasqal.com/cloud/api/core/operations/cancel_workload_api_v1_workloads__workload_id__cancel_put
|
|
262
|
+
"""
|
|
263
|
+
raise NotImplementedError
|
|
264
|
+
|
|
265
|
+
def endpoint_get_devices_specs(
|
|
266
|
+
self, request: Any, context: Any, matches: list[str]
|
|
267
|
+
) -> Any:
|
|
268
|
+
"""
|
|
269
|
+
Mock for GET /api/v1/devices/specs
|
|
270
|
+
|
|
271
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_all_devices_api_v1_devices_get
|
|
272
|
+
"""
|
|
273
|
+
raise NotImplementedError
|
|
274
|
+
|
|
275
|
+
def endpoint_get_devices_public_specs(
|
|
276
|
+
self, request: Any, context: Any, matches: list[str]
|
|
277
|
+
) -> Any:
|
|
278
|
+
"""
|
|
279
|
+
Mock for GET /api/v1/devices/public-specs
|
|
280
|
+
|
|
281
|
+
See https://docs.pasqal.com/cloud/api/core/operations/get_public_device_specs_api_v1_devices_public_specs_get
|
|
282
|
+
"""
|
|
283
|
+
raise NotImplementedError
|
|
284
|
+
|
|
285
|
+
def endpoint_patch_batch_tags(
|
|
286
|
+
self, request: Any, context: Any, matches: list[str]
|
|
287
|
+
) -> Any:
|
|
288
|
+
"""
|
|
289
|
+
Mock for PATCH /api/v1/batches/{batch_id}/tags
|
|
290
|
+
|
|
291
|
+
See https://docs.pasqal.com/cloud/api/core/operations/set_batch_tags_api_v1_batches__batch_id__tags_patch
|
|
292
|
+
"""
|
|
293
|
+
raise NotImplementedError
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pasqal-cloud
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.6
|
|
4
4
|
Summary: Software development kit for Pasqal cloud platform.
|
|
5
5
|
Home-page: https://github.com/pasqal-io/pasqal-cloud
|
|
6
6
|
Maintainer: Pasqal Cloud Services
|
|
@@ -15,18 +15,18 @@ Requires-Dist: auth0-python<4.0.0,>=3.23.1
|
|
|
15
15
|
Requires-Dist: requests<3.0.0,>=2.25.1
|
|
16
16
|
Requires-Dist: pyjwt[crypto]<3.0.0,>=2.5.0
|
|
17
17
|
Requires-Dist: pydantic<3.0.0,>=2.6.0
|
|
18
|
+
Requires-Dist: requests-mock==1.12.1
|
|
18
19
|
Provides-Extra: dev
|
|
19
|
-
Requires-Dist: types-requests==2.31.0.1; extra == "dev"
|
|
20
|
-
Requires-Dist: ruff==0.6.9; extra == "dev"
|
|
21
20
|
Requires-Dist: mypy==1.10.0; extra == "dev"
|
|
21
|
+
Requires-Dist: types-requests==2.31.0.1; extra == "dev"
|
|
22
22
|
Requires-Dist: pytest-cov==5.0.0; extra == "dev"
|
|
23
23
|
Requires-Dist: pytest==8.1.1; extra == "dev"
|
|
24
|
-
Requires-Dist:
|
|
24
|
+
Requires-Dist: ruff==0.6.9; extra == "dev"
|
|
25
25
|
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
|
|
26
27
|
Requires-Dist: mkdocstrings-python==1.13.0; extra == "docs"
|
|
27
28
|
Requires-Dist: mkdocs==1.6.1; extra == "docs"
|
|
28
29
|
Requires-Dist: mkdocs-material==9.5.50; extra == "docs"
|
|
29
|
-
Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
|
|
30
30
|
Dynamic: classifier
|
|
31
31
|
Dynamic: description
|
|
32
32
|
Dynamic: description-content-type
|
|
@@ -346,6 +346,12 @@ sdk.get_device_specs_dict()
|
|
|
346
346
|
The method returns a dict object mapping a device type to a serialized device specs. These specs can be used
|
|
347
347
|
to instantiate a `Device` instance in the `Pulser` library.
|
|
348
348
|
|
|
349
|
+
### Use the pasqal-cloud SDK behind a proxy
|
|
350
|
+
|
|
351
|
+
The pasqal-cloud SDK uses the [`requests` library](https://requests.readthedocs.io/en/latest/) to make HTTP calls to Pasqal's cloud APIs.
|
|
352
|
+
|
|
353
|
+
Please refer to the [requests documentation](https://requests.readthedocs.io/en/latest/user/advanced/#proxies) to use the SDK behind a proxy. Be sure to set the HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY environment variables to route traffic through your proxy. If your proxy uses a self-signed certificate, the certificate authority must be included in your CA bundle. One way to do it is to set the environment variable REQUESTS_CA_BUNDLE to the path of the file containing the certificate authority.
|
|
354
|
+
|
|
349
355
|
### Target different API endpoints
|
|
350
356
|
|
|
351
357
|
This is intended for the package developers or users which were given access to non-prod
|
|
@@ -12,6 +12,7 @@ pasqal_cloud/client.py
|
|
|
12
12
|
pasqal_cloud/endpoints.py
|
|
13
13
|
pasqal_cloud/errors.py
|
|
14
14
|
pasqal_cloud/job.py
|
|
15
|
+
pasqal_cloud/project.py
|
|
15
16
|
pasqal_cloud/py.typed
|
|
16
17
|
pasqal_cloud/workload.py
|
|
17
18
|
pasqal_cloud.egg-info/PKG-INFO
|
|
@@ -32,6 +33,7 @@ pasqal_cloud/utils/__init__.py
|
|
|
32
33
|
pasqal_cloud/utils/constants.py
|
|
33
34
|
pasqal_cloud/utils/filters.py
|
|
34
35
|
pasqal_cloud/utils/jsend.py
|
|
36
|
+
pasqal_cloud/utils/mock_server.py
|
|
35
37
|
pasqal_cloud/utils/responses.py
|
|
36
38
|
pasqal_cloud/utils/retry.py
|
|
37
39
|
pasqal_cloud/utils/strenum.py
|
|
@@ -68,6 +68,7 @@ setup(
|
|
|
68
68
|
"requests>=2.25.1, <3.0.0",
|
|
69
69
|
"pyjwt[crypto]>=2.5.0, <3.0.0",
|
|
70
70
|
"pydantic >= 2.6.0, <3.0.0",
|
|
71
|
+
"requests-mock==1.12.1",
|
|
71
72
|
],
|
|
72
73
|
extras_require={
|
|
73
74
|
"dev": {
|
|
@@ -76,7 +77,6 @@ setup(
|
|
|
76
77
|
"pytest==8.1.1",
|
|
77
78
|
"pytest-cov==5.0.0",
|
|
78
79
|
"types-requests==2.31.0.1",
|
|
79
|
-
"requests-mock==1.12.1",
|
|
80
80
|
},
|
|
81
81
|
"docs": {
|
|
82
82
|
"mkdocs==1.6.1",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/__init__.py
RENAMED
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/base_config.py
RENAMED
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_free.py
RENAMED
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_fresnel.py
RENAMED
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/emu_tn.py
RENAMED
|
File without changes
|
{pasqal_cloud-0.20.4.dev0 → pasqal_cloud-0.20.6}/pasqal_cloud/device/configuration/result_type.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,17 +2,17 @@ auth0-python<4.0.0,>=3.23.1
|
|
|
2
2
|
requests<3.0.0,>=2.25.1
|
|
3
3
|
pyjwt[crypto]<3.0.0,>=2.5.0
|
|
4
4
|
pydantic<3.0.0,>=2.6.0
|
|
5
|
+
requests-mock==1.12.1
|
|
5
6
|
|
|
6
7
|
[dev]
|
|
7
|
-
types-requests==2.31.0.1
|
|
8
|
-
ruff==0.6.9
|
|
9
8
|
mypy==1.10.0
|
|
9
|
+
types-requests==2.31.0.1
|
|
10
10
|
pytest-cov==5.0.0
|
|
11
11
|
pytest==8.1.1
|
|
12
|
-
|
|
12
|
+
ruff==0.6.9
|
|
13
13
|
|
|
14
14
|
[docs]
|
|
15
|
+
mkdocstrings==0.27.0
|
|
15
16
|
mkdocstrings-python==1.13.0
|
|
16
17
|
mkdocs==1.6.1
|
|
17
18
|
mkdocs-material==9.5.50
|
|
18
|
-
mkdocstrings==0.27.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|