Skip to content

Wait until finished

Keep checking a job once a minute, and print a line each time its status changes. It stops by itself when the job finishes.

wait_for_job.py

# wait_for_job.py - follow a job until it finishes
#   usage: python wait_for_job.py <job id>
import os
import sys
import time
from centific import PhysicalAI

client = PhysicalAI(
    api_key  = os.environ["CENTIFIC_API_KEY"],
    base_url = "https://humanoidiq-dev.centific.com",
)

job = client.qc.get(sys.argv[1])
last = None
while True:
    if job.status != last:
        last = job.status
        print(time.strftime("%H:%M:%S"), job.status, flush=True)
    if job.done:                          # complete, failed or cancelled
        break
    time.sleep(60)                        # our side moves once a minute
    job.refresh()

print("finished:", job.status, "| reason:", job.reason or "-",
      "| verdict:", job.verdict or "-")

How to use it

python wait_for_job.py qcjob_yLrQuj9XZ2LxIBbVN6f8S2

Leave the terminal open while it runs.

Press Ctrl+C to stop watching

That only stops this script. The job keeps running on our side.

Sample output

10:02:11 queued
10:03:12 grading
10:41:55 complete
finished: complete | reason: - | verdict: REJECTED

Next: Get the report & PDF