Skip to content

Commit

Permalink
Fix decoder and encoder for Experiment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IvanaGyro committed Jan 7, 2025
1 parent f173038 commit a609922
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions qiskit_pulse_control/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions qiskit_pulse_control/unified_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit a609922

Please sign in to comment.