pixano_inference.jobs
In-process async job manager for long-running inference (e.g. video tracking).
A job wraps a Ray Serve DeploymentResponse in an asyncio task, so status can be polled
without ever blocking the event loop on ray.get. The store is bounded: terminal jobs
are evicted past a TTL and when a size cap is exceeded. State is process-local and lost on
restart (the computation lives in Serve replicas the server manages), which is appropriate
for a single-node deployment.
JobManager(max_jobs=DEFAULT_MAX_JOBS, ttl_s=DEFAULT_TTL_S)
Bounded, in-process manager of asynchronous jobs over Serve responses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_jobs
|
int
|
Maximum number of retained jobs before terminal jobs are evicted. |
DEFAULT_MAX_JOBS
|
ttl_s
|
float
|
Time-to-live for terminal jobs before eviction. |
DEFAULT_TTL_S
|
Source code in pixano_inference/jobs.py
count
property
Number of retained jobs.
cancel(job_id)
Cancel a job on a best-effort basis.
Source code in pixano_inference/jobs.py
cancel_all()
cancel_for_model(model_name, detail='Model undeployed.')
Cancel all non-terminal jobs belonging to a model.
Source code in pixano_inference/jobs.py
evict_now()
get(job_id)
submit(response, *, model_name, metadata=None)
Register a job for a Serve response and start awaiting it.
Must be called from within a running event loop (i.e. an async route handler).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
A Serve |
required |
model_name
|
str
|
Name of the model handling the job. |
required |
metadata
|
dict[str, Any] | None
|
Optional metadata echoed back in job status. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The generated job id. |
Source code in pixano_inference/jobs.py
JobRecord(model_name, response=None, task=None, status='running', detail=None, result=None, metadata=dict(), timestamp=_utcnow(), submitted_at_monotonic=time.time(), processing_time=0.0)
dataclass
State for a single asynchronous job.
serialize_job(job_id, job)
Serialize a job record into the camelCase API status shape.