""

train_dataloader, test_dataloader = importer()model = trainer(train_dataloader)

accuracy = evaluator(test_dataloader=test_dataloader, model=model)

bento = bento_builder(model=model)

@pipeline

def local_deploy_pipeline(

bento_loader,

deployer,

):

"""Link all the steps and artifacts together"""

bento = bento_loader()

deployer(deploy_decision=decision, bento=bento)

Predicting with the local deployed model

Once the model has been deployed we can use the BentoML client to send requests to the deployed model. ZenML will automatically create a BentoML client for you and you can use it to send requests to the deployed model by simply calling the service to predict the method and passing the input data and the API function name.

The following example shows how to use the BentoML client to send requests to the deployed model.

@step

def predictor(

inference_data: Dict[str, List],

service: BentoMLDeploymentService,

) -> None:

"""Run an inference request against the BentoML prediction service.

Args:

service: The BentoML service.

data: The data to predict.

"""

service.start(timeout=10)  # should be a NOP if already started

for img, data in inference_data.items():

prediction = service.predict("predict_ndarray", np.array(data))

result = to_labels(prediction[0])

rich_print(f"Prediction for {img} is {result}")

Deploying and testing locally is a great way to get started and test your model. However, a real-world scenario will most likely require you to deploy your model to a remote environment. The next section will show you how to deploy the Bento you built with ZenML pipelines to a cloud environment using the bentoctl CLI.

From Local to Cloud with bentoctl

Bentoctl helps deploy any machine learning models as production-ready API endpoints into the cloud. It is a command line tool that provides a simple interface to manage your BentoML bundles.

The bentoctl CLI provides a list of operators which are plugins that interact with cloud services, some of these operators are:

AWS Lambda