Creating registered model versions with custom pip packages

Often your team may develop internal code utilities, or even models, that are packaged as pip packages and you may want to use these custom pip packages in your model code.

This functionality is supported out-of-the-box so long as Verta has access to the repository hosting these pip packages (e.g., private PyPi index or Artifactory).

To use the custom package, you simply need to define your model class using VertaModelBase and ensure that you specify the custom package in your requirements. The code snippet below shows an example.

from verta.registry import VertaModelBase
import my_custom_pip_pkg

class MyModel(VertaModelBase):
    def __init__(self, artifacts):
        self.model = my_custom_pip_pkg.MyModelClass()

    def predict(self, data):
        return self.model.function_equivalent_to_predict(data)
from verta.environment import Python

model_version = registered_model.create_standard_model(
    model_cls=MyModel,
    requirements=Python(requirements=["my_custom_pip_pkg"])
)

Last updated