sk_serve package

Submodules

sk_serve.api module

class sk_serve.api.SimpleAPI(validation_model: type[BaseModel] | None = None)[source]

Bases: object

Simple API class that takes pipeline/model path as arguments and defines one inference endpoint for simple model deployment. The pipeline must be a Scikit-Learn Pipeline. It can also take a pydantic validation model as input in order to validate the input everytime inference is requested.

static home() Dict[str, str][source]

Method that returns a message when sending a GET request to the / endpoint.

async inference(request: Request)[source]

Inference method that is used by the inference endpoint. In order to get the prediction the deployed pipeline must have the predict method.

Args:

request (Request): Input data for inference. Currently only one data point at a time is supported.

Returns:

dict: The prediction.

sk_serve.api.check_model_methods(model, method: str)[source]

Helper function that checks if a class method exits or not.

Args:

model: A Scikit-learn model. method (str): The name of the respective method.

sk_serve.serve module

sk_serve.serve.lifespan(app: FastAPI)[source]
sk_serve.serve.serve(simple_api: SimpleAPI)[source]

Function that constructs the model API.

Args:

simple_api (SimpleAPI): The SimpleAPI object needed for deployment.

Returns:

app (FastAPI): The FastAPI application.