Skip to content

Commit bff21e7

Browse files
committed
feat(qio): fix dict update
1 parent 4ad08b5 commit bff21e7

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

qiskit_scaleway/backends/base_job.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,25 @@ def submit(self, session_id: str) -> None:
8787
name=self.backend().name,
8888
version=self.backend().version,
8989
options=options,
90-
frozenset=True,
9190
)
9291

9392
client_data = ClientData(
9493
user_agent=USER_AGENT,
95-
frozenset=True,
9694
)
9795

98-
computation_model_dict = QuantumComputationModel(
96+
computation_model_json = QuantumComputationModel(
9997
programs=programs,
10098
backend=backend_data,
10199
client=client_data,
102100
noise_model=noise_model,
103-
frozenset=True,
104-
).to_dict()
101+
).to_json_str()
105102

106-
computation_parameters_dict = QuantumComputationParameters(
103+
computation_parameters_json = QuantumComputationParameters(
107104
shots=shots,
108-
frozenset=True,
109-
).to_dict()
105+
).to_json_str()
110106

111107
model = self._client.create_model(
112-
payload=computation_model_dict,
108+
payload=computation_model_json,
113109
)
114110

115111
if not model:
@@ -119,7 +115,7 @@ def submit(self, session_id: str) -> None:
119115
name=self._name,
120116
session_id=session_id,
121117
model_id=model.id,
122-
parameters=computation_parameters_dict,
118+
parameters=computation_parameters_json,
123119
).id
124120

125121
def result(
@@ -133,12 +129,10 @@ def result(
133129
program_results = list(
134130
map(
135131
lambda r: self._extract_payload_from_response(r).to_qiskit_result(
136-
**{
137-
"backend_name": self.backend().name,
138-
"backend_version": self.backend().version,
139-
"job_id": self._job_id,
140-
"qobj_id": ", ".join(x.name for x in self._circuits),
141-
}
132+
backend_name=self.backend().name,
133+
backend_version=self.backend().version,
134+
job_id=self._job_id,
135+
qobj_id=", ".join(x.name for x in self._circuits),
142136
),
143137
job_results,
144138
)
@@ -164,7 +158,7 @@ def _extract_payload_from_response(
164158
else:
165159
raise RuntimeError("Got result with empty data and url fields")
166160

167-
return QuantumProgramResult.from_json(result)
161+
return QuantumProgramResult.from_json_str(result)
168162

169163
def _wait_for_result(
170164
self, timeout: Optional[int], fetch_interval: int

qiskit_scaleway/backends/qsim/job.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,24 @@ def submit(self, session_id: str) -> None:
7474
name=self.backend().name,
7575
version=self.backend().version,
7676
options=options,
77-
frozenset=True,
7877
)
7978

8079
client_data = ClientData(
8180
user_agent=USER_AGENT,
82-
frozenset=True,
8381
)
8482

85-
computation_model_dict = QuantumComputationModel(
83+
computation_model_json = QuantumComputationModel(
8684
programs=programs,
8785
backend=backend_data,
8886
client=client_data,
89-
frozenset=True,
90-
).to_dict()
87+
).to_json_str()
9188

92-
computation_parameters_dict = QuantumComputationParameters(
89+
computation_parameters_json = QuantumComputationParameters(
9390
shots=options.pop("shots"),
94-
frozenset=True,
95-
).to_dict()
91+
).to_json_str()
9692

9793
model = self._client.create_model(
98-
payload=computation_model_dict,
94+
payload=computation_model_json,
9995
)
10096

10197
if not model:
@@ -105,7 +101,7 @@ def submit(self, session_id: str) -> None:
105101
name=self._name,
106102
session_id=session_id,
107103
model_id=model.id,
108-
parameters=computation_parameters_dict,
104+
parameters=computation_parameters_json,
109105
).id
110106

111107
def __to_cirq_result(self, program_result: QuantumProgramResult) -> "cirq.Result":
@@ -143,11 +139,14 @@ def result(
143139

144140
conv_method = match.get(format, self.__to_qiskit_result)
145141

146-
results = list(
142+
program_results = list(
147143
map(
148144
lambda r: conv_method(self._extract_payload_from_response(r)),
149145
job_results,
150146
)
151147
)
152148

153-
return results
149+
if len(program_results) == 1:
150+
return program_results[0]
151+
152+
return program_results

0 commit comments

Comments
 (0)