hsml.deployment_schema #
DeploymentSchema #
The request and response contract of a deployment.
Serving keys, passed features, and request parameters are required in every request; extra logging features are optional. columns gives the positional order for list rows. Types are feature store offline types (bigint, string, array<double>, ...); see to_json_schema() for the JSON encoding each one accepts.
Example
# a custom predictor script with an explicit contract
schema = DeploymentSchema(
serving_keys=[{"name": "cc_num", "type": "bigint", "nullable": False}],
passed_features=[{"name": "amount", "type": "double"}],
)
deployment = model.deploy(script_file="predictor.py", schema=schema)
deployment.schema.validate_instances([{"cc_num": 1, "amount": "x"}]) # -> errors
print(deployment.schema.to_openapi()["paths"])
columns property #
columns: list[SchemaField]
All fields in positional order: serving keys, passed features, request parameters, extra logging features.
extra_logging_features property #
extra_logging_features: list[SchemaField]
Client-supplied values that are only logged; optional.
feature_view property #
{"name", "version"} of the feature view the schema was inferred from.
inferred property #
inferred: bool
Whether the schema was inferred from the feature view rather than given.
max_batch_rows property #
max_batch_rows: int
Largest batch a request may carry; part of the published contract, so changing it changes the schema id.
output property #
Response contract: {"kind": "predictions" | "feature_vectors", "columns": [...] | None}.
passed_features property #
passed_features: list[SchemaField]
Feature view features whose values the client provides; required.
request_parameters property #
request_parameters: list[SchemaField]
Parameters of on-demand transformations; required.
serving_keys property #
serving_keys: list[SchemaField]
Fields identifying the entity to look up; required and non-null.
training_dataset_version property #
training_dataset_version: int | None
Training dataset version whose statistics the deployment uses.
unresolved property #
Names whose type is unknown and therefore not validated.
rows #
split_row #
to_json_schema #
to_openapi #
Render an OpenAPI 3.1 document for the deployment's :predict endpoint.
| PARAMETER | DESCRIPTION |
|---|---|
name | Deployment name. TYPE: |
url | Full inference URL when known; otherwise the path is rendered relative to the server the client already uses. TYPE: |
max_rows | Largest accepted batch; defaults to TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any] | The OpenAPI document as a dict. |
validate_instance #
Validate one request row.
| PARAMETER | DESCRIPTION |
|---|---|
instance | A row as an object keyed by field name or an array in TYPE: |
row | Index of the row in its batch, reported in the errors. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]] | The errors found, each |
validate_instances #
Validate a batch of rows.
Rows must all be objects or all be arrays.
| PARAMETER | DESCRIPTION |
|---|---|
instances | The rows of a request. TYPE: |
max_rows | Largest accepted batch; defaults to TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]] | All errors found across the batch; empty when the batch is valid. |
DeploymentSchemaError #
Bases: ModelServingException
A request does not match a deployment schema. errors lists {"row", "field", "reason"}.
SchemaField #
One field of a deployment schema: a name, an optional feature store type, and nullability.
A None type means the type could not be resolved (request parameters of on-demand transformations); such fields are not type-checked.