Model Registry scenarios
This article collects practical scenarios for validating Model Registry from notebooks, MLOps Studio Pipelines, and the web interface. It focuses on common end-to-end paths such as registering a model, creating multiple versions, verifying duplicate-name handling, testing invalid payloads, and checking behavior when pipeline connectivity is misconfigured.
Overview
These scenarios are intended to confirm that Model Registry works correctly across the main user-facing workflows:
adding a model from a notebook,
validating duplicate-name behavior,
checking input validation during model registration,
creating multiple model versions from a notebook,
registering models and versions from MLOps Studio Pipelines,
verifying rerun behavior,
testing connection failures caused by an incorrect endpoint,
registering multiple versions from a pipeline,
creating models and versions directly from the UI.
The scenarios below are written as practical validation procedures. Each one describes the goal, the actions to perform, and the expected result.
Prerequisites
Before starting, make sure that:
You have access to MLOps Studio and can open the Model Registry interface.
Your namespace allows notebooks to use the Allow access to MLOps Studio Model Registry option.
Model Registry is deployed and reachable from notebooks and pipelines.
You can upload and run pipelines in MLOps Studio Pipelines.
For pipeline scenarios, you can compile pipeline definitions locally.
Scenario 1. Add a model to Model Registry from a notebook
This scenario verifies whether it is possible to connect to the Model Registry service from a running Notebook in MLOps Studio and perform basic REST operations on the registered_models resource, including creation and reading or listing. Its purpose is a quick validation that the network, DNS, PodDefault configuration, and the basic API contract are working end to end in the environment, without diving into details of versioning, artifacts, and permissions.
Create a new notebook with the Allow access to MLOps Studio Model Registry option.
Open the notebook.
Add and run:
!pip install requests model-registry !pip install --upgrade typing_extensions
Add 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}")
The result should be like:
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!
Add 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-classifierxxxxxx", "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}")
The result should be like:
Model registered successfully! Model ID: 55 Model name: test-classifierxxxxxx Metadata (from description): {'framework': 'tensorflow', 'version': '2.10', 'accuracy': '0.92'}Add 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"\nRetrieved 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}")
Results
At the end, something like this should appear:
Found 13 registered models: - test-classifier (ID: 1) Description: Test classification model - test-no-customprops (ID: 4) ... Retrieved model: test-classifier Versions: 0In the Model Registry tab, a new model should appear.
Scenario 2. Error on model name duplication
This scenario checks how the Model Registry behaves when attempting to create a second registered_model with the same name. The purpose of the test is to confirm uniqueness and conflict handling, usually through a 409 error, or, if uniqueness is not enforced, to identify the risk of duplicates and the need for a different key or search method.
In the existing notebook from the previous scenario, add and run:
import requests, json, os, uuid 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}" endpoint = f"{url}/api/model_registry/v1alpha3/registered_models" # Use a fixed name to force a conflict, # or set it to one that you know already exists. name = f"test-classifier-dup-{uuid.uuid4().hex[:8]}" metadata = {"framework": "tensorflow", "version": "2.10", "accuracy": "0.92"} model_data = { "name": name, "owner": MODEL_REGISTRY_AUTHOR, "description": f"Duplicate-name test. Metadata: {json.dumps(metadata)}" } def post_model(payload): return requests.post(endpoint, json=payload, timeout=10) # First attempt r1 = post_model(model_data) print(f"POST #1: HTTP {r1.status_code}") print(r1.text[:300]) # Second attempt: duplicate r2 = post_model(model_data) print(f"\nPOST #2 (duplicate): HTTP {r2.status_code}") print(r2.text[:300]) if r2.status_code == 409: print("\nPASS: 409 Conflict — the name is treated as unique and the duplicate is blocked.") elif r2.status_code in (400, 422): print("\nPASS (conditional): The API rejected the duplicate during validation (400/422). Check whether the message refers to a name conflict.") elif r2.status_code in (200, 201): print("\nFAIL / RISK: The API accepted the duplicate (200/201). That means 'name' is not unique and you need to rely on ID or additional filters.") elif r2.status_code in (401, 403): print("\nINCONCLUSIVE: You received 401/403 — this is an authorization problem, not duplicate semantics.") else: print("\nINCONCLUSIVE: Unusual status code — check the response body and service logs.")
Results
Since this code attempts to create a model with the same name twice in a row, the first request should return 200 or 201, and the second should return 409.
POST #1: HTTP 201 {"createTimeSinceEpoch":"1765875259057",...,"name":"test-classifier-dup-b9a92aa8",...} POST #2 (duplicate): HTTP 409 {"code":"","message":"rpc error: code = AlreadyExists desc = Given node already exists: ..."} PASS: 409 Conflict — the name is treated as unique and the duplicate is blocked.
Scenario 3. Input data validation during model registration
This scenario checks whether the Model Registry rejects incorrect payloads when creating a registered_model, for example when the name field is missing, empty, or has the wrong type. Its purpose is to confirm that the registry does not accept invalid data and that the errors are diagnostic for the user or automation.
Note
When creating a model with a very long name, a MLOps Studio limitation may occur. In that case, the response may be 500 instead of a 4xx validation error.
In the existing notebook, add and run:
!pip install requests
Add and run:
import os import requests import uuid import json 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}" endpoint = f"{url}/api/model_registry/v1alpha3/registered_models" print("Endpoint:", endpoint)
Add and run, test 1: missing name field:
payload = { "owner": MODEL_REGISTRY_AUTHOR, "description": "Validation test: missing name" } r = requests.post(endpoint, json=payload, timeout=10) print("POST missing name:", r.status_code) print(r.text[:400]) if r.status_code in (400, 422): print("PASS: missing name was rejected (400/422).") else: print("FAIL / RISK: expected 400/422 for missing name.")
Add and run, test 2: empty name:
payload = { "name": "", "owner": MODEL_REGISTRY_AUTHOR, "description": "Validation test: empty name" } r = requests.post(endpoint, json=payload, timeout=10) print("POST empty name:", r.status_code) print(r.text[:400]) if r.status_code in (400, 422): print("PASS: empty name was rejected (400/422).") else: print("FAIL / RISK: expected 400/422 for empty name.")
Add and run, test 3: incorrect field type, name as a number:
payload = { "name": 12345, "owner": MODEL_REGISTRY_AUTHOR, "description": "Validation test: name as number" } r = requests.post(endpoint, json=payload, timeout=10) print("POST name as number:", r.status_code) print(r.text[:400]) if r.status_code in (400, 422): print("PASS: invalid name type was rejected (400/422).") else: print("FAIL / RISK: expected 400/422 for name with the wrong type.")
Add and run, test 4: very long name:
too_long_name = "qa-" + ("x" * 300) payload = { "name": too_long_name, "owner": MODEL_REGISTRY_AUTHOR, "description": "Validation test: too long name" } r = requests.post(endpoint, json=payload, timeout=10) print("POST too long name:", r.status_code) print(r.text[:400]) if r.status_code in (400, 422): print("PASS: too long name was rejected (400/422).") elif r.status_code in (200, 201): print("OBS: The API accepted a very long name (200/201) — verify whether this matches your requirements.") else: print("INCONCLUSIVE: unusual status code — check the response body.")
Results
For tests 1 and 2, the error should look like:
POST missing name: 422 {"code":"","message":"required field 'name' is zero value."} PASS: missing name was rejected (400/422).For test 3, the error should be similar to:
POST name as number: 400 {"code":"","message":"json: cannot unmarshal number into Go struct field RegisteredModelCreate.name of type string"} PASS: invalid name type was rejected (400/422).For test 4, the response may look like:
POST too long name: 500 {"code":"","message":"rpc error: code = Internal desc = Cannot create node for type_id: 60 name: \"qa-xxxxxxxx..."} INCONCLUSIVE: unusual status code — check the response body.
Scenario 4. Model versioning from a notebook using the SDK in a virtual environment
This scenario verifies a typical end-user workflow: registering a model and then adding subsequent versions by using the Python model-registry SDK, followed by validation through the REST API and the UI. Its purpose is to confirm that versioning works end to end and that new versions are correctly stored and visible in the interface.
Create a new notebook with the Allow access to MLOps Studio Model Registry option.
Open the notebook.
Create an isolated environment and register the model with version v1:
%%bash set -euo pipefail python -m venv /tmp/mr-venv source /tmp/mr-venv/bin/activate pip -q install -U pip pip -q install "typing_extensions>=4.10.0" "model-registry==0.2.22" python - <<'PY' import os, uuid from model_registry import ModelRegistry MODEL_REGISTRY_HOST = os.getenv("MODEL_REGISTRY_HOST", "model-registry-service.model-registry.svc.cluster.local") MODEL_REGISTRY_PORT = int(os.getenv("MODEL_REGISTRY_PORT", "8080")) MODEL_REGISTRY_AUTHOR = os.getenv("MODEL_REGISTRY_AUTHOR", "kubeflow-user") registry = ModelRegistry( server_address=f"http://{MODEL_REGISTRY_HOST}", port=MODEL_REGISTRY_PORT, author=MODEL_REGISTRY_AUTHOR, is_secure=False ) model_name = f"qa-iris-{uuid.uuid4().hex[:8]}" version = "v1" uri = f"s3://dummy-bucket/{model_name}/{version}/model" rm = registry.register_model( model_name, uri, model_format_name="sklearn", model_format_version="1", version=version, description="E2E versioning test from notebook (venv)", metadata={"accuracy": 0.92}, ) print("MODEL_NAME:", model_name) print("MODEL_ID:", rm.id) PY
Add a second version v2 to the same model. Insert the MODEL_NAME value from the previous step and run:
%%bash set -euo pipefail MODEL_NAME="INSERT_MODEL_NAME_FROM_STEP_3_HERE" V2_URI="s3://dummy-bucket/${MODEL_NAME}/v2/model" source /tmp/mr-venv/bin/activate export MODEL_NAME export V2_URI python - <<'PY' import os from model_registry import ModelRegistry MODEL_REGISTRY_HOST = os.getenv("MODEL_REGISTRY_HOST", "model-registry-service.model-registry.svc.cluster.local") MODEL_REGISTRY_PORT = int(os.getenv("MODEL_REGISTRY_PORT", "8080")) MODEL_REGISTRY_AUTHOR = os.getenv("MODEL_REGISTRY_AUTHOR", "kubeflow-user") registry = ModelRegistry( server_address=f"http://{MODEL_REGISTRY_HOST}", port=MODEL_REGISTRY_PORT, author=MODEL_REGISTRY_AUTHOR, is_secure=False ) registry.register_model( os.environ["MODEL_NAME"], os.environ["V2_URI"], model_format_name="sklearn", model_format_version="1", version="v2", description="E2E versioning test from notebook (venv) - v2", metadata={"note": "second version"}, ) print("OK: created v2 for model:", os.environ["MODEL_NAME"]) PY
Verify via the REST API that the model has both versions v1 and v2. Insert MODEL_NAME:
import os, requests MODEL_NAME = "INSERT_MODEL_NAME_FROM_STEP_3_HERE" 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") base = f"http://{MODEL_REGISTRY_HOST}:{MODEL_REGISTRY_PORT}" models_ep = f"{base}/api/model_registry/v1alpha3/registered_models" r = requests.get(models_ep, timeout=10) r.raise_for_status() items = r.json().get("items", []) model_id = next((m.get("id") for m in items if m.get("name") == MODEL_NAME), None) print("model_id:", model_id) versions_ep = f"{models_ep}/{model_id}/versions" rv = requests.get(versions_ep, timeout=10) rv.raise_for_status() versions = rv.json().get("items", []) names = [v.get("name") for v in versions] print("Versions:", names) print("PASS" if ("v1" in names and "v2" in names) else "FAIL")
Verify in the Model Registry UI that:
the model MODEL_NAME exists,
the VERSIONS tab shows v1 and v2,
each version has visible metadata and a visible Model location.
Results
After step 3, the model is created and MODEL_NAME and MODEL_ID are printed.
After step 4, adding v2 ends with a message such as OK: created v2…
After step 5, the result should look like:
model_id: 108 Versions: ['v1', 'v2'] PASS
After step 6, both versions are visible in the UI for the same model.
Scenario 5. Happy path: register a model and version from MLOps Studio Pipelines
This scenario verifies a typical end-user use case: running a pipeline in MLOps Studio that uses the model-registry Python SDK to register a model + version (v1) and saves basic execution metadata such as pipeline_job_id and source. Additionally, the scenario performs a read-after-write validation after registration to confirm the end-to-end functionality of the Model Registry service from within the pipeline.
Create a new file and save it as test_model_registry_pipeline.py.
from kfp import dsl from kfp import kubernetes from kfp.compiler import Compiler @dsl.component( base_image="python:3.11-slim", packages_to_install=[ "model-registry==0.2.22", "typing_extensions>=4.10.0", "requests>=2.31.0", ], ) def register_model_happy_path( model_name_prefix: str, model_uri: str, author: str, model_registry_host: str = "model-registry-service", model_registry_port: str = "8080", model_format_name: str = "sklearn", model_format_version: str = "1", version: str = "v1", pipeline_job_id: str = "", ) -> str: """Happy path: register model+version via SDK and read back for E2E validation.""" from model_registry import ModelRegistry registry = ModelRegistry( server_address=f"http://{model_registry_host}", port=int(model_registry_port), author=author, is_secure=False, ) suffix = (pipeline_job_id or "no-run-id")[:8] model_name = f"{model_name_prefix}-{suffix}" rm = registry.register_model( model_name, model_uri, model_format_name=model_format_name, model_format_version=model_format_version, version=version, description="HappyPath registration from MLOps Studio Pipeline", metadata={ "source": "kubeflow-pipeline", "pipeline_job_id": pipeline_job_id, }, ) print(f"Registered model: name={model_name}, id={rm.id}") model = registry.get_registered_model(model_name) if not model or str(model.id) != str(rm.id): raise RuntimeError(f"Post-check failed: cannot retrieve registered model {model_name}") mv = registry.get_model_version(model_name, version) if not mv: raise RuntimeError(f"Post-check failed: cannot retrieve model version {model_name}:{version}") print(f"Registered version: name={mv.name}, id={mv.id}") return str(rm.id) @dsl.pipeline( name="model-registry-happy-path", description="Happy path: register model+version in Model Registry via SDK from KFP v2 pipeline.", ) def model_registry_happy_path_pipeline( model_name_prefix: str = "pipeline-test-model", model_uri: str = "s3://bucket/path/to/model", author: str = "user@example.com", model_registry_host: str = "model-registry-service", model_registry_port: str = "8080", ): t = register_model_happy_path( model_name_prefix=model_name_prefix, model_uri=model_uri, author=author, model_registry_host=model_registry_host, model_registry_port=model_registry_port, pipeline_job_id=dsl.PIPELINE_JOB_ID_PLACEHOLDER, ) t.set_display_name("Register model (HappyPath)") t.set_caching_options(enable_caching=False) kubernetes.add_pod_annotation( t, annotation_key="sidecar.istio.io/inject", annotation_value="true", ) if __name__ == "__main__": Compiler().compile( pipeline_func=model_registry_happy_path_pipeline, package_path="model_registry_happy_path_pipeline.yaml", ) print("Compiled to model_registry_happy_path_pipeline.yaml")
On your local machine, navigate to your workspace directory.
Create a virtual environment:
python3 -m venv .venv
Activate the environment:
source .venv/bin/activate
Install the MLOps Studio Pipelines SDK:
pip install kfp pip install kfp-kubernetes
Generate the file:
python test_model_registry_pipeline.pyNavigate to the MLOps Studio UI → Pipelines.
Click + Upload pipeline / Create a new pipeline.
Set the pipeline name.
Select Upload a file and point to the generated model_registry_happy_path_pipeline.yaml file.
Click Create.
Once the pipeline is created, click Create run.
Provide a run name, select or create an Experiment, and then click Start.
Open the run details and check the logs.
Results
Both the registration and the read-after-write validation should complete successfully.
There are no errors in the logs.
The model should appear in the Model Registry interface with a name like pipeline-test-model-<8_characters>.
In the VERSIONS tab, version v1 is visible.
In the v1 → DETAILS view:
Model location / URI = s3://bucket/path/to/model
Model format = sklearn
Properties include:
pipeline_job_id
source = kubeflow-pipeline
Scenario 6. Rerun by cloning the same pipeline run
This scenario checks the pipeline’s behavior during a rerun in a manner typical for users, for example by cloning a run. Because the pipeline generates a unique model name based on pipeline_job_id, the expected result is the creation of a new model with a different suffix and the correct registration of version v1 and its metadata.
Open the details of the first run from the previous scenario.
Click Clone run.
Set a new run name, for example mr_hp_run_2_clone.
Do not change the parameters.
Click Start.
Wait for the run to finish and check the logs of the Register model (HappyPath) step.
Expected result
The second run also completes successfully.
A new model appears in Model Registry with a name like pipeline-test-model-<different_8_characters>.
The new model has version v1.
Version v1 has:
the same URI as before,
format sklearn,
a different pipeline_job_id,
source = kubeflow-pipeline.
Scenario 7. Incorrect Model Registry endpoint in a pipeline
This scenario verifies the pipeline behavior when the most common configuration mistake occurs: an incorrect DNS name or service port for Model Registry. The goal is to confirm that the pipeline detects the connection problem, ends the step in a clear diagnostic way, and does not create any models in Model Registry.
Create a file and save it as model_registry_bad_endpoint_pipeline.py with the following code:
from kfp import dsl from kfp import kubernetes from kfp.compiler import Compiler @dsl.component( base_image="python:3.11-slim", packages_to_install=[ "model-registry==0.2.22", "typing_extensions>=4.10.0", "requests>=2.31.0", ], ) def register_model_expect_connection_failure( model_name_prefix: str, model_uri: str, author: str, model_registry_host: str, model_registry_port: str, pipeline_job_id: str = "", ) -> None: """ Negative test: intentionally provide a wrong host or port. We expect a failure (ConnectionError/Timeout) and treat that as PASS. """ import requests url = f"http://{model_registry_host}:{model_registry_port}" print("Testing Model Registry endpoint:", url) try: r = requests.get( f"{url}/api/model_registry/v1alpha3/registered_models", timeout=5, ) raise RuntimeError( f"FAIL: Endpoint unexpectedly reachable. HTTP {r.status_code}. " "This was supposed to be a bad host/port test." ) except requests.exceptions.Timeout as e: print("PASS: timeout as expected:", str(e)[:300]) return except requests.exceptions.ConnectionError as e: print("PASS: connection error as expected:", str(e)[:300]) return except requests.exceptions.RequestException as e: print("PASS: request exception as expected:", str(e)[:300]) return @dsl.pipeline( name="model-registry-bad-endpoint", description="Negative: wrong host/port must fail fast and create nothing in Model Registry.", ) def model_registry_bad_endpoint_pipeline( model_name_prefix: str = "pipeline-test-model-bad-endpoint", model_uri: str = "s3://bucket/path/to/model", author: str = "user@example.com", model_registry_host: str = "model-registry-service.DOES-NOT-EXIST.svc.cluster.local", model_registry_port: str = "8080", ): t = register_model_expect_connection_failure( model_name_prefix=model_name_prefix, model_uri=model_uri, author=author, model_registry_host=model_registry_host, model_registry_port=model_registry_port, pipeline_job_id=dsl.PIPELINE_JOB_ID_PLACEHOLDER, ) t.set_display_name("Bad endpoint (Expect fail)") t.set_caching_options(enable_caching=False) kubernetes.add_pod_annotation( t, annotation_key="sidecar.istio.io/inject", annotation_value="true", ) if __name__ == "__main__": Compiler().compile( pipeline_func=model_registry_bad_endpoint_pipeline, package_path="model_registry_bad_endpoint_pipeline.yaml", ) print("Compiled to model_registry_bad_endpoint_pipeline.yaml")
Compile the file and run the pipeline exactly as in the previous scenarios.
Expected result
The pipeline step ends with a successful negative test. A green status is acceptable because the test treats the connection error as PASS.
The step logs should include a line with the tested address, for example:
Testing Model Registry endpoint: http://model-registry-service.DOES-NOT-EXIST.svc.cluster.local:8080
The logs should confirm the expected error, for example:
PASS: connection error as expected: ... NameResolutionError ...
or:
PASS: timeout as expected ...
In the Model Registry UI, no new model should appear with a name starting with pipeline-test-model-bad-endpoint-…
Scenario 8. Register multiple model versions in the Model Registry from a pipeline
The goal of this scenario is to verify that a pipeline in MLOps Studio Pipelines can:
create a single, stable model name within a run,
register two versions of the same model, for example v1 and v1.1, in the Model Registry,
confirm through the Model Registry REST API that both versions exist.
The scenario uses a pipeline file without set_display_name() in accordance with the workaround for a known issue in KFP 2.5.0.
Create the file locally, for example model_registry_versioning_pipeline.py.
from kfp import dsl from kfp import kubernetes from kfp.compiler import Compiler @dsl.component( base_image="python:3.11-slim", ) def make_model_name(model_name_prefix: str, pipeline_job_id: str) -> str: """Generates a stable model name for the whole run.""" suffix = (pipeline_job_id or "no-run-id")[:8] model_name = f"{model_name_prefix}-{suffix}" print("Generated model name:", model_name) return model_name @dsl.component( base_image="python:3.11-slim", packages_to_install=[ "model-registry==0.2.22", "typing_extensions>=4.10.0", "requests>=2.31.0", ], ) def register_version( model_name: str, model_uri: str, author: str, version: str, model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local", model_registry_port: str = "8080", pipeline_job_id: str = "", ) -> None: """Registers a model version in Model Registry.""" from model_registry import ModelRegistry registry = ModelRegistry( server_address=f"http://{model_registry_host}", port=int(model_registry_port), author=author, is_secure=False, ) rm = registry.register_model( model_name, model_uri, model_format_name="sklearn", model_format_version="1", version=version, description=f"Versioning test from KFP: {version}", metadata={ "source": "kubeflow-pipeline", "pipeline_job_id": pipeline_job_id, }, ) print(f"register_model OK: model={model_name}, version={version}, registered_model_id={rm.id}") @dsl.component( base_image="python:3.11-slim", packages_to_install=["requests>=2.31.0"], ) def verify_versions_rest( model_name: str, expected_versions_csv: str, model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local", model_registry_port: str = "8080", ) -> None: """Validates through the REST API that the model has the expected versions.""" import requests base = f"http://{model_registry_host}:{model_registry_port}" models_ep = f"{base}/api/model_registry/v1alpha3/registered_models" r = requests.get(models_ep, timeout=10) r.raise_for_status() items = r.json().get("items", []) model_id = next((m.get("id") for m in items if m.get("name") == model_name), None) if not model_id: raise RuntimeError(f"FAIL: model '{model_name}' not found in registered_models list") versions_ep = f"{models_ep}/{model_id}/versions" rv = requests.get(versions_ep, timeout=10) rv.raise_for_status() versions = rv.json().get("items", []) names = [v.get("name") for v in versions] expected = [x.strip() for x in expected_versions_csv.split(",") if x.strip()] missing = [v for v in expected if v not in names] print("Model:", model_name) print("Model ID:", model_id) print("Found versions:", names) print("Expected versions:", expected) if missing: raise RuntimeError(f"FAIL: missing versions: {missing}") print("PASS: all expected versions exist") @dsl.pipeline( name="model-registry-versioning", description="KFP v2: register model versions v1 and v1.1 and verify both exist.", ) def model_registry_versioning_pipeline( model_name_prefix: str = "pipeline-versioning-model", author: str = "user@example.com", model_registry_host: str = "model-registry-service.model-registry.svc.cluster.local", model_registry_port: str = "8080", v1_uri: str = "s3://bucket/path/to/model/v1", v11_uri: str = "s3://bucket/path/to/model/v1_1", ): job_id = dsl.PIPELINE_JOB_ID_PLACEHOLDER name_task = make_model_name( model_name_prefix=model_name_prefix, pipeline_job_id=job_id, ) name_task.set_caching_options(enable_caching=False) r1 = register_version( model_name=name_task.output, model_uri=v1_uri, author=author, version="v1", model_registry_host=model_registry_host, model_registry_port=model_registry_port, pipeline_job_id=job_id, ) r1.set_caching_options(enable_caching=False) kubernetes.add_pod_annotation( r1, annotation_key="sidecar.istio.io/inject", annotation_value="true", ) r1.after(name_task) r2 = register_version( model_name=name_task.output, model_uri=v11_uri, author=author, version="v1.1", model_registry_host=model_registry_host, model_registry_port=model_registry_port, pipeline_job_id=job_id, ) r2.set_caching_options(enable_caching=False) kubernetes.add_pod_annotation( r2, annotation_key="sidecar.istio.io/inject", annotation_value="true", ) r2.after(r1) v = verify_versions_rest( model_name=name_task.output, expected_versions_csv="v1,v1.1", model_registry_host=model_registry_host, model_registry_port=model_registry_port, ) v.set_caching_options(enable_caching=False) kubernetes.add_pod_annotation( v, annotation_key="sidecar.istio.io/inject", annotation_value="true", ) v.after(r2) if __name__ == "__main__": Compiler().compile( pipeline_func=model_registry_versioning_pipeline, package_path="mr_versioning_no_display_name.yaml", ) print("Compiled to mr_versioning_no_display_name.yaml")
Compile the file and run the pipeline exactly as in the previous scenarios.
Expected result
The pipeline run ends with status Succeeded.
In the Model Registry, there is one Registered Model with the name generated in the model-name step.
This model has at least two versions:
v1
v1.1
The Verify versions via REST task completes successfully and confirms the full set of versions in the logs.
Scenario 9. Happy path: register a model and version directly in the Model Registry UI, then add a new version
This scenario checks whether it is possible to create a new model together with its first version v1 directly from the Model Registry UI, and whether a subsequent version v2 can be added. Its purpose is to confirm that the UI correctly saves both the model data and the version data, and that both the model and its versions are visible in the UI after refreshing.
Navigate to MLOps Studio UI → Model Registry.
Create a new model with the first version v1:
Click Register model.
Set the following fields:
Model registry: model-registry-service
Model name: ui-qa-model-<timestamp>
Model description: ui-qa-model-<timestamp>
Version name: v1
Version description: ui-qa-model-<timestamp>
Source model format: sklearn
Source model format version: 1
Model location: Object storage
Endpoint: <S3_ENDPOINT>
Bucket: dummy-bucket
Region: <REGION>
Path: ui-qa-model-<timestamp>/v1/model
Click Register model.
Validate in the UI after creation of v1:
The model ui-qa-model-<timestamp> appears in the model list.
Open the model and navigate to the Versions tab.
Confirm that version v1 is visible.
Open the details of version v1 and confirm that:
Model location corresponds to Object storage as entered.
Source model format = sklearn.
Source model format version = 1.
Add a second version v2 to the same model:
In the ui-qa-model-<timestamp> model, go to the Versions tab.
Click Add/Register version depending on the UI label.
Set the following fields:
Version name: v2
Version description: ui-qa-model-<timestamp>
Source model format: sklearn
Source model format version: 1
Model location: Object storage
Endpoint: <S3_ENDPOINT>
Bucket: dummy-bucket
Region: <REGION>
Path: ui-qa-model-<timestamp>/v2/model
Save the version.
Validate in the UI after adding v2:
Versions v1 and v2 are visible in the Versions tab.
In the details for version v2:
Path points to ui-qa-model-<timestamp>/v2/model.
Format and format version match the settings.
Results
After steps 2 and 3:
The model ui-qa-model-<timestamp> is visible in the UI.
Version v1 is visible in the UI with correctly set format, format version, and location.
After steps 4 and 5:
The same model contains two versions: v1 and v2.
Version v2 points to ui-qa-model-<timestamp>/v2/model and maintains consistent format data.
Scenario 10. Error when attempting to add a model that already exists
This scenario verifies that the UI displays a clear error when you try to create a model whose name already exists.
Add a model with a name that already exists.
Click Register model.
Results
Information should appear stating that a model with this name already exists.
rpc error: code = AlreadyExists desc = Given node already exists: type_id: 60 name: "qa-iris-c5eb9142" properties { key: "description" value { string_value: "a" } } properties { key: "owner" value { string_value: "xxx" } } properties { key: "state" value { string_value: "LIVE" } } type: "kf.RegisteredModel" INTERNAL: Cannot create node for type_id: 60 name: "qa-iris-c5eb9142" properties { key: "description" value { string_value: "a" } } properties { key: "owner" value { string_value: "xxx" } } properties { key: "state" value { string_value: "LIVE" } } type: "kf.RegisteredModel" mysql_query failed: errno: Duplicate entry '60-qa-iris-c5eb9142' for key 'Context.type_id'
What to do next
After validating these Model Registry scenarios, the next useful topics are:
checking permissions and namespace visibility rules for Model Registry,
validating model deletion or update behavior,
testing richer metadata and artifact references,
documenting UI screenshots for the happy-path and failure-path scenarios,
aligning notebook, pipeline, and UI workflows into one end-user guide.