Skip to content

More robust local service implementation #1383

Open
@nkanazawa1989

Description

@nkanazawa1989

Suggested feature

One of the important features in the Qiskit Expeirments is the result data management through the Experiment service. We have local implementation of this in qiskit_experiments.test.fake_service, however, the implementation details are different in many places from one by IBM.

For example, when you retrieve the data from the service, it returns a list of AnalysisResult object which is implemented in https://github.com/Qiskit-Extensions/qiskit-experiments/blob/32474382ea28e36a7ffe5253d87e1aaa7e0c1a40/qiskit_experiments/framework/experiment_data.py#L1492-L1494

In the IBM service, the result object is created from the data dictionary. This dictionary has two fields value and _value. Non underscore one is a displayed value in the IBM experiment website, which is created from the original data when the result object is created for save https://github.com/Qiskit-Extensions/qiskit-experiments/blob/32474382ea28e36a7ffe5253d87e1aaa7e0c1a40/qiskit_experiments/framework/analysis_result.py#L186-L188
while the other is original data serialized and deserialized by our custom JSON encoder and decoder.

This mechanism is not implemented in the fake service, and accessing _value value raises the key error (likely this pattern is not tested):
https://github.com/Qiskit-Extensions/qiskit-experiments/blob/32474382ea28e36a7ffe5253d87e1aaa7e0c1a40/qiskit_experiments/framework/experiment_data.py#L1505

Apart from this, current fake service doesn't implement serialization and deserialization mechanism (it just stores raw data in the data frame). Form the local client viewpoint handling of data behind the scene doesn't matter, however, for the unit test purpose this could produce different situation from the online service.

This makes me think we need to promote the fake service to the qiskit_experiments.database_service.local_service so that the end users and test agent can reliably use (note that IBM service also implements local mode, but this is not necessary in my opinion). To achieve this, we need to define the protocol (or abstract service class) in this package, and let IBM project rewrite their service class based off of the protocol. Qiskit Expeirment should implement reliable local service as a reference implementation. This resembles the Qiskit Backend model / Qiskit IBM Backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions