Skip to main content

Job Submission

Submit and manage Ray jobs on local or remote clusters. Jobs run Python entrypoints on the cluster's Ray runtime and can return structured results via a log marker protocol.

Prerequisites​

  • Admin authentication (JWT token with admin role)
  • Ray cluster running on the target cluster

Submit a Job (Async)​

curl -sk -X POST "https://kamiwaza.test/api/cluster/jobs/submit" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entrypoint": "python train.py --epochs 10",
"runtime_env": {"pip": ["numpy", "pandas"]},
"timeout_seconds": 300
}'

Response:

{"job_id": "uuid", "ray_job_id": "raysubmit_...", "status": "PENDING"}

Run a Job (Synchronous)​

Submits and blocks until completion, returning the extracted result:

curl -sk -X POST "https://kamiwaza.test/api/cluster/jobs/run" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entrypoint": "python inference.py",
"timeout_seconds": 60
}'

Response:

{
"job_id": "uuid",
"ray_job_id": "raysubmit_...",
"status": "SUCCEEDED",
"result": {"accuracy": 0.95},
"duration_seconds": 12.3
}

Check Job Status​

curl -sk "https://kamiwaza.test/api/cluster/jobs/{job_id}/status" \
-H "Authorization: Bearer $TOKEN"

Returns the full job record including status, timestamps, and error details if failed.

Get Job Logs​

curl -sk "https://kamiwaza.test/api/cluster/jobs/{job_id}/logs" \
-H "Authorization: Bearer $TOKEN"

Returns Ray stdout/stderr for the job.

Extract Job Result​

curl -sk "https://kamiwaza.test/api/cluster/jobs/{job_id}/result" \
-H "Authorization: Bearer $TOKEN"

Extracts structured JSON from the job's stdout. The job code must print a result marker:

import json
result = {"accuracy": 0.95, "model": "v2"}
print(f"KZ_MESH_RUN_ON_JSON::{json.dumps(result)}")
Status CodeMeaning
200Result extracted successfully
409Job has not succeeded yet
410Ray logs expired (result no longer available)

Cancel a Job​

curl -sk -X POST "https://kamiwaza.test/api/cluster/jobs/{job_id}/cancel" \
-H "Authorization: Bearer $TOKEN"

Requests cancellation of a running job. The job transitions to STOPPED status.

Job Lifecycle​

StatusDescription
PENDINGSubmitted to Ray, not yet running
RUNNINGExecuting on Ray cluster
SUCCEEDEDCompleted successfully
FAILEDExited with error
STOPPEDCancelled by user or timed out

Timeout and Auto-Cancel​

Set timeout_seconds on submission. If the job exceeds this duration during a /run call, it is automatically cancelled and marked with timed_out: true.

API Reference​

MethodPathDescription
POST/cluster/jobs/submitAsync submission
POST/cluster/jobs/runSync submit + poll + result
GET/cluster/jobs/{id}/statusJob status with Ray refresh
GET/cluster/jobs/{id}/resultExtract structured result
GET/cluster/jobs/{id}/logsRay stdout/stderr
POST/cluster/jobs/{id}/cancelCancel running job