qiboteam / qibo-client

Qibo remote connection client.
https://qibo.science
Apache License 2.0
2 stars 1 forks source link

Client launches job and exits #41

Closed marcorossi5 closed 2 months ago

marcorossi5 commented 3 months ago

The current run_circuit behavior is to wait online for the results.

An alternative behavior is the client sends the request, the server answer success and the client immediately exits.

The user can see when the results are ready on the webapp user page. He can also download the files from browser by clicking a button there.

scarrazza commented 3 months ago

For this point, I would like to suggest defining a syntax similar to https://docs.quantum.ibm.com/api/qiskit/0.19/qiskit.providers.ibmq.job.IBMQJob.

alecandido commented 3 months ago

Just blocking within the library is never a great option, but sometimes you might want to return a handle that will execute in the same script, whenever it's ready, without blocking other possible actions.

The way to do this is to use an async primitive: https://docs.python.org/3/library/asyncio.html

Then, identifying jobs with a token, and being able to fetch results even in a separate script is a good idea as well (because the client might crash for whatever reason, but if you dispatched an expensive calculation you might still want to be able to retrieve the result).

marcorossi5 commented 2 months ago

For this point, I would like to suggest defining a syntax similar to https://docs.quantum.ibm.com/api/qiskit/0.19/qiskit.providers.ibmq.job.IBMQJob.

If we want to mimic the Qiskit interface, the run_circuit function shouldn't return the result:

https://github.com/qiboteam/qibo-client/blob/2e358efa6568816c1f12ffefc874efe0702ff2ac/src/qibo_client/qibo_client.py#L146-L179

scarrazza commented 2 months ago

Indeed, it should return a job object. Could you please elaborate on a proposal about this?

marcorossi5 commented 2 months ago

I'm implementing something like the following

client: QiboClient = Client(token, url="http://localhost:8011/")
job: QiboJob= client.run_circuit(circuit, nshots=100, device="sim")
result: QiboJobResult = job.result()
print(result)

The job object is similar to this: https://docs.quantum.ibm.com/api/qiskit/0.19/qiskit.providers.ibmq.job.IBMQJob

At the moment I've thought about the following methods for the QiboJob class:

It will be available in a commit of the PR soon