Model Registry

Registered models are generic containers that group multiple versions of models which can be deployed, used as a challenger model, or replace a deployed model. Each registered model can have multiple versions. Each version can be created from a DataRobot model, custom model, or external model. Registered models can have versions of different types (leaderboard, custom, or external) simultaneously as long as they have same target properties and time series settings where applicable.

Create registered model & version

The following command can be used to either create a registered model from or add version to the existing model.

LEADERBOARD_MODEL_ID = "650c2372c538ffa4480567d1"
first_version = dr.RegisteredModelVersion.create_for_leaderboard_item(
    model_id=LEADERBOARD_MODEL_ID,
    name="Name of the version(aka model package)",
    registered_model_name='DEMO 3: Name of the registered model unique across the org '
)
# add custom model as a version
CUSTOM_MODEL_VERSION_ID = "619679c86c1abbc2bd628ed1"
second_version_from_custom = dr.RegisteredModelVersion.create_for_custom_model_version(
    custom_model_version_id=first_version.registered_model_id,
    name="Another Name of the version(aka model package)",
)

# add external model as a version
second_version_from_external = dr.RegisteredModelVersion.create_for_external(
    name='Another name',
    target={'name': 'Target', 'type': 'Regression'},
    registered_model_id=first_version.registered_model_id,
)

List and filter registered models

Use the following command to list registered models.

You can filter the registered models that are returned by passing an instance of the RegisteredModelListFilters class to the filters keyword argument.

You can also filter the registered model versions that are returned by passing an instance of the RegisteredModelVersionsListFilters class to the filters keyword argument.

demo_registered_models = dr.RegisteredModel.list(search="DEMO")
registered_model_filters = dr.models.model_registry.RegisteredModelListFilters(
    created_at_start=datetime.datetime(2020, 1, 1),
    created_at_end=datetime.datetime(2024, 1, 2),
    modified_at_start=datetime.datetime(2020, 1, 1),
    modified_at_end=datetime.datetime(2024, 1, 2),
    target_name='readmitted',
    target_type='Binary',
    created_by='[email protected]',
    compatible_with_model_package_id='650a9f57d3f427ce1cc64747',
    prediction_threshold=0.5,
    imported=False,
    for_challenger=False,
)
registered_models = dr.RegisteredModel.list(filters=registered_model_filters, search="10k")
registered_model = registered_models[0]
versions = registered_model.list_versions()
# similarily to registered models, versions also support fine-grain filtering and search
filters = dr.models.model_registry.RegisteredModelVersionsListFilters(
    target_name='readmitted',
)
versions_with_search = registered_model.list_versions(search="Elastic", filters=filters)

Archive, update and share registered models

Use the following command to archive registered models. Archiving registered models archives all the versions of the registered model.

REGISTERED_MODEL_ID = "651bd2317aed25ed7d4bca7f"
dr.RegisteredModel.archive(REGISTERED_MODEL_ID)

Use the following command to update registered models.

REGISTERED_MODEL_ID = "651bd2317aed25ed7d4bca7f"
dr.RegisteredModel.update(REGISTERED_MODEL_ID, name="New name")

The following commands can be used to share registered models with other users or groups or retrieve existing roles on the deployment.

registered_model = dr.RegisteredModel.get('645b62d5373ed49b485d73e9')
# EXISTING ROLES
roles = registered_model.get_shared_roles()

role = dr.SharingRole(
    share_recipient_type="user",
    id='5ca19879a950d002c61ea3e7',
    role="USER",
)
registered_model.share([role])

List deployments associated with a registered model

Use the following command to list deployments associated with registered model. The deployment is considered associated if one of the versions of the registered model is either a champion or a challenger model.

model_with_deployments = dr.RegisteredModel.get('65035d911e9ff5b07f00f2ea')
# we can list deployments associated with this registered model. Method is searchable and paginated.
model_associated_deployments = model_with_deployments.list_associated_deployments()
# we can also list deployments associated with specific version of the registered model
version = model_with_deployments.list_versions()[1]
version.list_associated_deployments()