Leo Chen
05/07/2024, 4:29 PMbentoml.exceptions.NotFound: no Models with name 'tennis-predictor' exist in BentoML store <osfs '/home/bentoml/bento/models'>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/_bentoml_sdk/service/factory.py", line 230, in __call__
instance = self.inner()
File "/home/bentoml/bento/src/service.py", line 16, in __init__
self.model: bentoml.Model = bentoml.models.get("tennis-predictor:latest")
File "/usr/local/lib/python3.10/site-packages/simple_di/__init__.py", line 139, in _
return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
File "/usr/local/lib/python3.10/site-packages/bentoml/models.py", line 45, in get
return _model_store.get(tag)
File "/usr/local/lib/python3.10/site-packages/bentoml/_internal/store.py", line 149, in get
self._recreate_latest(_tag)
File "/usr/local/lib/python3.10/site-packages/bentoml/_internal/store.py", line 120, in _recreate_latest
raise NotFound(
Before I start deployment, the model is saved in the following python code, so Im pretty sure the model is saved in cloud.
model_saved = bentoml.sklearn.save_model("tennis-predictor", rf_classifier)
print(f"Model saved:{model_saved}")
bentoml.models.push("tennis-predictor:latest")
Here is my service.py
import bentoml
import numpy as np
import pandas as pd
@bentoml.service(
resources={"cpu": "2"},
traffic={"timeout": 10},
)
class TennisPrediction:
def __init__(self) -> None:
self.model = bentoml.sklearn.load_model('tennis-predictor:latest')
# self.model: bentoml.Model = bentoml.models.get("tennis-predictor:latest")
@bentoml.api
def tennis_match_prediction(self, odd1: float, odd2: float) -> int:
pre_data = {
'Odd_1': [odd1],
'Odd_2': [odd2],
}
pre_data = pd.DataFrame(pre_data)
predict = self.model.predict(pre_data)[0]
return predict
and my yaml file:
service: "service:TennisPrediction"
labels:
owner: leo
project: gallery
include:
- "*.py"
python:
packages:
- scikit-learn
- pandas
- numpy
Hope someone can help me with this, and I appreciate your amazing works.Jian Shen Yap
05/09/2024, 9:08 AMload_model as a class variable, or manually annotate the model dependencies in the yaml fileLeo Chen
05/09/2024, 12:00 PMError: [bentoml-cli] `deploy` failed: Failed to create deployment due to invalid configuration: request failed with status code 400: {"error":"create modelRepository model: ERROR: duplicate key value violates unique constraint \"uk_model_modelRepositoryId_version\" (SQLSTATE 23505)"}
my model annotation:
models:
- "tennis-predictor:latest"
service.py:
class TennisPrediction:
def __init__(self) -> None:
model = bentoml.sklearn.load_model('tennis-predictor:latest')Jian Shen Yap
05/09/2024, 12:02 PMLeo Chen
05/09/2024, 12:03 PMJian Shen Yap
05/09/2024, 12:05 PMLeo Chen
05/09/2024, 12:08 PMJian Shen Yap
05/09/2024, 12:08 PMJian Shen Yap
05/09/2024, 12:09 PMError: [bentoml-cli] `deploy` failed: Failed to create deployment due to invalid configuration: request failed with status code 400: {"error":"create modelRepository model: ERROR: duplicate key value violates unique constraint \"uk_model_modelRepositoryId_version\" (SQLSTATE 23505)"}Leo Chen
05/09/2024, 12:10 PMbentoml deploy .Jian Shen Yap
05/09/2024, 12:12 PMLeo Chen
05/09/2024, 12:16 PMLeo Chen
05/09/2024, 12:21 PMJian Shen Yap
05/09/2024, 12:23 PMshould i save another model on remote?You shouldn't need to! The
deploy command will check if the model exist, if not then upload from the local.
the service will load the model from BentoCloud instead of local,This will tell BentoCloud to pull the model into the Deployment, so that
bentoml.load can find the modelLeo Chen
05/09/2024, 12:25 PMError: [bentoml-cli] `deploy` failed: Failed to create deployment due to invalid configuration: request failed with status code 400: {"error":"create modelRepository model: ERROR: duplicate key value violates unique constraint \"uk_model_modelRepositoryId_version\" (SQLSTATE 23505)"}Jian Shen Yap
05/09/2024, 12:31 PMLeo Chen
05/09/2024, 12:33 PMJian Shen Yap
05/09/2024, 12:59 PMLeo Chen
05/09/2024, 1:04 PMJian Shen Yap
05/09/2024, 1:05 PMmodels:
- "tennis-predictor:latest"^ this should solve the problem but i believe we have a bug in the pipeline. will let you know once its fixed!
Leo Chen
05/09/2024, 1:09 PMservice: "service:TennisPrediction"
labels:
owner: leo
project: gallery
include:
- "*.py"
models:
- "tennis-predictor:latest"
python:
packages:
- scikit-learn
- pandas
- numpyJian Shen Yap
05/09/2024, 1:09 PMNuwan
06/07/2024, 6:46 AMJian Shen Yap
06/07/2024, 6:54 AMNuwan
06/07/2024, 6:55 AMNuwan
06/07/2024, 6:56 AMbentoml.exceptions.BentoMLException: Failed to create deployment due to invalid configuration: request failed with status code 400: {"error":"create modelRepository model: ERROR: duplicate key value violates unique constraint \"uk_model_modelRepositoryId_version\" (SQLSTATE 23505)"}Nuwan
06/07/2024, 7:01 AM