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, should_abort=None)
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 |
should_abort
|
Callable[[], bool] | None
|
Optional predicate polled while waiting on Ray; when it returns True
the wait is cut short (see :func: |
None
|
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. |
StartupAborted
|
If shutdown was requested while waiting for the deployment. |
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_interface(name)
How a deployed model is called, as fetched when it was deployed (None if unknown).
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
StartupAborted
Bases: RuntimeError
Raised when startup is cut short because shutdown was requested (Ctrl-C / SIGTERM).
create_ray_serve_app(config=None, should_abort=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
|
should_abort
|
Callable[[], bool] | None
|
Optional predicate polled during startup; when it returns True, startup is
cut short. :class: |
None
|
Returns:
| Type | Description |
|---|---|
tuple[FastAPI, DeploymentManager]
|
Tuple of (FastAPI app, DeploymentManager). |
Source code in pixano_inference/ray/app.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |