Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix local client #104

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Fix local client #104

wants to merge 7 commits into from

Conversation

1d4n
Copy link
Collaborator

@1d4n 1d4n commented Aug 1, 2024

Summary

Fixed the file methods of the local client and added an option to choose a custom directory for it.

Details and comments

Example of initializing a local service with a custom directory:

from qiskit_ibm_experiment import IBMExperimentService
service = IBMExperimentService(local=True, local_db_dir='/home/usr/results')

Fixes #
There were problems with loading and saving .zip files.
E.g. this code raised the exception: TypeError: write() argument must be str, not _io.BytesIO:

from qiskit_experiments.library.characterization import T1
import numpy as np
from qiskit_aer import AerSimulator
backend = AerSimulator()
t1_delays = np.arange(1e-6, 600e-6, 50e-6)
exp = T1(physical_qubits=(0,), delays=t1_delays)
exp_data = exp.run(backend=backend).block_for_results()

from qiskit_ibm_experiment import IBMExperimentService
exp_service = IBMExperimentService(local=True)
exp_data.service = exp_service
exp_data.save() # this line caused the exception (it calls to IBMExperimentService.file_upload() and then to LocalExperimentClient.save()).
  • In order to read a zip file, we need to open it in 'rb' mode.
  • In LocalExperimentClient.experiment_file_download(): if we use io.BytesIO and read the data, we need to use file.seek(0) so next time we read the data, it will start reading from the beginninng.

@1d4n 1d4n marked this pull request as draft August 1, 2024 13:23
@1d4n 1d4n changed the title fix local client file methods Fix local client Aug 19, 2024
@1d4n 1d4n marked this pull request as ready for review August 19, 2024 12:40
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants