Skip to content

Commit 02394bd

Browse files
committed
feat(ys): update to qio
1 parent 76361e7 commit 02394bd

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

.github/workflows/publish.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
2022

2123
- name: Set up Python
2224
uses: actions/setup-python@v4
@@ -26,16 +28,18 @@ jobs:
2628
- name: Install dependencies
2729
run: |
2830
python -m pip install --upgrade pip
29-
pip install build twine wheel scmver setuptools
31+
pip install build twine setuptools-scm
3032
31-
- name: Get version from setup.py
33+
- name: Get version
3234
id: version
3335
run: |
34-
version=$(python3 setup.py --version)
36+
version=$(python -m setuptools_scm)
3537
echo "version=$version" >> $GITHUB_ENV
38+
echo "Version : $version"
3639
3740
- name: Build package
38-
run: python setup.py sdist bdist_wheel
41+
run: |
42+
python -m build
3943
4044
- name: Publish package
4145
uses: pypa/gh-action-pypi-publish@v1.5.0
@@ -48,4 +52,4 @@ jobs:
4852
git tag v$version
4953
git push origin v$version
5054
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ jobs:
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install build twine wheel scmver setuptools
21+
pip install build twine wheel scmver setuptools setuptools-scm
2222
2323
- name: Get version from setup.py
2424
id: version
2525
run: |
26-
version=$(python3 setup.py --version)
26+
version=$(python -m setuptools_scm)
2727
echo "version=$version" >> $GITHUB_ENV
2828
2929
- name: Build package
30-
run: python setup.py sdist bdist_wheel
30+
run: python -m build
3131

3232
- name: Install package
33-
run: pip install dist/pulser_scaleway-${version}-py3-none-any.whl
33+
run: pip install dist/yardstiq_scaleway-${version}-py3-none-any.whl
3434

3535
- name: Install test
3636
run: pip install -r tests/requirements.txt

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ requires-python = ">=3.12"
1111
dependencies = [
1212
"yardstiq>=0.1.0",
1313
"scaleway-qaas-client>=0.1.23",
14-
"qami,"
14+
"qami>=0.1.0",
1515
]
1616

17+
[project.urls]
18+
Repository = "https://github.com/scaleway/yardstiq-scaleway"
19+
1720
[project.entry-points."yardstiq.plugins"]
1821
scaleway = "yardstiq_scaleway.plugin_loader"

yardstiq_scaleway/scaleway_provider.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from typing import List, Union
55

6-
from qami import (
6+
from qio.core import (
77
QuantumProgram,
88
QuantumProgramResult,
99
QuantumComputationModel,
@@ -54,50 +54,49 @@ def deallocate(self, **kwargs) -> None:
5454
return
5555

5656
self.__client.terminate_session(self.__session_id)
57+
self.__session_id = None
5758

5859
def run(
5960
self,
6061
program: Union[QuantumProgram, List[QuantumProgram]],
6162
shots: int,
62-
wait: bool,
6363
**kwargs,
6464
) -> List[QuantumProgramResult]:
6565
if not isinstance(program, list):
6666
program = [program]
6767

68-
computation_model = QuantumComputationModel(
68+
computation_model_dict = QuantumComputationModel(
6969
programs=program,
7070
backend=None,
7171
client=None,
7272
).to_dict()
7373

74-
computation_parameters = QuantumComputationParameters(
74+
computation_parameters_dict = QuantumComputationParameters(
7575
shots=shots,
7676
).to_dict()
7777

78-
model = self.__client.create_model(computation_model)
78+
model = self.__client.create_model(computation_model_dict)
7979

8080
if not model:
8181
raise RuntimeError("Failed to push model data")
8282

83-
job = self.__client.create_job(self.__session_id, model_id=model.id)
83+
job = self.__client.create_job(
84+
self.__session_id, model_id=model.id, parameters=computation_parameters_dict
85+
)
8486

85-
if wait:
86-
while job.status in ["waiting", "running"]:
87-
time.sleep(2)
88-
job = self.__client.get_job(job.id)
87+
while job.status in ["waiting", "running"]:
88+
time.sleep(2)
89+
job = self.__client.get_job(job.id)
8990

9091
if job.status == "error":
9192
raise RuntimeError(f"Job failed with error: {job.progress_message}")
9293

93-
raw_results = self.__client.list_job_results(job.id)
94+
job_results = self.__client.list_job_results(job.id)
9495

9596
program_results = list(
9697
map(
97-
lambda r: QuantumProgramResult.from_json(
98-
self._extract_payload_from_response(r)
99-
),
100-
raw_results,
98+
lambda r: self._extract_payload_from_response(r),
99+
job_results,
101100
)
102101
)
103102

@@ -106,7 +105,9 @@ def run(
106105

107106
return program_results
108107

109-
def _extract_payload_from_response(self, job_result: QaaSJobResult) -> str:
108+
def _extract_payload_from_response(
109+
self, job_result: QaaSJobResult
110+
) -> QuantumProgramResult:
110111
result = job_result.result
111112

112113
if result is None or result == "":
@@ -115,12 +116,11 @@ def _extract_payload_from_response(self, job_result: QaaSJobResult) -> str:
115116
if url is not None:
116117
resp = httpx.get(url)
117118
resp.raise_for_status()
118-
119-
return resp.text
119+
result = resp.text
120120
else:
121121
raise RuntimeError("Got result with empty data and url fields")
122-
else:
123-
return result
122+
123+
return QuantumProgramResult.from_json(result)
124124

125125
@property
126126
def max_qubit_count(self) -> int:

0 commit comments

Comments
 (0)