pasqal-cloud 0.20.2__tar.gz → 0.20.4.dev0__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.
Files changed (39) hide show
  1. {pasqal_cloud-0.20.2/pasqal_cloud.egg-info → pasqal_cloud-0.20.4.dev0}/PKG-INFO +12 -29
  2. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/README.md +6 -24
  3. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/__init__.py +82 -20
  4. pasqal_cloud-0.20.4.dev0/pasqal_cloud/_version.py +2 -0
  5. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/authentication.py +32 -2
  6. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/batch.py +37 -19
  7. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/client.py +50 -11
  8. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/__init__.py +2 -0
  9. pasqal_cloud-0.20.2/pasqal_cloud/device/emulator_types.py → pasqal_cloud-0.20.4.dev0/pasqal_cloud/device/device_types.py +2 -1
  10. pasqal_cloud-0.20.4.dev0/pasqal_cloud/device/emulator_types.py +13 -0
  11. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/errors.py +21 -0
  12. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/filters.py +2 -0
  13. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/retry.py +4 -4
  14. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/workload.py +2 -2
  15. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0/pasqal_cloud.egg-info}/PKG-INFO +12 -29
  16. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud.egg-info/SOURCES.txt +1 -0
  17. pasqal_cloud-0.20.2/pasqal_cloud/_version.py +0 -2
  18. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/LICENSE +0 -0
  19. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/MANIFEST.in +0 -0
  20. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/__init__.py +0 -0
  21. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/base_config.py +0 -0
  22. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/emu_free.py +0 -0
  23. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/emu_fresnel.py +0 -0
  24. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/emu_tn.py +0 -0
  25. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/device/configuration/result_type.py +0 -0
  26. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/endpoints.py +0 -0
  27. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/job.py +0 -0
  28. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/py.typed +0 -0
  29. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/__init__.py +0 -0
  30. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/constants.py +0 -0
  31. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/jsend.py +0 -0
  32. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/responses.py +0 -0
  33. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud/utils/strenum.py +0 -0
  34. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud.egg-info/dependency_links.txt +0 -0
  35. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud.egg-info/requires.txt +3 -3
  36. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pasqal_cloud.egg-info/top_level.txt +0 -0
  37. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/pyproject.toml +0 -0
  38. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/setup.cfg +0 -0
  39. {pasqal_cloud-0.20.2 → pasqal_cloud-0.20.4.dev0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: pasqal-cloud
3
- Version: 0.20.2
3
+ Version: 0.20.4.dev0
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
@@ -16,22 +16,23 @@ 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
18
  Provides-Extra: dev
19
- Requires-Dist: pytest-cov==5.0.0; extra == "dev"
20
19
  Requires-Dist: types-requests==2.31.0.1; extra == "dev"
21
20
  Requires-Dist: ruff==0.6.9; extra == "dev"
22
21
  Requires-Dist: mypy==1.10.0; extra == "dev"
22
+ Requires-Dist: pytest-cov==5.0.0; extra == "dev"
23
23
  Requires-Dist: pytest==8.1.1; extra == "dev"
24
24
  Requires-Dist: requests-mock==1.12.1; extra == "dev"
25
25
  Provides-Extra: docs
26
- Requires-Dist: mkdocs-material==9.5.50; extra == "docs"
27
26
  Requires-Dist: mkdocstrings-python==1.13.0; extra == "docs"
28
- Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
29
27
  Requires-Dist: mkdocs==1.6.1; extra == "docs"
28
+ 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
33
33
  Dynamic: home-page
34
34
  Dynamic: license
35
+ Dynamic: license-file
35
36
  Dynamic: maintainer
36
37
  Dynamic: maintainer-email
37
38
  Dynamic: provides-extra
@@ -41,25 +42,7 @@ Dynamic: summary
41
42
 
42
43
  # PASQAL Cloud
43
44
 
44
- SDK to be used to access Pasqal Cloud Services.
45
-
46
- ## Version Support & Deprecation Timeline
47
-
48
- | Version | Release Date | End of Support |
49
- | ------- | ------------ | -------------- |
50
- | 0.5.0 | 2024-02-05 | 2025-02-05 |
51
- | 0.6.0 | 2024-02-26 | 2025-02-26 |
52
- | 0.7.0 | 2024-03-05 | 2025-03-05 |
53
- | 0.8.0 | 2024-04-15 | 2025-04-15 |
54
- | 0.9.0 | 2024-05-15 | 2025-05-15 |
55
- | 0.10.0 | 2024-06-05 | 2025-06-05 |
56
- | 0.11.0 | 2024-06-27 | 2025-06-27 |
57
- | 0.12.0 | 2024-09-03 | 2025-09-03 |
58
- | 0.12.1 | 2024-09-11 | 2025-09-11 |
59
- | 0.12.2 | 2024-09-11 | 2025-09-11 |
60
- | 0.12.3 | 2024-10-02 | 2025-10-02 |
61
- | 0.12.4 | 2024-10-09 | 2025-10-09 |
62
- | 0.20.2 | 2024-11-26 | 2025-11-26 |
45
+ SDK to access Pasqal Cloud Services.
63
46
 
64
47
  ## Installation
65
48
 
@@ -156,7 +139,7 @@ to the next statement.
156
139
 
157
140
  ```python
158
141
  # Create a closed batch with 2 jobs and wait for its termination
159
- batch = sdk.create_batch(serialized_sequence, [job1, job2], wait=True)
142
+ batch = sdk.create_batch(serialized_sequence, [job1, job2], device_type=DeviceTypeName.FRESNEL, wait=True)
160
143
  ```
161
144
 
162
145
  To create an open batch, set the `open` argument to `True`, you can then add jobs to your batch.
@@ -164,7 +147,7 @@ Don't forget to mark your batch as closed when you are done adding new jobs to i
164
147
 
165
148
  ```python
166
149
  # Create an open batch with 1 job
167
- batch = sdk.create_batch(serialized_sequence, [job1], open=True)
150
+ batch = sdk.create_batch(serialized_sequence, [job1], open=True, device_type=DeviceTypeName.FRESNEL)
168
151
  # Add some jobs to it and wait for the jobs to be terminated
169
152
  job3 = {"runs": 50, "variables": {"omega_max": 10.5}}
170
153
  batch.add_jobs([job2, job3], wait=True)
@@ -173,14 +156,14 @@ batch.add_jobs([job2, job3], wait=True)
173
156
  batch.close()
174
157
  ```
175
158
 
176
- You can also choose to run your batch on an emulator using the optional argument `emulator`.
159
+ You should choose the device on which to run the batch with the parameter `device_type`.
177
160
  For using a basic single-threaded QPU emulator that can go up to 10 qubits, you can specify the "EMU_FREE" emulator:
178
161
 
179
162
  ```python
180
- from pasqal_cloud.device import EmulatorType
163
+ from pasqal_cloud.device import DeviceTypeName
181
164
 
182
165
  batch = sdk.create_batch(
183
- serialized_sequence, [job1, job2], emulator=EmulatorType.EMU_FREE
166
+ serialized_sequence, [job1, job2], device_type=DeviceTypeName.EMU_FREE
184
167
  )
185
168
  ```
186
169
 
@@ -1,24 +1,6 @@
1
1
  # PASQAL Cloud
2
2
 
3
- SDK to be used to access Pasqal Cloud Services.
4
-
5
- ## Version Support & Deprecation Timeline
6
-
7
- | Version | Release Date | End of Support |
8
- | ------- | ------------ | -------------- |
9
- | 0.5.0 | 2024-02-05 | 2025-02-05 |
10
- | 0.6.0 | 2024-02-26 | 2025-02-26 |
11
- | 0.7.0 | 2024-03-05 | 2025-03-05 |
12
- | 0.8.0 | 2024-04-15 | 2025-04-15 |
13
- | 0.9.0 | 2024-05-15 | 2025-05-15 |
14
- | 0.10.0 | 2024-06-05 | 2025-06-05 |
15
- | 0.11.0 | 2024-06-27 | 2025-06-27 |
16
- | 0.12.0 | 2024-09-03 | 2025-09-03 |
17
- | 0.12.1 | 2024-09-11 | 2025-09-11 |
18
- | 0.12.2 | 2024-09-11 | 2025-09-11 |
19
- | 0.12.3 | 2024-10-02 | 2025-10-02 |
20
- | 0.12.4 | 2024-10-09 | 2025-10-09 |
21
- | 0.20.2 | 2024-11-26 | 2025-11-26 |
3
+ SDK to access Pasqal Cloud Services.
22
4
 
23
5
  ## Installation
24
6
 
@@ -115,7 +97,7 @@ to the next statement.
115
97
 
116
98
  ```python
117
99
  # Create a closed batch with 2 jobs and wait for its termination
118
- batch = sdk.create_batch(serialized_sequence, [job1, job2], wait=True)
100
+ batch = sdk.create_batch(serialized_sequence, [job1, job2], device_type=DeviceTypeName.FRESNEL, wait=True)
119
101
  ```
120
102
 
121
103
  To create an open batch, set the `open` argument to `True`, you can then add jobs to your batch.
@@ -123,7 +105,7 @@ Don't forget to mark your batch as closed when you are done adding new jobs to i
123
105
 
124
106
  ```python
125
107
  # Create an open batch with 1 job
126
- batch = sdk.create_batch(serialized_sequence, [job1], open=True)
108
+ batch = sdk.create_batch(serialized_sequence, [job1], open=True, device_type=DeviceTypeName.FRESNEL)
127
109
  # Add some jobs to it and wait for the jobs to be terminated
128
110
  job3 = {"runs": 50, "variables": {"omega_max": 10.5}}
129
111
  batch.add_jobs([job2, job3], wait=True)
@@ -132,14 +114,14 @@ batch.add_jobs([job2, job3], wait=True)
132
114
  batch.close()
133
115
  ```
134
116
 
135
- You can also choose to run your batch on an emulator using the optional argument `emulator`.
117
+ You should choose the device on which to run the batch with the parameter `device_type`.
136
118
  For using a basic single-threaded QPU emulator that can go up to 10 qubits, you can specify the "EMU_FREE" emulator:
137
119
 
138
120
  ```python
139
- from pasqal_cloud.device import EmulatorType
121
+ from pasqal_cloud.device import DeviceTypeName
140
122
 
141
123
  batch = sdk.create_batch(
142
- serialized_sequence, [job1, job2], emulator=EmulatorType.EMU_FREE
124
+ serialized_sequence, [job1, job2], device_type=DeviceTypeName.EMU_FREE
143
125
  )
144
126
  ```
145
127
 
@@ -23,6 +23,7 @@ from pasqal_cloud.authentication import TokenProvider
23
23
  from pasqal_cloud.batch import Batch, RESULT_POLLING_INTERVAL
24
24
  from pasqal_cloud.client import Client
25
25
  from pasqal_cloud.device import BaseConfig as BaseConfig
26
+ from pasqal_cloud.device import DeviceTypeName as DeviceTypeName
26
27
  from pasqal_cloud.device import EmulatorType as EmulatorType
27
28
  from pasqal_cloud.endpoints import (
28
29
  AUTH0_CONFIG, # noqa: F401
@@ -37,7 +38,9 @@ from pasqal_cloud.errors import (
37
38
  BatchClosingError,
38
39
  BatchCreationError,
39
40
  BatchFetchingError,
41
+ BatchSetTagsError,
40
42
  DeviceSpecsFetchingError,
43
+ InvalidDeviceTypeSet,
41
44
  JobCancellingError,
42
45
  JobCreationError,
43
46
  JobFetchingError,
@@ -159,7 +162,6 @@ class SDK:
159
162
  def user_token(self) -> Union[str, None]:
160
163
  return self._client.user_token()
161
164
 
162
-
163
165
  def _get_batch(
164
166
  self,
165
167
  id: str,
@@ -169,6 +171,44 @@ class SDK:
169
171
  except HTTPError as e:
170
172
  raise BatchFetchingError(e) from e
171
173
 
174
+ def _validate_device_type(
175
+ self,
176
+ emulator: Optional[EmulatorType],
177
+ device_type: Optional[DeviceTypeName],
178
+ ) -> DeviceTypeName:
179
+ if emulator is not None and device_type is not None:
180
+ raise InvalidDeviceTypeSet
181
+ if emulator is not None:
182
+ warn(
183
+ "Argument `emulator` is deprecated and will be removed in a"
184
+ " future version. Please use argument `device_type` instead.",
185
+ DeprecationWarning,
186
+ stacklevel=2,
187
+ )
188
+ return DeviceTypeName(str(emulator))
189
+ if emulator is None and device_type is None:
190
+ return DeviceTypeName.FRESNEL
191
+ return device_type
192
+
193
+ def _validate_open(
194
+ self,
195
+ complete: Optional[bool],
196
+ open: Optional[bool],
197
+ ) -> bool:
198
+ if complete is not None and open is not None:
199
+ raise OnlyCompleteOrOpenCanBeSet
200
+ if complete is not None:
201
+ warn(
202
+ "Argument `complete` is deprecated and will be removed in a"
203
+ " future version. Please use argument `open` instead.",
204
+ DeprecationWarning,
205
+ stacklevel=2,
206
+ )
207
+ return not complete
208
+ if complete is None and open is None:
209
+ return False
210
+ return open
211
+
172
212
  def create_batch(
173
213
  self,
174
214
  serialized_sequence: str,
@@ -176,9 +216,12 @@ class SDK:
176
216
  complete: Optional[bool] = None,
177
217
  open: Optional[bool] = None,
178
218
  emulator: Optional[EmulatorType] = None,
219
+ device_type: Optional[DeviceTypeName] = None,
179
220
  configuration: Optional[BaseConfig] = None,
221
+ backend_configuration: Optional[str] = None,
180
222
  wait: bool = False,
181
223
  fetch_results: bool = False,
224
+ tags: Optional[list[str]] = None,
182
225
  ) -> Batch:
183
226
  """Create a new batch and send it to the API.
184
227
 
@@ -200,7 +243,7 @@ class SDK:
200
243
  terminated
201
244
  fetch_results (deprecated): Whether to wait for the batch to
202
245
  be done and fetch results
203
-
246
+ tags: List of keywords that can be used to refine the Batch search
204
247
 
205
248
  Returns:
206
249
  Batch: The new batch that has been created in the database.
@@ -209,18 +252,9 @@ class SDK:
209
252
  BatchCreationError: If batch creation failed
210
253
  BatchFetchingError: If batch fetching failed
211
254
  """
212
- if complete is not None and open is not None:
213
- raise OnlyCompleteOrOpenCanBeSet
214
- if complete is not None:
215
- warn(
216
- "Argument `complete` is deprecated and will be removed in a"
217
- " future version. Please use argument `open` instead.",
218
- DeprecationWarning,
219
- stacklevel=2,
220
- )
221
- open = not complete
222
- elif complete is None and open is None:
223
- open = False
255
+ device_type = self._validate_device_type(emulator, device_type)
256
+ open = self._validate_open(complete, open)
257
+
224
258
  if fetch_results:
225
259
  warn(
226
260
  "Argument `fetch_results` is deprecated and will be removed in a"
@@ -235,18 +269,21 @@ class SDK:
235
269
  "webhook": self.webhook,
236
270
  "jobs": jobs,
237
271
  "open": open,
272
+ "device_type": device_type,
238
273
  }
239
-
240
- # the emulator field is only added in the case
241
- # an emulator job is requested otherwise it's left empty
242
- if emulator:
243
- req.update({"emulator": emulator})
244
-
245
274
  # The configuration field is only added in the case
246
275
  # it's requested
247
276
  if configuration:
248
277
  req.update({"configuration": configuration.to_dict()}) # type: ignore[dict-item]
249
278
 
279
+ if tags:
280
+ req.update({"tags": tags}) # type: ignore[dict-item]
281
+
282
+ # The backend_configuration is only added if
283
+ # a value is provided
284
+ if backend_configuration:
285
+ req.update({"backend_configuration": backend_configuration})
286
+
250
287
  try:
251
288
  batch_rsp = self._client.send_batch(req)
252
289
  except HTTPError as e:
@@ -747,3 +784,28 @@ class SDK:
747
784
  return self._client.get_device_specs_dict()
748
785
  except HTTPError as e:
749
786
  raise DeviceSpecsFetchingError(e) from e
787
+
788
+ def set_batch_tags(
789
+ self,
790
+ batch_id: str,
791
+ tags: list[str],
792
+ ) -> Batch:
793
+ """Set tags to an existing batch, overwriting previous ones already set.
794
+
795
+ Args:
796
+ batch_id: Batch id.
797
+ tags: the tags defining the batch
798
+
799
+ Returns:
800
+ batch: The updated batch with newly set tags.
801
+
802
+ Raises:
803
+ BatchSetTagsError: If setting tags to a batch failed.
804
+ """
805
+
806
+ try:
807
+ resp = self._client.set_batch_tags(batch_id, tags)
808
+ except HTTPError as e:
809
+ raise BatchSetTagsError(e)
810
+
811
+ return Batch(**resp, _client=self._client)
@@ -0,0 +1,2 @@
1
+ __version__ = '0.20.4.dev0'
2
+ deprecation_date = '2026-07-04'
@@ -4,6 +4,7 @@ from abc import ABC, abstractmethod
4
4
  from datetime import datetime, timedelta, timezone
5
5
  from typing import Any, Optional
6
6
 
7
+ import requests
7
8
  from auth0.v3.authentication import GetToken # type: ignore[import-untyped]
8
9
  from jwt import decode, DecodeError
9
10
  from requests import PreparedRequest
@@ -116,6 +117,10 @@ class ExpiringTokenProvider(TokenProvider, ABC):
116
117
  return None
117
118
 
118
119
 
120
+ AUTH0_TOKEN_PROVIDER_SCOPE = "openid profile email"
121
+ AUTH0_TOKEN_PROVIDER_GRANT_TYPE = "http://auth0.com/oauth/grant-type/password-realm"
122
+
123
+
119
124
  class Auth0TokenProvider(ExpiringTokenProvider):
120
125
  """ExpiringTokenProvider implementation which fetches a token from auth0."""
121
126
 
@@ -146,8 +151,33 @@ class Auth0TokenProvider(ExpiringTokenProvider):
146
151
  username=self.username,
147
152
  password=self.password,
148
153
  audience=self.auth0.audience,
149
- scope="openid profile email",
154
+ scope=AUTH0_TOKEN_PROVIDER_SCOPE,
150
155
  realm=self.auth0.realm,
151
- grant_type="http://auth0.com/oauth/grant-type/password-realm",
156
+ grant_type=AUTH0_TOKEN_PROVIDER_GRANT_TYPE,
152
157
  )
153
158
  return validated_token
159
+
160
+
161
+ class InsecureAuth0TokenProvider(Auth0TokenProvider):
162
+ """Token Provider for auth0 with SSL verification disabled
163
+
164
+ Should be only used in testing environments.
165
+ """
166
+
167
+ def _query_token(self) -> Any:
168
+ response = requests.post(
169
+ "https://{}/oauth/token".format(self.auth0.domain),
170
+ data={
171
+ "client_id": self.auth0.public_client_id,
172
+ "username": self.username,
173
+ "password": self.password,
174
+ "realm": self.auth0.realm,
175
+ "client_secret": "",
176
+ "scope": AUTH0_TOKEN_PROVIDER_SCOPE,
177
+ "audience": self.auth0.audience,
178
+ "grant_type": AUTH0_TOKEN_PROVIDER_GRANT_TYPE,
179
+ },
180
+ verify=False,
181
+ )
182
+ response.raise_for_status()
183
+ return response.json()
@@ -6,7 +6,7 @@ from pydantic import BaseModel, ConfigDict, field_validator, PrivateAttr, Valida
6
6
  from requests import HTTPError
7
7
 
8
8
  from pasqal_cloud.client import Client
9
- from pasqal_cloud.device import EmulatorType
9
+ from pasqal_cloud.device import DeviceTypeName
10
10
  from pasqal_cloud.device.configuration import (
11
11
  BaseConfig,
12
12
  EmuFreeConfig,
@@ -16,6 +16,7 @@ from pasqal_cloud.errors import (
16
16
  BatchCancellingError,
17
17
  BatchClosingError,
18
18
  BatchFetchingError,
19
+ BatchSetTagsError,
19
20
  JobCreationError,
20
21
  JobRetryError,
21
22
  )
@@ -27,9 +28,10 @@ RESULT_POLLING_INTERVAL = 2 # seconds
27
28
  class Batch(BaseModel):
28
29
  """Class to load batch data return by the API.
29
30
 
30
- A batch groups up several jobs with the same sequence. When a batch is assigned to
31
- a QPU, all its jobs are run sequentially and no other batch can be assigned to the
32
- device until all its jobs are done and declared complete.
31
+ A batch groups up several jobs with the same sequence. When
32
+ a batch is assigned to a QPU, all its jobs are run sequentially
33
+ and no other batch can be assigned to the device until all its
34
+ jobs are done and declared complete.
33
35
 
34
36
  Attributes:
35
37
  open: Whether the batch accepts more jobs or not.
@@ -42,18 +44,24 @@ class Batch(BaseModel):
42
44
  user_id: Unique identifier of the user that created the batch.
43
45
  status: Status of the batch. Possible values are:
44
46
  PENDING, RUNNING, DONE, CANCELED, TIMED_OUT, ERROR, PAUSED.
45
- webhook: Webhook where the job results are automatically sent to.
46
47
  _client: A Client instance to connect to PCS.
47
- sequence_builder: Pulser sequence of the batch.
48
- start_datetime: Timestamp of the time the batch was sent to the QPU.
49
- end_datetime: Timestamp of when the batch process was finished.
50
- device_status: Status of the device where the batch is running.
51
- jobs (deprecated): Dictionary of all the jobs added to the batch.
52
48
  ordered_jobs: List of all the jobs added to the batch,
53
49
  ordered by creation time.
54
50
  jobs_count: Number of jobs added to the batch.
55
51
  jobs_count_per_status: Number of jobs per status.
52
+ webhook: Webhook where the job results are automatically sent to.
53
+ start_datetime: Timestamp of the time the batch was sent to the QPU.
54
+ end_datetime: Timestamp of when the batch process was finished.
55
+ device_status: Status of the device where the batch is running.
56
+ parent_id: ID from previous batch if a batch was resubmitted for execution.
56
57
  configuration: Further configuration for certain emulators.
58
+ backend_configuration: serialised config object for emulation runtimes. This is
59
+ a configuration from the pulser library that can be used on certain
60
+ backend emulator types. It must be in the form of an
61
+ abstract representation/encoded string.
62
+ tags: Keyword used to refine the batch search.
63
+ jobs (deprecated): Dictionary of all the jobs added to the batch.
64
+ sequence_builder: Pulser sequence of the batch.
57
65
  """
58
66
 
59
67
  open: bool
@@ -75,6 +83,9 @@ class Batch(BaseModel):
75
83
  device_status: Optional[str] = None
76
84
  parent_id: Optional[str] = None
77
85
  configuration: Union[BaseConfig, Dict[str, Any], None] = None
86
+ backend_configuration: Optional[str] = None
87
+ _sequence_builder: Optional[str] = None
88
+ tags: Optional[list[str]] = None
78
89
 
79
90
  model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
80
91
 
@@ -93,13 +104,9 @@ class Batch(BaseModel):
93
104
  def sequence_builder(self) -> Optional[str]:
94
105
  if self._sequence_builder is None:
95
106
  batch_response = self._client.get_batch(self.id)
96
- self.sequence_builder = batch_response["sequence_builder"]
107
+ self._sequence_builder = batch_response["sequence_builder"]
97
108
  return self._sequence_builder
98
109
 
99
- @sequence_builder.setter
100
- def sequence_builder(self, value: Any) -> None:
101
- self._sequence_builder = value
102
-
103
110
  @property
104
111
  def ordered_jobs(self) -> List[Job]:
105
112
  if self._ordered_jobs is None:
@@ -141,13 +148,13 @@ class Batch(BaseModel):
141
148
  if not isinstance(configuration, dict):
142
149
  return configuration
143
150
  conf_class: Type[BaseConfig] = BaseConfig
144
- if info.data["device_type"] == EmulatorType.EMU_TN.value:
151
+ if info.data["device_type"] == DeviceTypeName.EMU_TN:
145
152
  conf_class = EmuTNConfig
146
- elif info.data["device_type"] == EmulatorType.EMU_FREE.value:
153
+ elif info.data["device_type"] == DeviceTypeName.EMU_FREE:
147
154
  conf_class = EmuFreeConfig
148
155
  elif info.data["device_type"] in {
149
- EmulatorType.EMU_FRESNEL.value,
150
- EmulatorType.EMU_MPS.value,
156
+ DeviceTypeName.EMU_FRESNEL.value,
157
+ DeviceTypeName.EMU_MPS.value,
151
158
  }:
152
159
  return None
153
160
  return conf_class.from_dict(configuration)
@@ -261,3 +268,14 @@ class Batch(BaseModel):
261
268
  for field in batch_model_fields:
262
269
  value = getattr(updated_batch, field)
263
270
  setattr(self, field, value)
271
+
272
+ def set_tags(
273
+ self,
274
+ tags: list[str],
275
+ ) -> None:
276
+ """Set tags for the current batch, overwriting previous ones already set"""
277
+ try:
278
+ batch_rsp = self._client.set_batch_tags(self.id, tags)
279
+ except HTTPError as e:
280
+ raise BatchSetTagsError(e) from e
281
+ return self._update_from_api_response(batch_rsp)
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  from __future__ import annotations
15
15
 
16
+ import os
16
17
  from getpass import getpass
17
18
  from typing import Any, Dict, List, Mapping, Optional, Sequence, Union
18
19
  from uuid import UUID
@@ -40,6 +41,11 @@ from pasqal_cloud.utils.retry import retry_http_error
40
41
  TIMEOUT = 30 # client http requests timeout after 30s
41
42
 
42
43
 
44
+ # Env variable to disable SSL verification. Should be used only in testing environement
45
+ def _skip_ssl_verify() -> bool:
46
+ return bool(os.getenv("PASQAL_SKIP_SSL_VERIFY", False))
47
+
48
+
43
49
  class EmptyFilter:
44
50
  pass
45
51
 
@@ -71,6 +77,9 @@ class Client:
71
77
  if token_provider:
72
78
  self.authenticator = HTTPBearerAuthenticator(token_provider)
73
79
 
80
+ self.session = requests.Session()
81
+ self.session.verify = not _skip_ssl_verify()
82
+
74
83
  def user_token(self) -> Union[str, None]:
75
84
  return (
76
85
  self.authenticator.token_provider.get_token() # type: ignore[attr-defined]
@@ -126,12 +135,16 @@ class Client:
126
135
  token_provider: TokenProvider = Auth0TokenProvider(username, password, auth0)
127
136
  return token_provider
128
137
 
129
- @retry_http_error(max_retries=5, retry_status_code={408, 425, 429, 500, 502, 504})
138
+ def _request_with_status_check(self, *args: Any, **kwargs: Any): # type: ignore
139
+ resp = self.session.request(*args, **kwargs)
140
+ resp.raise_for_status()
141
+ return resp
142
+
130
143
  def _authenticated_request(
131
144
  self,
132
145
  method: str,
133
146
  url: str,
134
- payload: Optional[Union[Mapping, Sequence[Mapping]]] = None,
147
+ payload: Optional[Union[Mapping, Sequence[Mapping], Sequence[str]]] = None,
135
148
  params: Optional[Mapping[str, Any]] = None,
136
149
  ) -> JSendPayload:
137
150
  if self.authenticator is None:
@@ -140,19 +153,32 @@ class Client:
140
153
  " initializing the client."
141
154
  )
142
155
 
143
- resp = requests.request(
156
+ headers = {
157
+ "content-type": "application/json",
158
+ "User-Agent": self.user_agent,
159
+ }
160
+
161
+ if method == "GET":
162
+ request_with_retry = retry_http_error(
163
+ max_retries=5,
164
+ retry_status_code={408, 425, 429, 500, 502, 504},
165
+ retry_exceptions=(requests.ConnectionError, requests.Timeout), # type: ignore
166
+ )(self._request_with_status_check)
167
+ else:
168
+ request_with_retry = retry_http_error(
169
+ max_retries=5,
170
+ retry_status_code={408, 425, 429, 500, 502, 504},
171
+ )(self._request_with_status_check)
172
+
173
+ resp = request_with_retry(
144
174
  method,
145
175
  url,
146
176
  json=payload,
147
177
  timeout=TIMEOUT,
148
- headers={
149
- "content-type": "application/json",
150
- "User-Agent": self.user_agent,
151
- },
178
+ headers=headers,
152
179
  auth=self.authenticator,
153
180
  params=params,
154
181
  )
155
- resp.raise_for_status()
156
182
  data: JSendPayload = resp.json()
157
183
  return data
158
184
 
@@ -238,7 +264,7 @@ class Client:
238
264
 
239
265
  @retry_http_error(max_retries=5, retry_exceptions=(requests.ConnectionError,))
240
266
  def _download_results(self, results_link: str) -> JobResult:
241
- response = requests.request("GET", results_link)
267
+ response = self.session.request("GET", results_link)
242
268
  response.raise_for_status()
243
269
  data = response.json()
244
270
  return JobResult(
@@ -373,9 +399,22 @@ class Client:
373
399
  return self.get_public_device_specs()
374
400
 
375
401
  def get_public_device_specs(self) -> Dict[str, str]:
376
- response = requests.request(
377
- "GET", f"{self.endpoints.core}/api/v1/devices/public-specs"
402
+ response = self.session.request(
403
+ "GET",
404
+ f"{self.endpoints.core}/api/v1/devices/public-specs",
378
405
  )
379
406
  response.raise_for_status()
380
407
  devices = response.json()["data"]
381
408
  return {device["device_type"]: device["specs"] for device in devices}
409
+
410
+ def set_batch_tags(
411
+ self,
412
+ batch_id: str,
413
+ tags: list[str],
414
+ ) -> Dict[str, str]:
415
+ response: Dict[str, Any] = self._authenticated_request(
416
+ "PATCH",
417
+ f"{self.endpoints.core}/api/v1/batches/{batch_id}/tags",
418
+ tags,
419
+ )["data"]
420
+ return response
@@ -1,8 +1,10 @@
1
1
  from pasqal_cloud.device.configuration import BaseConfig, EmuFreeConfig, EmuTNConfig
2
+ from pasqal_cloud.device.device_types import DeviceTypeName
2
3
  from pasqal_cloud.device.emulator_types import EmulatorType
3
4
 
4
5
  __all__ = [
5
6
  "BaseConfig",
7
+ "DeviceTypeName",
6
8
  "EmuFreeConfig",
7
9
  "EmuTNConfig",
8
10
  "EmulatorType",
@@ -1,8 +1,9 @@
1
1
  from pasqal_cloud.utils.strenum import StrEnum
2
2
 
3
3
 
4
- class EmulatorType(StrEnum):
4
+ class DeviceTypeName(StrEnum):
5
5
  EMU_FREE = "EMU_FREE"
6
6
  EMU_TN = "EMU_TN"
7
7
  EMU_FRESNEL = "EMU_FRESNEL"
8
8
  EMU_MPS = "EMU_MPS"
9
+ FRESNEL = "FRESNEL"
@@ -0,0 +1,13 @@
1
+ from pasqal_cloud.utils.strenum import StrEnum
2
+
3
+
4
+ class EmulatorType(StrEnum):
5
+ """
6
+ Enum for the emulator type, is deprecated.
7
+ Use DeviceTypeName instead.
8
+ """
9
+
10
+ EMU_FREE = "EMU_FREE"
11
+ EMU_TN = "EMU_TN"
12
+ EMU_FRESNEL = "EMU_FRESNEL"
13
+ EMU_MPS = "EMU_MPS"
@@ -79,6 +79,15 @@ class RebatchError(BatchException):
79
79
  super().__init__("Batch retry failed", e)
80
80
 
81
81
 
82
+ class BatchSetTagsError(BatchException):
83
+ """
84
+ Exception class when setting tags to a batch failed.
85
+ """
86
+
87
+ def __init__(self, e: HTTPError) -> None:
88
+ super().__init__("Setting Batch tags failed", e)
89
+
90
+
82
91
  class JobException(ExceptionWithResponseContext):
83
92
  """
84
93
  Base Exception class for jobs.
@@ -215,3 +224,15 @@ class OnlyCompleteOrOpenCanBeSet(BaseException):
215
224
 
216
225
  def __init__(self) -> None:
217
226
  super().__init__("Only complete or open can be set when creating a batch.")
227
+
228
+
229
+ class InvalidDeviceTypeSet(BaseException):
230
+ """
231
+ Exception class raised when both emulator and device_type
232
+ arguments are set on a batch.
233
+ """
234
+
235
+ def __init__(self) -> None:
236
+ super().__init__(
237
+ "Only emulator or device_type can be set when creating a batch."
238
+ )
@@ -194,6 +194,7 @@ class BatchFilters(BaseFilters):
194
194
  start_date: Batches created at or after this datetime.
195
195
  end_date: Batches created at or before this datetime.
196
196
  queue_priority: Filter by queue priority value.
197
+ tag: Filter by a specific tag.
197
198
  """
198
199
 
199
200
  project_id: Optional[Union[List[Union[UUID, str]], Union[UUID, str]]] = None
@@ -202,6 +203,7 @@ class BatchFilters(BaseFilters):
202
203
  status: Optional[Union[List[BatchStatus], BatchStatus]] = None
203
204
  open: Optional[bool] = None
204
205
  queue_priority: Optional[Union[List[QueuePriority], QueuePriority]] = None
206
+ tag: Optional[str] = None
205
207
 
206
208
  @field_validator(
207
209
  "id",
@@ -19,7 +19,7 @@ def retry_http_error(
19
19
 
20
20
  Args:
21
21
  max_retries: The maximum number of retry attempts
22
- retry_status_codes: Specific HTTP status codes to trigger a retry.
22
+ retry_status_code: Specific HTTP status codes to trigger a retry.
23
23
  - NB: If None, retries on all HTTP error status codes.
24
24
  retry_exceptions: List of specific Exception classes that trigger a retry.
25
25
  - NB: If None, retries will only occur based on status codes, not
@@ -30,9 +30,11 @@ def retry_http_error(
30
30
  @functools.wraps(func)
31
31
  def wrapper(*args: Param.args, **kwargs: Param.kwargs) -> RT:
32
32
  for iteration in range(max_retries + 1):
33
+ # 2 seconds, 4 seconds, 8 seconds, 16 seconds, 32 seconds
34
+ delay = 2**iteration
33
35
  try:
34
36
  response = func(*args, **kwargs)
35
- except HTTPError as e: # noqa: PERF203
37
+ except HTTPError as e:
36
38
  if (
37
39
  e.response is None
38
40
  or (
@@ -42,7 +44,6 @@ def retry_http_error(
42
44
  or iteration == max_retries
43
45
  ):
44
46
  raise e
45
- delay = (1 * 2) ** iteration
46
47
  time.sleep(delay)
47
48
  except Exception as e:
48
49
  if (
@@ -50,7 +51,6 @@ def retry_http_error(
50
51
  and isinstance(e, retry_exceptions)
51
52
  and iteration < max_retries
52
53
  ):
53
- delay = (1 * 2) ** iteration
54
54
  time.sleep(delay)
55
55
  else:
56
56
  raise e
@@ -7,7 +7,7 @@ from pydantic import BaseModel, ConfigDict, field_validator, PrivateAttr
7
7
  from pydantic_core.core_schema import ValidationInfo
8
8
  from requests import HTTPError
9
9
 
10
- from pasqal_cloud.client import Client
10
+ from pasqal_cloud.client import _skip_ssl_verify, Client
11
11
  from pasqal_cloud.errors import (
12
12
  InvalidWorkloadResultsFormatError,
13
13
  WorkloadCancellingError,
@@ -82,7 +82,7 @@ class Workload(BaseModel):
82
82
  if result or not result_link:
83
83
  return result
84
84
  try:
85
- res = requests.get(result_link)
85
+ res = requests.get(result_link, verify=not _skip_ssl_verify())
86
86
  except HTTPError as e:
87
87
  raise WorkloadResultsDownloadError(e) from e
88
88
  except requests.ConnectionError as e:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: pasqal-cloud
3
- Version: 0.20.2
3
+ Version: 0.20.4.dev0
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
@@ -16,22 +16,23 @@ 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
18
  Provides-Extra: dev
19
- Requires-Dist: pytest-cov==5.0.0; extra == "dev"
20
19
  Requires-Dist: types-requests==2.31.0.1; extra == "dev"
21
20
  Requires-Dist: ruff==0.6.9; extra == "dev"
22
21
  Requires-Dist: mypy==1.10.0; extra == "dev"
22
+ Requires-Dist: pytest-cov==5.0.0; extra == "dev"
23
23
  Requires-Dist: pytest==8.1.1; extra == "dev"
24
24
  Requires-Dist: requests-mock==1.12.1; extra == "dev"
25
25
  Provides-Extra: docs
26
- Requires-Dist: mkdocs-material==9.5.50; extra == "docs"
27
26
  Requires-Dist: mkdocstrings-python==1.13.0; extra == "docs"
28
- Requires-Dist: mkdocstrings==0.27.0; extra == "docs"
29
27
  Requires-Dist: mkdocs==1.6.1; extra == "docs"
28
+ 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
33
33
  Dynamic: home-page
34
34
  Dynamic: license
35
+ Dynamic: license-file
35
36
  Dynamic: maintainer
36
37
  Dynamic: maintainer-email
37
38
  Dynamic: provides-extra
@@ -41,25 +42,7 @@ Dynamic: summary
41
42
 
42
43
  # PASQAL Cloud
43
44
 
44
- SDK to be used to access Pasqal Cloud Services.
45
-
46
- ## Version Support & Deprecation Timeline
47
-
48
- | Version | Release Date | End of Support |
49
- | ------- | ------------ | -------------- |
50
- | 0.5.0 | 2024-02-05 | 2025-02-05 |
51
- | 0.6.0 | 2024-02-26 | 2025-02-26 |
52
- | 0.7.0 | 2024-03-05 | 2025-03-05 |
53
- | 0.8.0 | 2024-04-15 | 2025-04-15 |
54
- | 0.9.0 | 2024-05-15 | 2025-05-15 |
55
- | 0.10.0 | 2024-06-05 | 2025-06-05 |
56
- | 0.11.0 | 2024-06-27 | 2025-06-27 |
57
- | 0.12.0 | 2024-09-03 | 2025-09-03 |
58
- | 0.12.1 | 2024-09-11 | 2025-09-11 |
59
- | 0.12.2 | 2024-09-11 | 2025-09-11 |
60
- | 0.12.3 | 2024-10-02 | 2025-10-02 |
61
- | 0.12.4 | 2024-10-09 | 2025-10-09 |
62
- | 0.20.2 | 2024-11-26 | 2025-11-26 |
45
+ SDK to access Pasqal Cloud Services.
63
46
 
64
47
  ## Installation
65
48
 
@@ -156,7 +139,7 @@ to the next statement.
156
139
 
157
140
  ```python
158
141
  # Create a closed batch with 2 jobs and wait for its termination
159
- batch = sdk.create_batch(serialized_sequence, [job1, job2], wait=True)
142
+ batch = sdk.create_batch(serialized_sequence, [job1, job2], device_type=DeviceTypeName.FRESNEL, wait=True)
160
143
  ```
161
144
 
162
145
  To create an open batch, set the `open` argument to `True`, you can then add jobs to your batch.
@@ -164,7 +147,7 @@ Don't forget to mark your batch as closed when you are done adding new jobs to i
164
147
 
165
148
  ```python
166
149
  # Create an open batch with 1 job
167
- batch = sdk.create_batch(serialized_sequence, [job1], open=True)
150
+ batch = sdk.create_batch(serialized_sequence, [job1], open=True, device_type=DeviceTypeName.FRESNEL)
168
151
  # Add some jobs to it and wait for the jobs to be terminated
169
152
  job3 = {"runs": 50, "variables": {"omega_max": 10.5}}
170
153
  batch.add_jobs([job2, job3], wait=True)
@@ -173,14 +156,14 @@ batch.add_jobs([job2, job3], wait=True)
173
156
  batch.close()
174
157
  ```
175
158
 
176
- You can also choose to run your batch on an emulator using the optional argument `emulator`.
159
+ You should choose the device on which to run the batch with the parameter `device_type`.
177
160
  For using a basic single-threaded QPU emulator that can go up to 10 qubits, you can specify the "EMU_FREE" emulator:
178
161
 
179
162
  ```python
180
- from pasqal_cloud.device import EmulatorType
163
+ from pasqal_cloud.device import DeviceTypeName
181
164
 
182
165
  batch = sdk.create_batch(
183
- serialized_sequence, [job1, job2], emulator=EmulatorType.EMU_FREE
166
+ serialized_sequence, [job1, job2], device_type=DeviceTypeName.EMU_FREE
184
167
  )
185
168
  ```
186
169
 
@@ -20,6 +20,7 @@ pasqal_cloud.egg-info/dependency_links.txt
20
20
  pasqal_cloud.egg-info/requires.txt
21
21
  pasqal_cloud.egg-info/top_level.txt
22
22
  pasqal_cloud/device/__init__.py
23
+ pasqal_cloud/device/device_types.py
23
24
  pasqal_cloud/device/emulator_types.py
24
25
  pasqal_cloud/device/configuration/__init__.py
25
26
  pasqal_cloud/device/configuration/base_config.py
@@ -1,2 +0,0 @@
1
- __version__ = '0.20.2'
2
- deprecation_date = '2026-03-05'
@@ -4,15 +4,15 @@ pyjwt[crypto]<3.0.0,>=2.5.0
4
4
  pydantic<3.0.0,>=2.6.0
5
5
 
6
6
  [dev]
7
- pytest-cov==5.0.0
8
7
  types-requests==2.31.0.1
9
8
  ruff==0.6.9
10
9
  mypy==1.10.0
10
+ pytest-cov==5.0.0
11
11
  pytest==8.1.1
12
12
  requests-mock==1.12.1
13
13
 
14
14
  [docs]
15
- mkdocs-material==9.5.50
16
15
  mkdocstrings-python==1.13.0
17
- mkdocstrings==0.27.0
18
16
  mkdocs==1.6.1
17
+ mkdocs-material==9.5.50
18
+ mkdocstrings==0.27.0