pixano_inference.ray.app
DeploymentManager and FastAPI app factory for Ray Serve.
BodySizeLimitMiddleware(app, max_body_bytes)
Bases: BaseHTTPMiddleware
Reject requests whose body exceeds a configured maximum, before reading it.
Source code in pixano_inference/ray/app.py
dispatch(request, call_next)
async
Return 413 when the declared Content-Length exceeds the configured maximum.
Source code in pixano_inference/ray/app.py
DeploymentManager(config)
In-process manager for Ray Serve model deployments and async tracking jobs.
Each model runs as its own Serve application (serve.run(app, name=..., route_prefix=None)).
Handles are obtained lazily via serve.get_app_handle and inference is dispatched
through the native async DeploymentResponse. Deployment/config state is process-local;
Serve owns replica supervision, autoscaling, and batching. Async jobs are delegated to a
:class:~pixano_inference.jobs.JobManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RayServeConfig
|
Ray Serve configuration. |
required |
Source code in pixano_inference/ray/app.py
config
property
Server configuration.
cancel_tracking_job(job_id)
deploy_model(config)
Deploy a model as its own Ray Serve application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ModelDeploymentConfig
|
Model deployment configuration. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the model is already deployed or resources are insufficient. |
KeyError
|
If the model class is not registered. |
RuntimeError
|
If the Serve deployment fails to become healthy. |
Source code in pixano_inference/ray/app.py
get_gpu_info()
Get GPU resource information from Ray.
Source code in pixano_inference/ray/app.py
get_handle(name)
Get a Serve deployment handle by model name (cached), or None if not deployed.
Source code in pixano_inference/ray/app.py
get_model_capability(name)
get_model_metadata(name)
Get metadata for a deployed model.
Source code in pixano_inference/ray/app.py
get_timeout(name, capability)
Resolve the inference timeout for a model, honoring a per-model override.
Source code in pixano_inference/ray/app.py
get_tracking_job(job_id)
list_models()
List all deployed models.
Source code in pixano_inference/ray/app.py
model_statuses()
Return {model_name: Serve status string} for all configured models.
Source code in pixano_inference/ray/app.py
num_nodes()
Number of alive Ray nodes, or 1 when Ray is not initialized.
readiness()
Report readiness: every configured model must be RUNNING.
Source code in pixano_inference/ray/app.py
submit_tracking_job(model_name, input_data)
Submit a tracking request as an asynchronous job over the Serve handle.
Source code in pixano_inference/ray/app.py
undeploy_model(name)
Undeploy a model: delete its Serve app (freeing GPU via replica cleanup).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Model name. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the model is not deployed. |
Source code in pixano_inference/ray/app.py
create_ray_serve_app(config=None)
Create the FastAPI application and DeploymentManager for Ray Serve.
The returned app carries a lifespan that starts Ray + Serve and deploys startup models
on startup, and drains Serve + Ray on shutdown. The lifespan runs when the app is served
(or under with TestClient(app)), not on bare construction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RayServeConfig | None
|
Ray Serve configuration. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[FastAPI, DeploymentManager]
|
Tuple of (FastAPI app, DeploymentManager). |
Source code in pixano_inference/ray/app.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |