Model Registry

This article explains how to validate Model Registry from three different paths: the web interface, notebooks, and MLOps Studio Pipelines. It also includes troubleshooting guidance, a quick API reference, and useful operational commands.

Prerequisites

Before starting, make sure that:

  1. You have a MLOps Studio Profile with an associated namespace.

  2. You are logged in to MLOps Studio.

  3. Model Registry is deployed and running.

  4. The PodDefault access-model-registry is available in your namespace for notebook-based tests.

Overview

Model Registry can be validated from several angles:

  • from the web interface, to confirm that the UI loads correctly and displays models,

  • from notebooks, to confirm direct API connectivity and model registration,

  • from pipelines, to confirm that workflows can connect to and register models programmatically.

In the version described by the source material, the web interface is mainly intended for browsing and inspecting models. Creating or editing models is performed through the API or SDK.

Testing from the web interface

Access the Model Registry interface

To verify basic UI access:

  1. Log in to the MLOps Studio Central Dashboard.

  2. Click Model Registry in the left navigation menu.

  3. Confirm that the interface loads without errors.

  4. Confirm that a namespace drop-down is visible and shows your user namespace.

Available UI functionality in version v0.2.15

The Model Registry interface version v0.2.15 offers the following capabilities:

  • Browsing models

    • Displaying a list of registered models.

    • Filtering models by namespace.

    • Viewing model details (name, owner, description, metadata).

    • Browsing model versions.

  • Model management

    • Viewing model metadata.

    • Browsing version history.

    • Displaying the model URI for each version.

    • Viewing information about the owner and creation date.

  • Filtering and searching

    • Selecting a namespace from the dropdown.

    • Automatic use of the user namespace (no need for the ?namespace= parameter in the URL).

    • Displaying an empty state when no models are present.

  • Limitations in version v0.2.15

    • Registration of new models is done via API/SDK, not through the web interface.

    • Editing models is done via API/SDK.

    • The interface serves primarily for browsing and managing existing models.

Expected behavior

  • If there are no models, you will see an empty state.

  • All API calls should return HTTP 200 (check the Network tab in your browser’s DevTools).

Testing from notebooks

Notebook configuration

To test Model Registry from a notebook:

  1. Go to Notebooks and click + NEW NOTEBOOK.

  2. Select your namespace.

  3. Choose a Python image, for example tensorflow/tensorflow:latest.

  4. In the Configurations section, select the PodDefault access-model-registry.

  5. Click LAUNCH.

  6. Wait until the notebook status becomes Running.

  7. Click CONNECT to open JupyterLab.

Install the required packages

In a new notebook cell, run:

!pip install requests model-registry
!pip install --upgrade typing_extensions

Test 1. Basic connection test

Create a new Python cell and run:

import requests
import os

# Environment variables are injected by the PodDefault 'access-model-registry'
MODEL_REGISTRY_HOST = os.getenv("MODEL_REGISTRY_HOST", "model-registry-service.model-registry.svc.cluster.local")
MODEL_REGISTRY_PORT = os.getenv("MODEL_REGISTRY_PORT", "8080")

url = f"http://{MODEL_REGISTRY_HOST}:{MODEL_REGISTRY_PORT}"

print(f"Testing connection to Model Registry at {url}")

try:
    health_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models", timeout=5)
    print(f"Health check: Status Code {health_response.status_code}")
    health_response.raise_for_status()

    api_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models", timeout=5)
    print(f"API check: Status Code {api_response.status_code}")
    api_response.raise_for_status()

    print("Connection to Model Registry completed successfully!")

except requests.exceptions.ConnectionError as e:
    print(f"Connection error: Could not connect to Model Registry. {e}")
except requests.exceptions.Timeout:
    print("Timeout error: The request exceeded the time limit.")
except requests.exceptions.RequestException as e:
    print(f"Request error: {e}")

Expected result:

Testing connection to Model Registry at http://model-registry-service.model-registry.svc.cluster.local:8080
Health check: Status Code 200
API check: Status Code 200
Connection to Model Registry completed successfully!

Test 2. Model registration with the REST API

Create another cell and run:

import requests
import json
import os

MODEL_REGISTRY_HOST = os.getenv("MODEL_REGISTRY_HOST", "model-registry-service.model-registry.svc.cluster.local")
MODEL_REGISTRY_PORT = os.getenv("MODEL_REGISTRY_PORT", "8080")
MODEL_REGISTRY_AUTHOR = os.getenv("MODEL_REGISTRY_AUTHOR", "kubeflow-user")

url = f"http://{MODEL_REGISTRY_HOST}:{MODEL_REGISTRY_PORT}"

metadata = {
    "framework": "tensorflow",
    "version": "2.10",
    "accuracy": "0.92"
}

model_data = {
    "name": "test-classifier",
    "owner": MODEL_REGISTRY_AUTHOR,
    "description": f"Test classification model. Metadata: {json.dumps(metadata)}"
}

response = requests.post(
    f"{url}/api/model_registry/v1alpha3/registered_models",
    json=model_data
)

if response.status_code in [200, 201]:
    model = response.json()
    model_id = model.get("id")
    print("Model registered successfully!")
    print(f"Model ID: {model_id}")
    print(f"Model name: {model.get('name')}")

    description = model.get("description", "")
    if "Metadata:" in description:
        import re
        metadata_match = re.search(r"Metadata: ({.*})", description)
        if metadata_match:
            metadata_json = metadata_match.group(1)
            metadata = json.loads(metadata_json)
            print(f"   Metadata (from description): {metadata}")

Test 3. Listing and searching for models

Create another cell and run:

import requests
import json
import os

MODEL_REGISTRY_HOST = os.getenv("MODEL_REGISTRY_HOST", "model-registry-service.model-registry.svc.cluster.local")
MODEL_REGISTRY_PORT = os.getenv("MODEL_REGISTRY_PORT", "8080")
MODEL_REGISTRY_AUTHOR = os.getenv("MODEL_REGISTRY_AUTHOR", "kubeflow-user")

url = f"http://{MODEL_REGISTRY_HOST}:{MODEL_REGISTRY_PORT}"

# List all models
response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models")

if response.status_code == 200:
    data = response.json()
    models = data.get("items", [])
    print(f"Found {len(models)} registered models:")

    for model in models:
        print(f"  - {model.get('name')} (ID: {model.get('id')})")
        if model.get("description"):
            print(f"    Description: {model.get('description')}")

        # Extract metadata from description if present
        description = model.get("description", "")
        if "Metadata:" in description:
            import re
            metadata_match = re.search(r"Metadata: ({.*})", description)
            if metadata_match:
                metadata_json = metadata_match.group(1)
                metadata = json.loads(metadata_json)
                print(f"    Metadata: {metadata}")

    # Retrieve a specific model by ID
    if models:
        model_id = models[0].get("id")
        model_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models/{model_id}")

        if model_response.status_code == 200:
            model = model_response.json()
            print(f"\nFetched model: {model.get('name')}")

            # Retrieve model versions
            versions_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models/{model_id}/versions")

            if versions_response.status_code == 200:
                versions_data = versions_response.json()
                versions = versions_data.get("items", [])
                print(f"   Versions: {len(versions)}")
                for version in versions:
                    print(f"     - {version.get('name')}: {version.get('modelUri', 'N/A')}")
            else:
                print(f"   Could not retrieve versions: {versions_response.status_code}")
        else:
            print(f"Could not retrieve model: {model_response.status_code}")
else:
    print(f"Could not retrieve model list: {response.status_code}")
    print(f"   Error: {response.text}")

Testing from pipelines

Create a pipeline component

Create a new Python file test_model_registry_pipeline.py:

from kfp import dsl
from kfp.dsl import component
import os

@dsl.component(
    base_image="python:3.11-slim"
)
def test_model_registry_connection(
    model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local",
    model_registry_port: str = "8080"
):
    """Tests the connection to the Model Registry service."""
    import subprocess
    import sys

    # Install requests at runtime
    subprocess.check_call([sys.executable, "-m", "pip", "install", "requests", "-q"])

    import requests

    url = f"http://{model_registry_host}:{model_registry_port}"
    print(f"Testing connection to Model Registry at {url}")

    try:
        health_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models", timeout=5)
        print(f"Health check: Status Code {health_response.status_code}")
        health_response.raise_for_status()

        api_response = requests.get(f"{url}/api/model_registry/v1alpha3/registered_models", timeout=5)
        print(f"API check: Status Code {api_response.status_code}")
        api_response.raise_for_status()

        print("Connection to Model Registry completed successfully!")

    except requests.exceptions.ConnectionError as e:
        raise RuntimeError(f"Connection error: Could not connect to Model Registry. {e}")
    except requests.exceptions.Timeout:
        raise RuntimeError("Timeout error: The request exceeded the time limit.")
    except requests.exceptions.RequestException as e:
        raise RuntimeError(f"Request error: {e}")

@dsl.component(
    base_image="python:3.11-slim"
)
def register_model_from_pipeline(
    model_name: str,
    model_uri: str,
    owner: str,
    description: str = "",
    model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local",
    model_registry_port: str = "8080"
):
    """Registers a model in Model Registry from a pipeline."""
    import subprocess
    import sys

    subprocess.check_call([sys.executable, "-m", "pip", "install", "requests", "-q"])

    import requests

    url = f"http://{model_registry_host}:{model_registry_port}"

    # Step 1: Create the model
    model_data = {
        "name": model_name,
        "owner": owner,
        "description": description
    }

    response = requests.post(
        f"{url}/api/model_registry/v1alpha3/registered_models",
        json=model_data
    )

    if response.status_code not in [200, 201]:
        raise RuntimeError(f"Failed to create model: {response.status_code} - {response.text}")

    model = response.json()
    model_id = model["id"]
    print(f"Model created: {model_name} (ID: {model_id})")

    # Step 2: Register the model version
    version_data = {
        "name": "v1.0",
        "modelUri": model_uri,
        "description": f"Pipeline-created version: {description}"
    }

    version_response = requests.post(
        f"{url}/api/model_registry/v1alpha3/registered_models/{model_id}/versions",
        json=version_data
    )

    if version_response.status_code in [200, 201]:
        version = version_response.json()
        print(f"Version registered: {version.get('name')} (ID: {version.get('id')})")
    else:
        print(f"Model created but version registration failed: {version_response.status_code}")
        print(f"Error: {version_response.text}")

    print(f"Model ID: {model_id} (you can see it in the logs)")

@dsl.pipeline(
    name="test-model-registry-pipeline-v2",
    description="Test Model Registry connection and registration from a pipeline (KFP v2.x)"
)
def test_model_registry_pipeline_v2(
    model_name: str = "pipeline-test-model",
    model_uri: str = "s3://bucket/path/to/model",
    owner: str = "user@example.com",
    model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local",
    model_registry_port: str = "8080"
):
    """Pipeline for testing Model Registry using the KFP v2.x format."""

    # Test the connection
    test_connection_op = test_model_registry_connection(
        model_registry_host=model_registry_host,
        model_registry_port=model_registry_port
    )
    test_connection_op.set_display_name("Connection test")
    test_connection_op.set_caching_options(enable_caching=False)

    # Register the model
    register_op = register_model_from_pipeline(
        model_name=model_name,
        model_uri=model_uri,
        owner=owner,
        description="Model registered from the pipeline test",
        model_registry_host=model_registry_host,
        model_registry_port=model_registry_port
    )
    register_op.set_display_name("Model registration")
    register_op.set_caching_options(enable_caching=False)
    register_op.after(test_connection_op)

Compile and upload the pipeline

Install KFP:

!pip install --user kfp

Then, in a notebook or Python script, run:

from kfp import compiler
from test_model_registry_pipeline import test_model_registry_pipeline

# Compile the pipeline
compiler.Compiler().compile(
    pipeline_func=test_model_registry_pipeline,
    package_path="test_model_registry_pipeline.yaml"
)

print("Pipeline compiled to test_model_registry_pipeline.yaml")

Run the pipeline

  1. Go to Pipelines and click Upload Pipeline.

  2. Upload the file test_model_registry_pipeline.yaml.

  3. Create a new run with parameters: * model_name: my-pipeline-model * model_uri: s3://my-bucket/models/v1.0 * owner: your email address

  4. Monitor the run execution.

  5. Check the logs for both steps: * Connection test should show a successful connection. * Model registration should show successful model registration.

Verify in the UI

After the pipeline run finishes:

  1. Open Model Registry.

  2. Check whether the model appears in the list.

  3. Check whether the model custom properties include pipeline_run and source: kubeflow-pipeline.

Troubleshooting

Connection problems

Problem: ConnectionError: Could not connect to Model Registry

Solutions:

  • Check whether the Model Registry service is running:

    kubectl get pods -n model-registry
    
  • Check the service endpoint:

    kubectl get svc -n model-registry
    
  • Check whether the PodDefault is applied:

    kubectl get poddefault access-model-registry -n <your-namespace>
    

Missing environment variables

Problem: MODEL_REGISTRY_HOST or MODEL_REGISTRY_PORT is not set

Solutions:

  • Make sure that the PodDefault access-model-registry is selected when creating the notebook.

  • Manually set the environment variables in code:

    MODEL_REGISTRY_HOST = "model-registry-service.model-registry.svc.cluster.local"
    MODEL_REGISTRY_PORT = "8080"
    

Namespace problems

Problem: You cannot see models, or you get Access forbidden

Solutions:

  • Check whether you have a Profile:

    kubectl get profile
    
  • Check whether the namespace exists:

    kubectl get namespace <your-namespace>
    
  • Check RBAC permissions.

API errors

Problem: 404 Not Found or 500 Internal Server Error

Solutions:

  • Check the Model Registry backend logs:

    kubectl logs -n model-registry deployment/model-registry-deployment
    
  • Check database connectivity:

    kubectl get secret mysql-secret -n model-registry
    
  • Check backend health directly:

    curl http://model-registry-service.model-registry.svc.cluster.local:8080/api/model_registry/v1alpha3/registered_models
    

Quick reference

Environment variables from PodDefault

  • MODEL_REGISTRY_HOST: model-registry-service.model-registry.svc.cluster.local

  • MODEL_REGISTRY_PORT: 8080

  • MODEL_REGISTRY_GRPC_PORT: 9090

  • MODEL_REGISTRY_AUTHOR: kubeflow-user

API endpoints

  • Health Check: GET /api/model_registry/v1alpha3/registered_models

  • List models: GET /api/model_registry/v1alpha3/registered_models

  • Register model: POST /api/model_registry/v1alpha3/registered_models

  • Update model: PATCH /api/model_registry/v1alpha3/registered_models/{id}

  • Get model: GET /api/model_registry/v1alpha3/registered_models/{id}

  • Register version: POST /api/model_registry/v1alpha3/registered_models/{id}/versions

Appendix: useful commands

Check Model Registry status

# Check pods
kubectl get pods -n model-registry

# Check service
kubectl get svc -n model-registry

# Check backend logs
kubectl logs -n model-registry deployment/model-registry-deployment --tail=50

# Check UI logs
kubectl logs -n kubeflow deployment/model-registry-ui --tail=50

What to do next

After completing these checks, continue by validating model registration from notebooks and pipelines, then use the troubleshooting section if any part of the flow does not behave as expected.