Skip to content

Commit

Permalink
[FEAT] Switch to V2 endpoints for some endpoints (#1281) (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mildophin authored Sep 11, 2024
1 parent d188930 commit 38f2a20
Show file tree
Hide file tree
Showing 14 changed files with 402 additions and 79 deletions.
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,42 @@

All notable changes to this project will be documented in this file.

## [0.12.2] - 2024-09-11

### Changed

- Now these methods are using V2 endpoints:
- Cancel a batch
- Cancel a job
- Cancel a group of jobs
- Add jobs to a batch
- Close a batch

## [0.12.1] - 2024-09-11

### Added

- Introduce EMU_FRESNEL device type

## [0.12.0] - 2024-09-03

### Breaking change

- 'from pasqal_cloud' import has completely replaced the deprecated import 'from sdk'
- 'group' field is now removed, use 'project' field instead
- 'group_id' field is now removed, use 'project_id' field instead

## [0.11.4] - 2024-08-28

### Changed

Batch that do not accept new jobs are now called "closed" instead of "complete". As a result:
A Batch that does not accept new jobs is now called "closed" instead of "complete". As a result:

- You should create an "open" batch using the "open" argument of the `create_batch` method instead of the `complete`
argument.
- Close an open batch using the `close_batch` method of the SDK or `close` method of the `Batch` class. They are
functionally equivalent to the now deprecated `complete_batch` and `declare_complete` functions.
- Batch dataclass parameter `complete` has been replaced by `open`.
- Using the deprecated method and arguments will now raise a warning .
- Using the deprecated method and arguments will now raise a warning.

## [0.11.3] - 2024-08-05

Expand Down
2 changes: 1 addition & 1 deletion pasqal_cloud/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.


__version__ = "0.12.1"
__version__ = "0.12.2"
12 changes: 6 additions & 6 deletions pasqal_cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ def get_job_results(self, job_id: str) -> Optional[JobResult]:

def close_batch(self, batch_id: str) -> Dict[str, Any]:
response: Dict[str, Any] = self._authenticated_request(
"PUT", f"{self.endpoints.core}/api/v1/batches/{batch_id}/complete"
"PATCH", f"{self.endpoints.core}/api/v2/batches/{batch_id}/complete"
)["data"]
return response

def cancel_batch(self, batch_id: str) -> Dict[str, Any]:
response: Dict[str, Any] = self._authenticated_request(
"PUT", f"{self.endpoints.core}/api/v1/batches/{batch_id}/cancel"
"PATCH", f"{self.endpoints.core}/api/v2/batches/{batch_id}/cancel"
)["data"]
return response

Expand Down Expand Up @@ -277,7 +277,7 @@ def add_jobs(
self, batch_id: str, jobs_data: Sequence[Mapping[str, Any]]
) -> Dict[str, Any]:
response: Dict[str, Any] = self._authenticated_request(
"POST", f"{self.endpoints.core}/api/v1/batches/{batch_id}/jobs", jobs_data
"POST", f"{self.endpoints.core}/api/v2/batches/{batch_id}/jobs", jobs_data
)["data"]
return response

Expand All @@ -289,16 +289,16 @@ def get_job(self, job_id: str) -> Dict[str, Any]:

def cancel_job(self, job_id: str) -> Dict[str, Any]:
response: Dict[str, Any] = self._authenticated_request(
"PUT", f"{self.endpoints.core}/api/v1/jobs/{job_id}/cancel"
"PATCH", f"{self.endpoints.core}/api/v2/jobs/{job_id}/cancel"
)["data"]
return response

def cancel_jobs(
self, batch_id: Union[UUID, str], filters: CancelJobFilters
) -> Dict[str, Any]:
response: Dict[str, Any] = self._authenticated_request(
"PUT",
f"{self.endpoints.core}/api/v1/batches/{batch_id}/cancel/jobs",
"PATCH",
f"{self.endpoints.core}/api/v2/batches/{batch_id}/cancel/jobs",
params=filters.model_dump(exclude_unset=True),
)["data"]
return response
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"status": "success",
"message": "OK.",
"code": "200",
"data": {
"id": "00000000-0000-0000-0000-000000000001",
"created_at": "2023-03-23T10:41:36.635820+00:00",
"updated_at": "2023-03-23T10:42:27.610076+00:00",
"start_datetime": null,
"end_datetime": "2023-03-23T10:42:27.611384+00:00",
"priority": 20,
"sequence_builder": "{\"_build\": true, \"__module__\": \"pulser.sequence.sequence\", \"__name__\": \"Sequence\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.register.register\", \"__name__\": \"Register\", \"__args__\": [{\"q0\": [-10.0, 0.0], \"q1\": [-5.0, -8.660254], \"q2\": [-5.0, 8.660254], \"q3\": [5.0, -8.660254], \"q4\": [5.0, 8.660254], \"q5\": [10.0, 0.0]}], \"__kwargs__\": {\"layout\": {\"_build\": true, \"__module__\": \"pulser.register.register_layout\", \"__name__\": \"RegisterLayout\", \"__args__\": [{\"_build\": true, \"__module__\": \"numpy\", \"__name__\": \"array\", \"__args__\": [[[0.0, 0.0], [2.5, 4.330127018922194], [2.5, -4.330127018922194], [-5.0, 0.0], [-5.0, 8.660254037844387], [5.0, 8.660254037844387], [7.5, 4.330127018922194], [10.0, 0.0], [7.5, -4.330127018922194], [5.0, -8.660254037844387], [-5.0, -8.660254037844387], [-10.0, 0.0], [-12.5, 4.330127018922194], [-10.0, 8.660254037844387], [10.0, 8.660254037844387], [15.0, 0.0], [-2.5, -12.99038105676658], [-7.5, -12.99038105676658], [-10.0, -8.660254037844387], [-10.0, 17.320508075688775], [5.0, 17.320508075688775], [10.0, 17.320508075688775], [12.5, 12.99038105676658], [17.5, 4.330127018922192], [20.0, 0.0], [12.5, -12.99038105676658], [-15.0, -8.660254037844387], [-20.0, 0.0], [-22.5, 4.330127018922194], [-12.5, 21.650635094610966], [17.5, 12.990381056766578], [25.0, 0.0], [12.5, -21.650635094610966], [-2.5, -21.650635094610966], [-12.5, -21.650635094610966], [-20.0, -8.660254037844384], [-22.5, 12.99038105676658], [5.0, 25.98076211353316], [17.5, 21.65063509461097], [20.0, 17.320508075688775], [22.5, 12.99038105676658], [25.0, 8.660254037844389], [27.5, 4.330127018922196], [25.0, -8.660254037844387], [-22.5, -12.99038105676658], [-30.0, 0.0], [-32.5, 4.330127018922194], [2.5, 30.310889132455355], [17.5, 30.310889132455355], [20.0, 25.98076211353316], [22.5, 21.650635094610966], [30.0, -8.660254037844387], [22.5, -21.650635094610966], [17.5, -30.310889132455355], [-2.5, -30.310889132455355], [-17.5, -30.310889132455355], [-22.5, -21.650635094610966], [-32.5, -4.330127018922192], [-37.5, 4.330127018922194], [-27.5, 21.650635094610966], [22.5, 30.310889132455355], [30.0, 17.320508075688775], [32.5, 12.99038105676658], [37.5, -4.330127018922194], [5.0, -34.64101615137755], [-22.5, -30.310889132455355], [-25.0, -25.98076211353316], [-32.5, -12.99038105676658]]], \"__kwargs__\": {}}], \"__kwargs__\": {}}, \"trap_ids\": [20, 24, 26, 35, 36, 41]}}, {\"_build\": false, \"__module__\": \"pulser.devices\", \"__name__\": \"IroiseMVP\"}], \"__kwargs__\": {}, \"__version__\": \"0.5.1\", \"calls\": [[\"declare_channel\", [\"ch_global\", \"rydberg_global\"], {\"initial_target\": null}], [\"add\", [{\"_build\": true, \"__module__\": \"pulser.pulse\", \"__name__\": \"Pulse\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [124, 12.566370614359172], \"__kwargs__\": {}}, {\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [124, 25.132741228718345], \"__kwargs__\": {}}, 0.0], \"__kwargs__\": {\"post_phase_shift\": 0.0}}, \"ch_global\"], {}], [\"add\", [{\"_build\": true, \"__module__\": \"pulser.pulse\", \"__name__\": \"Pulse\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [400, 0.0], \"__kwargs__\": {}}, {\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [400, -25.132741228718345], \"__kwargs__\": {}}, 0.0], \"__kwargs__\": {\"post_phase_shift\": 0.0}}, \"ch_global\"], {}], [\"add\", [{\"_build\": true, \"__module__\": \"pulser.pulse\", \"__name__\": \"Pulse\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [100, 12.566370614359172], \"__kwargs__\": {}}, {\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [100, 25.132741228718345], \"__kwargs__\": {}}, 0.0], \"__kwargs__\": {\"post_phase_shift\": 0.0}}, \"ch_global\"], {}], [\"add\", [{\"_build\": true, \"__module__\": \"pulser.pulse\", \"__name__\": \"Pulse\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [400, 0.0], \"__kwargs__\": {}}, {\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [400, -25.132741228718345], \"__kwargs__\": {}}, 0.0], \"__kwargs__\": {\"post_phase_shift\": 0.0}}, \"ch_global\"], {}], [\"add\", [{\"_build\": true, \"__module__\": \"pulser.pulse\", \"__name__\": \"Pulse\", \"__args__\": [{\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [100, 12.566370614359172], \"__kwargs__\": {}}, {\"_build\": true, \"__module__\": \"pulser.waveforms\", \"__name__\": \"ConstantWaveform\", \"__args__\": [100, 25.132741228718345], \"__kwargs__\": {}}, 0.0], \"__kwargs__\": {\"post_phase_shift\": 0.0}}, \"ch_global\"], {}], [\"measure\", [], {}]], \"vars\": {}, \"to_build_calls\": []}",
"device_type": "EMU_FREE",
"status": "CANCELED",
"complete": true,
"open": false,
"project_id": "00000000-0000-0000-0000-000000000001",
"webhook": null,
"user_id": "EQZj1ZQE",
"configuration": null,
"device_status": null,
"jobs_count": 2,
"jobs_count_per_status": {
"PENDING": 0,
"RUNNING": 0,
"DONE": 0,
"ERROR": 0,
"CANCELED": 2
},
"jobs": [
{
"id": "30c58103-8a6d-4e15-bc40-23285e73bf2b",
"created_at": "2023-03-23T10:41:36.635820+00:00",
"updated_at": "2023-03-23T10:42:27.610076+00:00",
"start_timestamp": null,
"end_timestamp": "2023-03-23T10:42:27.611419+00:00",
"runs": 200,
"status": "CANCELED",
"errors": null,
"variables": {},
"batch_id": "5af686ee-d7dc-459e-a73e-12279ae04b91",
"project_id": "00000000-0000-0000-0000-000000000007"
},
{
"id": "ed9ae427-a480-4bf6-9bd9-0ac82d0a1d50",
"created_at": "2023-03-23T10:41:36.635820+00:00",
"updated_at": "2023-03-23T10:42:27.610076+00:00",
"start_timestamp": null,
"end_timestamp": "2023-03-23T10:42:27.611425+00:00",
"runs": 100,
"status": "CANCELED",
"errors": null,
"variables": {},
"batch_id": "5af686ee-d7dc-459e-a73e-12279ae04b91",
"project_id": "00000000-0000-0000-0000-000000000007"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"status": "success",
"message": "OK.",
"code": "200",
"data": {
"jobs": [
{
"id": "00000000-0000-0000-0000-000000000001",
"created_at": "2023-03-23T10:41:36.635820+00:00",
"updated_at": "2023-03-23T10:42:27.610076+00:00",
"start_timestamp": null,
"end_timestamp": "2023-03-23T10:42:27.611419+00:00",
"runs": 200,
"status": "CANCELED",
"errors": null,
"variables": {},
"batch_id": "5af686ee-d7dc-459e-a73e-12279ae04b91",
"project_id": "00000000-0000-0000-0000-000000000007"
},
{
"id": "00000000-0000-0000-0000-000000000002",
"created_at": "2023-03-23T10:41:36.635820+00:00",
"updated_at": "2023-03-23T10:42:27.610076+00:00",
"start_timestamp": null,
"end_timestamp": "2023-03-23T10:42:27.611419+00:00",
"runs": 200,
"status": "CANCELED",
"errors": null,
"variables": {},
"batch_id": "5af686ee-d7dc-459e-a73e-12279ae04b91",
"project_id": "00000000-0000-0000-0000-000000000007"
}
],
"errors": {
"00000000-0000-0000-0000-000000000003": "Error could not be cancelled"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"code": 200,
"data": {
"complete": true,
"open": false,
"created_at": "2021-11-10T15:24:38.155824",
"device_type": "MOCK_DEVICE",
"project_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000000001",
"priority": 10,
"sequence_builder": "pulser_test_sequence",
"status": "PENDING",
"updated_at": "2021-11-10T15:27:44.110274",
"user_id": "EQZj1ZQE",
"webhook": "10.0.1.5",
"jobs": [
{
"batch_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000022010",
"project_id": "00000000-0000-0000-0000-000000022111",
"runs": 50,
"status": "RUNNING",
"created_at": "2021-11-10T15:27:06.698066",
"errors": [],
"updated_at": "2021-11-10T15:27:06.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [
200,
500
]
}
}
]
},
"message": "OK.",
"status": "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"code": 200,
"data": {
"complete": true,
"open": false,
"created_at": "2021-11-10T15:24:38.155824",
"device_type": "MOCK_DEVICE",
"project_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000000001",
"priority": 10,
"sequence_builder": "pulser_test_sequence",
"status": "PENDING",
"updated_at": "2021-11-10T15:27:44.110274",
"user_id": "EQZj1ZQE",
"webhook": "10.0.1.5",
"configuration": { "dt": 10.0, "precision": "normal" },
"start_datetime": "2023-03-23T10:42:27.611384+00:00",
"end_datetime": "2023-03-23T10:42:27.611384+00:00",
"jobs": [
{
"batch_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000022010",
"project_id": "00000000-0000-0000-0000-000000022111",
"runs": 50,
"status": "PENDING",
"created_at": "2021-11-10T15:27:06.698066",
"errors": [],
"updated_at": "2021-11-10T15:27:06.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [200, 500]
}
},
{
"batch_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000022011",
"project_id": "00000000-0000-0000-0000-000000022111",
"runs": 50,
"status": "PENDING",
"created_at": "2021-11-10T15:27:06.698066",
"errors": [],
"updated_at": "2021-11-10T15:27:06.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [200, 500]
}
}
]
},
"message": "OK.",
"status": "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"code": 200,
"data": {
"complete": true,
"open": false,
"created_at": "2021-11-10T15:24:38.155824",
"device_type": "MOCK_DEVICE",
"project_id": "00000000-0000-0000-0000-000000000001",
"id": "00000000-0000-0000-0000-000000000002",
"priority": 10,
"sequence_builder": "pulser_test_sequence",
"status": "PENDING",
"updated_at": "2021-11-10T15:27:44.110274",
"user_id": "EQZj1ZQE",
"webhook": "10.0.1.5",
"configuration": { "dt": 10.0, "precision": "normal" },
"start_datetime": "2023-03-23T10:42:27.611384+00:00",
"end_datetime": "2023-03-23T10:42:27.611384+00:00",
"jobs": [
{
"batch_id": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000022010",
"project_id": "00000000-0000-0000-0000-000000022111",
"runs": 50,
"status": "PENDING",
"created_at": "2021-11-10T15:27:06.698066",
"errors": [],
"updated_at": "2021-11-10T15:27:06.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [200, 500]
}
},
{
"batch_id": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000022011",
"project_id": "00000000-0000-0000-0000-000000022111",
"runs": 50,
"status": "PENDING",
"created_at": "2021-11-10T15:27:06.698066",
"errors": [],
"updated_at": "2021-11-10T15:27:06.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [200, 500]
}
}
]
},
"message": "OK.",
"status": "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"code": 200,
"data": {
"batch_id": "00000000-0000-0000-0000-000000000001",
"project_id": "00000000-0000-0000-0000-000000000002",
"created_at": "2021-11-10T15:24:38.172109",
"errors": [
"Error 1",
"Error 2: Cannot connect to QPU",
"Error 3: Matrix glitch"
],
"id": "00000000-0000-0000-0000-000000022010",
"runs": 50,
"status": "PENDING",
"updated_at": "2021-11-10T15:27:06.698066",
"start_timestamp": "1636558026.698066",
"end_timestamp": "1636558026.698066",
"variables": {
"Omega_max": 14.4,
"last_target": "q1",
"ts": [
200,
500
]
}
},
"message": "OK.",
"status": "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"status": "success",
"message": "OK.",
"code": "200",
"data": {
"id": "00000000-0000-0000-0000-000000022010",
"created_at": "2023-03-24T09:05:32.420887+00:00",
"updated_at": "2023-03-24T09:06:52.105568+00:00",
"start_timestamp": null,
"end_timestamp": "2023-03-24T09:06:52.107659+00:00",
"runs": 200,
"status": "CANCELED",
"errors": null,
"variables": {},
"batch_id": "00000000-0000-0000-0000-000000000001",
"project_id": "00000000-0000-0000-0000-000000000002"
}
}
Loading

0 comments on commit 38f2a20

Please sign in to comment.