fastapi_mlflow/predictors.py
def build_predictor(model: PyFuncModel) -> Callable[[List[BaseModel]], Any]:
    """Build and return a function that wraps the mlflow model.

    Currently supports only the `pyfunc`_ flavour of mlflow.

    :param model: PyFuncModel
    :return: Function suitable for mounting as a FastAPI endpoint or route.

    Example::

        model = load_model("/Users/me/path/to/local/model")
        predictor = build_predictor(model)

    .. _pyfunc: https://www.mlflow.org/docs/latest/python_api/mlflow.pyfunc.html

    """
    request_type: Any = _mlflow_types.build_input_model(
        model.metadata.get_input_schema()
    )
    return_type: Any = _mlflow_types.build_output_model(
        model.metadata.get_output_schema()
    )

    def predictor(request: List[request_type]) -> List[return_type]:
        df = pd.DataFrame([row.dict() for row in request], dtype=object)
        return [return_type(prediction=row) for row in model.predict(df)]

    return predictor
Build and return a function that wraps the mlflow model.

    Currently supports only the `pyfunc`_ flavour of mlflow.

    :param model: PyFuncModel
    :return: Function suitable for mounting as a FastAPI endpoint or route.

    Example::

        model = load_model("/Users/me/path/to/local/model")
        predictor = build_predictor(model)

    .. _pyfunc: https://www.mlflow.org/docs/latest/python_api/mlflow.pyfunc.html

    
Build and return a function that wraps the mlflow model.
Currently supports only the `pyfunc`_ flavour of mlflow.
Build and return a function that wraps the mlflow model . Currently supports only the ` pyfunc ` _ flavour of mlflow .
def build_predictor(model: PyFuncModel) -> Callable[[List[BaseModel]], Any]:
    request_type: Any = _mlflow_types.build_input_model(
        model.metadata.get_input_schema()
    )
    return_type: Any = _mlflow_types.build_output_model(
        model.metadata.get_output_schema()
    )
    def predictor(request: List[request_type]) -> List[return_type]:
        df = pd.DataFrame([row.dict() for row in request], dtype=object)
        return [return_type(prediction=row) for row in model.predict(df)]
    return predictor
def build_predictor ( model : PyFuncModel ) -> Callable [ [ List [ BaseModel ] ] , Any ] : request_type : Any = _mlflow_types . build_input_model ( model . metadata . get_input_schema ( ) ) return_type : Any = _mlflow_types . build_output_model ( model . metadata . get_output_schema ( ) ) def predictor ( request : List [ request_type ] ) -> List [ return_type ] : df = pd . DataFrame ( [ row . dict ( ) for row in request ] , dtype = object ) return [ return_type ( prediction = row ) for row in model . predict ( df ) ] return predictor
Build and return a function that wraps the mlflow model.
Build and return a function that wraps the mlflow model .
"""Build and return a function that wraps the mlflow model.

    Currently supports only the `pyfunc`_ flavour of mlflow.

    :param model: PyFuncModel
    :return: Function suitable for mounting as a FastAPI endpoint or route.

    Example::

        model = load_model("/Users/me/path/to/local/model")
        predictor = build_predictor(model)

    .. _pyfunc: https://www.mlflow.org/docs/latest/python_api/mlflow.pyfunc.html

    """
Function suitable for mounting as a FastAPI endpoint or route.
Example:.




Function suitable for mounting as a FastAPI endpoint or route . Example : .
model
PyFuncModel
None