Skip to content

Commit

Permalink
Experiment data fixes (#1092)
Browse files Browse the repository at this point in the history
### Summary

This PR handles some issues related to `ExperimentData`

1. Fixing a bug in `_add_job_data`.
2. Adding multi-upload capability to `ExperimentData.save()`
3. Different `provider` handling to enable better data loading 
4. `start_datetime` and `end_datetime` are not being set at all, and
`creation_datetime` and `updated_datetime` are being set only after
loading the experiment from the server.

### Details and comments
1. Currently `_add_job_data` is adding the result of a job without
explicitly supplying its `job_id`. While in the old
`qiskit-ibmq-provider` it was ok, in the new `qiskit-ibm-provider` it
seems the job id contained in the `Result` object is different than the
job id of the actual job itself. Since `ExperimentData` keeps the
original job id, the result is that for every submitted job, it ends up
with two different ids: One of a seemingly unfinished job, and the
second for a job which was seemingly never initiated. This PR addresses
this issue by using the original job id whenever possible.

2. `ExperimentData.save()` currently uploads both analysis results and
figures one-by-one, with the result being inefficient which already
affects other projects. This issue is handled in
`qiskit-ibm-experiments` whose API was enlarged to allow multiple
uploading of analysis results and figures; this PR enables this API
usage in `ExperimentData`

3. `ExperimentData.load()` currently takes the `experiment_id` and an
`IBMExperimentService` object. This has two setbacks: First,
`IBMExperimentService` should be transparent to the users as much as
possible. Second, `IBMExperimentService` handles the resultDB data, but
the job data stored by `ExperimentData` is handled by the `IBMProvider`.
This issue can be fixed by allowing the provider to be passed as
parameter to `load()` since the service can be obtained from the
provider. This change also fixes #1093.

4. `start_datetime` and `end_datetime` were not set by `ExperimentData`
nor by the database itself. This PR makes the experiment data set
`start_datetime` to the time it was created (unless another value is
passed on creation; currently the `BaseExperiment` creates the
experiment data right before beginning the experiment. Also, this PR
makes every job update the `end_datetime` once it terminates. Along with
that, calls to `save()` now update the values of `creation_datetime` and
`updated_datetime` (which are set by the server). All the times are
stored in UTC timezone, but the getters return them in local time, and
the setters convert from local time to UTC.

5. `ExperimentData.save()` did not raise error in case no database
service was available. Now it raises an error if `suppress_errors` is
`False`.

---------

Co-authored-by: Yael Ben-Haim <[email protected]>
  • Loading branch information
gadial and yaelbh authored May 11, 2023
1 parent a8f9de8 commit 6a732f4
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 74 deletions.
6 changes: 6 additions & 0 deletions qiskit_experiments/database_service/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ class ExperimentEntryExists(ExperimentDataError):
"""Errors raised when an experiment entry already exists."""

pass


class ExperimentDataSaveFailed(ExperimentDataError):
"""Errors raised when an experiment save fails."""

pass
Loading

0 comments on commit 6a732f4

Please sign in to comment.