GetJobStatus

get_job_status(public_api_client, job_id)
Expand source code
get_job_status(public_api_client, job_id):
"""
Description
-----------
To get the status of a given job.
Args
----
public_api_client: QDC api client object.
job_id: Id of the job.
Returns
-------
string: State of the job. like completed, canceled etc.
None: In case of any failure.
Usages
------
job_id = "1234"
poll_job_status = qdc_api.get_job_status(public_api_client, job_id)
if poll_job_status.lower() == "completed":
print("Job is completed, exiting client...")
break
elif poll_job_status.lower() == "canceled":
print("Job is canceled, exiting client...")
break
else:
print(f"Job is in {poll_job_status.lower()} mode)
"""
poll_job_response = get_jobs_id.sync_detailed(id=job_id, client=_get_client_with_new_trace_header(public_api_client))
if poll_job_response.status_code == 200:
response_data = poll_job_response.content.decode('utf-8')
print(f"Job response: {response_data}")
return poll_job_response.parsed.state
Description
To get the status of a given job.
Arguments
public_api_client: QDC api client object.
job_id: Id of the job.
Returns
string: State of the job. like completed, canceled etc.
None: In case of any failure.
Usages
job_id = "1234"
poll_job_status = qdc_api.get_job_status(public_api_client, job_id)
if poll_job_status.lower() == "completed":
print("Job is completed, exiting client...")
break
elif poll_job_status.lower() == "canceled":
print("Job is canceled, exiting client...")
break
else:
print(f"Job is in {poll_job_status.lower()} mode)