pixano_inference.models.capabilities
The capabilities served over HTTP, each described once.
A capability ties together a model base class, the Input/Output types of its predict,
the request and response of its route, its default timeout and, when it accepts raw uploads, the
multipart field of its /binary route. :data:CAPABILITIES is the single place where that is
declared: the routes, the capability lookup of a model class and the default timeouts are derived
from it. Adding a capability means adding one entry here (plus its base class and schemas).
BinaryUpload(file_field, payload_key)
dataclass
Multipart upload accepted by the /binary route of a capability.
Attributes:
| Name | Type | Description |
|---|---|---|
file_field |
str
|
Name of the multipart part(s) carrying the raw media. |
payload_key |
str
|
Field of the request model that receives the uploaded bytes. |
CapabilitySpec(model_base, input_type, output_type, request_type, response_type, default_timeout_s=60.0, binary=None)
dataclass
Everything the server needs to know about one capability.
Attributes:
| Name | Type | Description |
|---|---|---|
model_base |
type[InferenceModel]
|
Base class a model subclasses to implement the capability. Its
|
input_type |
type[BaseModel]
|
Type |
output_type |
type[BaseModel]
|
Type |
request_type |
type[BaseRequest]
|
Body of the route; it exposes |
response_type |
type[BaseResponse]
|
Response envelope of the route, whose |
default_timeout_s |
float
|
Inference timeout when the deployment does not set one. |
binary |
BinaryUpload | None
|
Upload accepted by the |
name
property
Name of the capability: the route segment and the value stored in deployment configs.
__post_init__()
Reject a base class that does not name its capability.
capability_of(model_cls)
Return the capability a model class implements.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the class subclasses none of the capability base classes. |
Source code in pixano_inference/models/capabilities.py
find_capability(name)
Return the capability called name, or None if there is no such capability.
get_capability(name)
Return the capability called name.
Raises:
| Type | Description |
|---|---|
KeyError
|
If there is no such capability. |