Slackbot
06/08/2023, 6:49 AMAaron Pham
06/08/2023, 6:57 AMSarthak Verma
06/08/2023, 6:57 AMAaron Pham
06/08/2023, 6:59 AMbentoml.sklearn
Currently, we don’t directly support azure ml, but you can always download the artifact locally, then use bentoml.sklearn to save itSarthak Verma
06/08/2023, 7:01 AMAaron Pham
06/08/2023, 7:30 AMbentoml.sklearn
Ashish Singh
06/08/2023, 11:33 AMdef convert_model_to_runner(model: BaseEstimator):
"""Function to convert sklearn model to a bentoml.Runner instance to be used for serving.
Args:
model: Any sklearn model stored locally with serve code.
Types allowed are BaseEstimator
Returns:
Bentoml.Runner instance which can be used to create a service.
Raises:
UnableToConvertModel: When conversion of model to Bentoml.Runner fails
"""
try:
prediction_runner = bentoml.Runner(
ScikitLearnModelRunnable,
name="prediction_runner",
runnable_init_params={"model": model},
)
return cast(ScikitLearnModelRunner, prediction_runner)
except TypeError as error:
logger.error("Could not save model into a bentoml.Runner.", exc_info=True)
raise UnableToConvertModel("Error mapping model to Bentoml.Runner") from error
Ashish Singh
06/08/2023, 11:34 AMdef load_pickle_file(path: str):
"""Function to load pickle file."""
try:
return joblib.load(path)
except (OSError, ValueError, AssertionError) as exception: # invalid pickle raises Assertion
log_error_and_raise_exception(ModelNotFound("Model file not found"), exception)
Ashish Singh
06/08/2023, 11:35 AMconvert_model_to_runner(model),
Ashish Singh
06/08/2023, 11:35 AM