Slackbot
05/16/2023, 1:10 AMJiang
05/16/2023, 2:37 AMBecause of this, each time they use it, it seems like the service has to restart and load all the runners and it takes a long time for them to be able to actually use the endpoint.I don't think it is the default behavior of bentoml. This might be caused by a service.py not in best practice.
Jiang
05/16/2023, 2:48 AMJack Norman
05/16/2023, 3:49 AM# define IO descriptors
# ...
success_probability_input_descriptor = (JSON(pydantic_model=SuccessProbabilityInputDescriptor))
success_probability_output_descriptor = (JSON(pydantic_model=SuccessProbabilityOutputDescriptor))
# ...
# Load Bento Models from Google Cloud Storage; also convert them to Runners
bento_models, runners = load_bentos_from_gcs()
svc = bentoml.Service("probability-models-bento", runners=list(runners.values()))
def success_probability_pipeline(input_data):
# do stuff with input_data
@svc.api(input=success_probability_input_descriptor,
output=success_probability_output_descriptor,
route="success/predict_proba")
def success_predict_proba(
input_data: SuccessProbabilityInputDescriptor) -> SuccessProbabilityOutputDescriptor:
validated_results = success_probability_pipeline(input_data)
return validated_results
# other pipelines ...
Jiang
05/16/2023, 4:41 AMhas to restart and load all the runnersCan you tell me about the relevant phenomenon behind this? And would you like provide the source of
load_bentos_from_gcs
?Jack Norman
05/16/2023, 4:53 AMdef load_bentos_from_gcs(bento_framework_model_names, load_from_gcs=True):
bento_models = {}
runners = {}
for model_tmp in bento_framework_model_names:
model_name_tmp = model_tmp["model_name"]
framework = model_tmp["framework"]
if load_from_gcs:
<http://bentoml_logger.info|bentoml_logger.info>(f"Importing {BUCKET}/{model_name_tmp}.bentomodel from GCS")
try:
bentoml.models.import_model(f"{BUCKET}/{model_name_tmp}.bentomodel")
except (BentoMLException, ImportServiceError) as e:
bentoml_logger.warning(f"The Bento model is already in the store. No harm done, though! "
f"The {e.__class__.__name__} exception caught from Bento was:"
f"\n\n\t'{e}'\n\nProceeding with the rest of the build.")
<http://bentoml_logger.info|bentoml_logger.info>(f"Loading in the {model_name_tmp}:latest model using the {framework} framework.")
if framework == "sklearn":
bento_model = bentoml.sklearn.get(f"{model_name_tmp}:latest")
elif framework == "picklable_model":
bento_model = bentoml.picklable_model.get(f"{model_name_tmp}:latest")
<http://bentoml_logger.info|bentoml_logger.info>("Success.")
<http://bentoml_logger.info|bentoml_logger.info>(f"Converting the model to a runner")
runner = bento_model.to_runner()
bento_models[model_name_tmp] = bento_model
runners[model_name_tmp] = runner
return bento_models, runners
Jack Norman
05/16/2023, 5:27 AMJiang
05/16/2023, 5:35 AMJiang
05/16/2023, 5:40 AMJiang
05/16/2023, 5:42 AMJack Norman
05/16/2023, 3:34 PMJack Norman
05/16/2023, 5:48 PMgcloud beta run services update SERVICE-NAME --no-cpu-throttling
. This made a Revision deployment. That’s fine, but now when I try to deploy using bentoctl, it gives me the error
Error 409: Revision named 'probability-models-bento-cloud-run-service-00023-pud' with different configuration already exists.
How can I either pull the configuration or update the bentoctl commands to include the --no-cpu-throttling flag?Jiang
05/17/2023, 9:32 AMJiang
05/17/2023, 9:40 AMIs it an easy transition from Cloud Run to BentoCloud?Yeah it is much easier since you will only need your bento to use BentoCloud, and you already have one.
Jiang
05/17/2023, 9:54 AM--no-throttle
, and then recreate it through terraform.