Verta
Search…
Deploying a pure function
Within Verta, a "Model" can be any arbitrary function: a traditional ML model (e.g., sklearn, PyTorch, TF, etc); a function (e.g., squaring a number, making a DB function etc.); or a mixture of the above (e.g., pre-processing code, a DB call, and then a model application.
This tutorial provides an example of how to deploy any function on Verta.
As mention in the deploying models guide, deploying models via Verta Inference is a two step process: (1) first create an endpoint, and (2) update the endpoint with a model.
This tutorial explains how Verta Inference can be used to deploy a scikit-learn model.

1. Create an endpoint

Users can create an endpoint using Client.create_endpoint() as follows:
1
census_endpoint = client.create_endpoint(path="/census")
Copied!

2. Updating the endpoint with a RMV

To deploy an arbitrary function within Verta, the function must be wrapped into a class that extends VertaModelBase (See this guide).
For example, suppose we have a cubic transform that we want to deploy to Verta. Note that this function could be absolutely anything -- make a database query, call a REST endpoint, use the associated artifacts to do further processing, etc.
1
def cubic_transform(x):
2
return 3*(x**3) + 2*x + 5
3
4
from verta.registry import VertaModelBase
5
class CubicFunction(VertaModelBase):
6
def __init__(self, artifacts=None):
7
pass
8
9
def predict(self, input_data):
10
output_data = []
11
for input_data_point in input_data:
12
output_data_point = cubic_transform(input_data_point)
13
output_data.append(output_data_point)
14
return output_data
15
16
from verta.environment import Python
17
18
model_version = registered_model.create_standard_model(
19
CubicFunction,
20
environment=Python(requirements=[]),
21
name="v1",
22
)
Copied!
Regardless of how a Registered Model Version has been created, the endpoint defined above can now be upated and we can make predictions against it.
1
ccubic_function_endpoint = client.get_or_create_endpoint("cubic")
2
cubic_function_endpoint.update(model_version, wait=True)
3
deployed_model = cubic_function_endpoint.get_deployed_model()
4
deployed_model.predict([3, 0])
Copied!
The full code for this tutorial can be found here.
Last modified 3mo ago