From a6099226c53f1def8ee4577fc3dcbbec26def0e7 Mon Sep 17 00:00:00 2001 From: Ivana Date: Tue, 7 Jan 2025 15:39:53 +0800 Subject: [PATCH] Fix decoder and encoder for Experiment JSON decoder decodes json objects from the bottom of the tree, so the list of jobs has been decoded while decoding the JSON object of Experiment. --- qiskit_pulse_control/json.py | 4 +--- qiskit_pulse_control/unified_job.py | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qiskit_pulse_control/json.py b/qiskit_pulse_control/json.py index c7fc855..d949386 100644 --- a/qiskit_pulse_control/json.py +++ b/qiskit_pulse_control/json.py @@ -77,9 +77,7 @@ def object_hook(self, any_object: Any) -> Any: if type_name == 'job': return self._decode_job(value) if type_name == 'experiment': - jobs = [ - self._decode_job(encoded_job) for encoded_job in value['jobs'] - ] + jobs = value['jobs'] experiment = self._experiment_decoder.decode(value['experiment']) analysis_result = None if 'analysis_result' in value: diff --git a/qiskit_pulse_control/unified_job.py b/qiskit_pulse_control/unified_job.py index db52eba..1438c9c 100644 --- a/qiskit_pulse_control/unified_job.py +++ b/qiskit_pulse_control/unified_job.py @@ -63,6 +63,7 @@ def runtime_job(self): self._runtime_job = service.get_service().job(self.id) return self._runtime_job + class ExperimentJob: '''A wrapper for qiskit_experiments' experiment @@ -83,6 +84,7 @@ class ExperimentJob: def __init__(self, experiment_data: framework.ExperimentData): self.jobs = [Job(j) for j in experiment_data.jobs()] self.experiment = experiment_data.experiment + self.analysis_result = None if all(job.status == providers.JobStatus.DONE for job in self.jobs): self.analysis_result = experiment_data.analysis_results() self._experiment_data = experiment_data @@ -96,6 +98,7 @@ def _(self, jobs: list[Job], self.jobs = jobs self.experiment = experiment self.analysis_result = analysis_result + self._experiment_data = None @property def experiment_data(self) -> framework.ExperimentData: