This message was deleted.
# ask-for-help
s
This message was deleted.
t
I saw that on tree structure
a
Hi there, can you run the following
Copy code
docker run -it --rm -p 3000:3000 container:tag bash

cd /home/bentoml/bento/ && ls -rthla
t
Hey @Aaron Pham I did what you suggest and I notice that the models folder is empty
What should I do in order to copy the models to filesystem?
BTW. With your tip, I could see that.
The point is, the model was really not there 😛 However I was expecting that it should be there, since I did the
bentoml build
command. To solve that, I did a manual copy from my filesystem moving the model folder to a bentos folder. Thenk I ran the containerize command and then I worked for me. Thanks @Aaron Pham
a
Ugh this seems like a bug on our end. Can u send me ur service definition code here?
t
Ok. The code is note that clear, and is missing some imports, but the core is this:
import bentoml
from bentoml._<http://internal.io|internal.io>_descriptors import NumpyNdarray
import mlflow
import json
import pickle
import pandas as pd
import numpy as np
from sklearn import svm
from sklearn.manifold import LocallyLinearEmbedding
from sklearn.model_selection import train_test_split
from <http://bentoml.io|bentoml.io> import JSON
from pydantic import BaseModel, ValidationError, validator
from validation import ModelFeatures
from artifacts_load  import load_param, load_encoder
from data_preprocess  import _zscore, create_model_input_dataframe
from cashout_runnable  import CashoutRunnable
bento_model = bentoml.mlflow.get('allow_list:latest')
artifacts_path = bento_model.path_of(bentoml.mlflow.MLFLOW_MODEL_FOLDER)
bento_model_runner=<http://bento_model.to|bento_model.to>_runner()
cashout_model = mlflow.xgboost.load_model(artifacts_path)
cashout_runner = bentoml.Runner(
runnable_class=CashoutRunnable,
runnable_init_params=dict({'cashout_model': cashout_model}),
name="cashout_runner")
svc = bentoml.Service('allow_list', runners=[cashout_runner])
current_city_encoder = load_encoder('current_city_encoder.pickle', artifacts_path)
device_status_encoder = load_encoder('device_status_encoder.pickle', artifacts_path)
device_type_encoder = load_encoder('device_type_encoder.pickle', artifacts_path)
operation_type_encoder = load_encoder('operation_type_encoder.pickle', artifacts_path)
owner_type_encoder = load_encoder('owner_type_encoder.pickle', artifacts_path)
json_params = load_param('base_params.json', artifacts_path)
@svc.api(input=JSON(pydantic_model=ModelFeatures), output=JSON())
def classify(input_series: ModelFeatures) -> json:
df_parsed = create_model_input_dataframe(input_series.dict(),  current_city_encoder,device_status_encoder,device_type_encoder,operation_type_encoder,owner_type_encoder,json_params)
df_to_model = df_parsed[json_params["training"]["features"]]
df_to_model = df_to_model.astype({'account_amount_zscore':'float', 'account_amount_zscore_robust':'float', 'account_daily_amount_zscore':'float', 'account_daily_amount_zscore_robust':'float', 'account_daily_n_transactions_zscore':'float', 'account_daily_n_transactions_zscore_robust':'float'})
# result = cashout_model.predict_proba(df_to_model) # No runner
# result = bento_model_runner.predict.run(df_to_model)   # With runner
result = cashout_runner.predict_proba.run(df_to_model) # Custom runner
return {'RESULT':result}