qiskit-ibm-runtime icon indicating copy to clipboard operation
qiskit-ibm-runtime copied to clipboard

get status of list of jobs

Open aeddins-ibm opened this issue 1 year ago • 4 comments

It could be useful to programmatically check the status of a known list of pending jobs to monitor for errors. But currently on my laptop it's taking about ~5 seconds to run job.status() for a single job. That delay is tolerable but not ideal.

Can we add something like QiskitRuntimeService.status() that takes a list of jobids (or jobs, either would be fine) and with a single API call gets all the job statuses? Hoping that would be more efficient than fetching each status individually.

aeddins-ibm avatar Jul 28 '23 15:07 aeddins-ibm

Would something like this work?

jobs = service.jobs(pending=True)

for job in jobs:
    print(job.job_id(), job.status())

kt474 avatar Aug 01 '23 20:08 kt474

Thanks for the suggestion. As-is that would not quite detect if a job has errored, since errored jobs would not have pending=True.

We could change it to pending=False, but that would be a gigantic number of jobs, assuming it's since the beginning of time, which might take a while to load (?).

So maybe we can also provide the time that the first job in our list was submitted:

jobs = service.jobs(pending=False, created_after = time_first_job_submitted)

And then filter those results against our list of desired jobs:

jobs = [j for j in jobs if j.job_id() in desired_job_ids and j.status() == 'ERROR']

This will probably work for me for now. But if possible it would still be helpful to be able to get the status of a list of job_ids (or just to fetch all jobs based on a list of job ids). It's less convenient to have to get many jobs and then filter locally, which in this case includes figuring out the format/timezone of the created_after argument. (It looks like it wants something in "local time", whereas the creation_time attribute of RuntimeJob is in UTC).

aeddins-ibm avatar Aug 04 '23 20:08 aeddins-ibm

Err actually, maybe I was confused above. I'm not sure how the API works, but the original problem is that calling job.status() was slow. So it's not a problem of fetching jobs, just calling status for more than one job at once. My impression is that even if the job is fetched using service.jobs(...), we would still have to call job.status() for each individual job and wait for that to slowly process?

If that's correct, then it seems like the ideal solution would be a single call that gets the status of all jobs in the list, if that's not too complicated to implement.

aeddins-ibm avatar Aug 05 '23 23:08 aeddins-ibm

I'm not sure but maybe IQP has a way to return status of a bunch of jobs, since they need to do that for the web UI.

jyu00 avatar May 22 '24 17:05 jyu00