sk_serve package

Submodules

sk_serve.api module

class sk_serve.api.SimpleAPI(pipeline_path: str, model_path: str, validation_model: BaseModel | None = None)[source]

Bases: object

Simple API class that takes pipeline and model paths as arguments and defines one inference endpoint for simple model deployment. Both loaded object must be Scikit-learn objects. 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.

inference(inf_data: dict)[source]

Inference method that is used by the inference endpoint. In order to get the prediction two checks are made beforehand: check if the pipeline is a sklearn.compose.ColumnTransformer object & if the model loaded has predict method.

Args:

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

Raises:

RuntimeError: If the model loaded doesn’t have predict method.

Returns:

dict: The prediction.

sk_serve.serve module

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.