Skip to content

Polling for Status

After submitting a job, poll GET /ordo/jobs/:id until the job reaches a terminal state.

Job status machine

pending → running → success
                 → failed
                 → partial
  • pending — job created, no steps have started
  • running — at least one step is running or complete
  • success — all steps completed successfully
  • failed — at least one step failed and the job is considered failed
  • partial — some steps succeeded, some failed (partial completion)

Step status machine

pending → running → success
                 → failed
                 → skipped

skipped means the step could not run because a dependency failed.

Polling example (JavaScript)

js
async function pollJob(id, token, onUpdate) {
  const res = await fetch(`/ordo/jobs/${id}`, {
    headers: { Authorization: `Bearer ${token}` },
  });
  const data = await res.json();

  // Progress based on completed steps
  const done = data.steps.filter(s =>
    ['success', 'failed', 'skipped'].includes(s.status)
  ).length;
  const pct = data.steps.length > 0 ? done / data.steps.length : 0;

  onUpdate({
    status: data.job.status,      // 'pending' | 'running' | 'success' | 'failed'
    progress: pct,                // 0.0 – 1.0
    steps: data.steps,
  });

  const terminal = ['success', 'failed', 'partial'];
  if (!terminal.includes(data.job.status)) {
    setTimeout(() => pollJob(id, token, onUpdate), 3000);
  }
}

Response structure summary

json
{
  "job": {
    "id": 3,
    "status": "success",
    "created_at": "...",
    "started_at": "...",
    "finished_at": "...",
    "error": null
  },
  "progress": {
    "percentage": 1,
    "completed_steps": 2,
    "total_steps": 2
  },
  "duration_ms": 135401,
  "steps": [
    {
      "step_id": "reproject",
      "step_type": "REPROJECT_LAS",
      "status": "success",
      "started_at": "...",
      "finished_at": "...",
      "error": null
    }
  ],
  "outputs": [
    {
      "artifact_name": "step:build_ept.output_ept",
      "path": "development/results/piney-dam/ept"
    }
  ]
}

Poll every 3–5 seconds. Most steps take tens of seconds to minutes depending on dataset size. Very large EPT builds may take longer.

Error handling

If job.status is failed, check job.error for a top-level message and inspect individual steps for error fields on failed steps.