Skip to content

Commit

Permalink
Transform result to dict before returning from Job.result (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-johnson authored Oct 2, 2023
1 parent 976b4e9 commit 32eaec5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/quantum_serverless/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,16 @@ def result(self, wait=True, cadence=5, verbose=False):
time.sleep(cadence)
if verbose:
logging.info(".")
return self._job_client.result(self.job_id)

# Retrieve the results. If they're string format, try to decode to a dictionary.
results = self._job_client.result(self.job_id)
if isinstance(results, str):
try:
results = json.loads(results, cls=QiskitObjectsDecoder)
except json.JSONDecodeError as exception:
logging.warning("Error during results decoding. Details: %s", exception)

return results

def _in_terminal_state(self) -> bool:
"""Checks if job is in terminal state"""
Expand Down

0 comments on commit 32eaec5

Please sign in to comment.