Hi there! I am newbie in BentoML. I have a questio...
# ask-for-help
y
Hi there! I am newbie in BentoML. I have a question about how to apply load mlflow-imported model in bentoml service object. First, I successfully loaded trained model by mlflow in bentoml(using
bentoml.mlflow.import_model
(docs) and I checked the trained model in bento-ml model store file system(
/users/zedd/bentoml/models
path) But, I tried to serve the trained model using bento-ml with Service object following tutorial code. my code is below.
Copy code
# main.py
import numpy as np
import bentoml
from bentoml.io import NumpyNdarray

#
path = "/Users/zedd/home-mlops/mlruns/283184337928820717/0d83b6bdeea44e34b74f70f821aa239a/artifacts/iris_model"
# `bentoml._internal.models.model.Model` object
iris_clf_runner = bentoml.mlflow.import_model(
    name="zedd-iris-clf-in-mlflow",
    model_uri=path
)

svc = bentoml.Service(
    name="zedd_iris_classifier",
    runners=[iris_clf_runner]
)

def preprocessing(x: np.ndarray) -> np.ndarray:
    return x 

def postprocessing(y: np.ndarray) -> np.ndarray:
    return y

@svc.api(input=NumpyNdarray(), output=NumpyNdarray())
def predict(input_arr: np.ndarray) -> np.ndarray:
    # preprocess
    x = preprocessing(input_arr)

    # inference
    y = iris_clf_runner.predict(x)

    # postprocessing 
    result = postprocessing(y)

    return result
Next, I enter the command on terminal;
bentoml serve main:svc
and I got this error.
AssertionError: Service runners list can only contain bentoml.Runner instances, type "<class 'bentoml._internal.models.model.Model'>" found.
How to fix this problem? What the best practice making bento-ml serving api with mlflow-trained model? I looking forward to replying anyone's reply. Thanks.
✅ 1
Oh. I got it. after questioning chat-gpt, I solved it. the answer is below. : converting it to
runner
class using
to_runner()
function of
bentoml._internal.models.model.Model
object
🙌 1