shanto268's picture
SQuADDS ML API 2: squadds 53ec2b11, registry 1dbf099a
55ce00a verified
Raw History Blame Contribute Delete
1.04 kB
"""The adapter protocol (duck-typed; tests/test_registry.py enforces it).
class Adapter:
input_kind: "json" | "file" json: inputs is an object (or a list when batch = True); file: one uploaded file + inputs
InputModel: pydantic model request schema of `inputs` (drives /docs, validation and the tool schema)
OptionsModel: pydantic model optional, schema of `options`
batch: bool optional, inputs may be a list of objects
def __init__(self, model_id, root, config, limits) root = verified local weights
def describe(self) -> dict merged into GET /v1/models/{id}
def predict(self, inputs, file=None, options=None) -> {"outputs": {...}, "metadata": {...}, "timing_s": {...}}
def warm(self, example: Path) -> None optional
predict validates its own raw inputs: pydantic.ValidationError -> 422, ValueError -> 400, a ValueError with
`too_large = True` -> 413, anything else -> 500.
"""
REQUIRED = ("input_kind", "describe", "predict")