Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion clients/python/tests/regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from model_registry import ModelRegistry
from model_registry.types.artifacts import ModelArtifact

from .conftest import REGISTRY_HOST, REGISTRY_PORT


@pytest.mark.e2e
def test_create_tagged_version(client: ModelRegistry):
Expand Down Expand Up @@ -101,6 +103,7 @@ async def test_create_standalone_model_artifact(client: ModelRegistry):
mv_ma = await client._api.upsert_model_version_artifact(new_ma, mv.id)
assert mv_ma.id == new_ma.id


@pytest.mark.e2e
async def test_patch_model_artifacts_artifact_type(client: ModelRegistry):
"""Patching Artifacts makes the model registry server panic.
Expand All @@ -125,10 +128,46 @@ async def test_patch_model_artifacts_artifact_type(client: ModelRegistry):
assert ma.id

payload = { "modelFormatName": "foo", "artifactType": "model-artifact" }
from .conftest import REGISTRY_HOST, REGISTRY_PORT
response = requests.patch(url=f"{REGISTRY_HOST}:{REGISTRY_PORT}/api/model_registry/v1alpha3/artifacts/{ma.id}", json=payload, timeout=10, headers={"Content-Type": "application/json"})
assert response.status_code == 200
ma = client.get_model_artifact(name, version)
assert ma
assert ma.id
assert ma.model_format_name == "foo"


@pytest.mark.e2e
async def test_as_mlops_engineer_i_would_like_to_store_a_malformed_registered_model_i_get_a_structured_error_message(client: ModelRegistry):
"""As a MLOps engineer if I try to store a malformed RegisteredModel I get a structured error message
"""
payload = { "name": "test_model", "ext_id": 123 }
response = requests.post(url=f"{REGISTRY_HOST}:{REGISTRY_PORT}/api/model_registry/v1alpha3/registered_models", json=payload, timeout=10, headers={"Content-Type": "application/json"})
assert response.status_code == 400
assert response.json() == {
"code": "Bad Request",
"message": 'json: unknown field "ext_id"',
}


@pytest.mark.e2e
async def test_as_mlops_engineer_i_would_like_to_store_a_malformed_model_version_i_get_a_structured_error_message(client: ModelRegistry):
"""As a MLOps engineer if I try to store a malformed ModelVersion I get a structured error message
"""
name = "test_model"
version = "1.0.0"
rm = client.register_model(
name,
"https://acme.org/something",
model_format_name="test_format",
model_format_version="test_version",
version=version,
)
assert rm.id

payload = { "registeredModelId": rm.id }
response = requests.post(url=f"{REGISTRY_HOST}:{REGISTRY_PORT}/api/model_registry/v1alpha3/model_versions", json=payload, timeout=10, headers={"Content-Type": "application/json"})
assert response.status_code == 422
assert response.json() == {
"code": "Bad Request",
"message": "required field 'name' is zero value.",
}
2 changes: 2 additions & 0 deletions test/robot/Regression.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ Regression tests for Model Registry

*** Test Cases ***
As a MLOps engineer if I try to store a malformed RegisteredModel I get a structured error message
# MIGRATED to test_as_mlops_engineer_i_would_like_to_store_a_malformed_registered_model_i_get_a_structured_error_message in pytest
${rm} Create Dictionary name="model" ext_id=123
${err} POST url=http://${MR_HOST}:${MR_PORT}/api/model_registry/v1alpha3/registered_models json=&{rm} expected_status=400
${rm_err} Create Dictionary code=Bad Request message=json: unknown field "ext_id"
And Should be equal ${rm_err} ${err.json()}

As a MLOps engineer if I try to store a malformed ModelVersion I get a structured error message
# MIGRATED to test_as_mlops_engineer_i_would_like_to_store_a_malformed_model_version_i_get_a_structured_error_message in pytest
${rId} Given I create a RegisteredModel having name=${name}
${mv} Create Dictionary registeredModelId=${rId}
${err} POST url=http://${MR_HOST}:${MR_PORT}/api/model_registry/v1alpha3/model_versions json=&{mv} expected_status=422
Expand Down
Loading