QJob into JobV1 - #27
Open
JooNiv wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
QJob is now a Qiskit JobV1
closes #28
Why
QBackendIQMsubclassesIQMBackend, so consumers treat the return value ofrun()as aqiskit.providers.JobV1.QJobwas a plain class withjob_idas an int attribute andstatus()returning a string. That madejob.job_id()raiseTypeErrorand made everyJobStatusbased poll loop never terminate, silently. It broke e.gfiqci-emsand would breakany other Qiskit facing consumer or package trying to integrate with Qiskit or IQM software stack.
What changed
QJobderives fromJobV1.status()returns aJobStatus, andsubmit()andcancel()were added, so
done(),cancelled(),in_final_state()andwait_for_final_state()allwork.
HEAppE_QISKIT_STATUS_MAPPINGholdsJobStatusmembers now.WAITINGstill maps toRUNNINGrather thanQUEUED, which is left as a separate change.job_idstays an int through a callable int subclass, sojob.job_idis still e.g. int1234forQClientcalls and HEAppE result paths whilejob.job_id()returns e.g. str'1234'for Qiskit.That keeps every existing reader of
job.job_idworking.Cancelling a job used to report
JobStatus.ERROR, with two causes.QClient.get_job_statusfolded
JobState.CanceledintoFAILED, so it now returns a distinctCANCELED, and thefour poll loops stop on
QClient.TERMINAL_JOB_STATESinstead of a local list. That is notenough on its own, because HEAppE reaps a cancelled job as
JobState.Failedand never asCanceled. Socancel()records that HEAppE accepted the request, and_to_qiskit_status()reports
CANCELLEDrather thanERRORwhen it did. A job cancelled out of band stillreports
ERROR, which is documented on the method.backend_service.pycomparedjob.status()againstIQMJobStatus, butIQMJob.status()returns a Qiskit
JobStatus, so that operand was always false and remote failure detectionrested on
not result.successalone. It now compares againstJobStatus.ERROR.Cancel on timeout in
result()andwait_for_final_state()calledself._backend.cancel_job(...), which raisedAttributeErrorafter the firstresult()because
update_from_remotejob()replacesself._backend. Both callself.cancel()now.Verified on VLQ
JobV1job.job_idgives1234andjob.job_id()gives'1234'status()returns the same value before and after the firstresult(), anddone()andin_final_state()are true once results are incancel(), HEAppE reportsJobState.Failedandjob.status()givesJobStatus.CANCELLEDfiqci-emsworks as expected on VLQ (used as an integration test)