Qiskit / qiskit-ibm-runtime

IBM Client for Qiskit Runtime
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime
Apache License 2.0
149 stars 154 forks source link

Make `NoiseLearnerResult` JSON serializable #1908

Closed frankharkins closed 1 week ago

frankharkins commented 2 weeks ago

What is the expected feature or enhancement?

Unlike other result types, NoiseLearnerResult is not JSON serializable. I get an error when trying to save the job using this guide: https://docs.quantum.ibm.com/guides/save-jobs#save-results-to-disk.

import json
from qiskit_ibm_runtime import RuntimeEncoder
with open("result.json", "w") as file:
   json.dump(retrieved_job.result(), file, cls=RuntimeEncoder)
TypeError: Object of type NoiseLearnerResult is not JSON serializable

Full traceback.

Acceptance criteria

NoiseLearnerResult can be serialized with RuntimeEncoder and RuntimeDecoder.

frankharkins commented 1 week ago

Thank you!