From 3701535248fc4088328bfcd508b664783e02b0bf Mon Sep 17 00:00:00 2001 From: Matteo Mortari Date: Mon, 4 Nov 2024 12:38:17 +0100 Subject: [PATCH] with non regression testing Signed-off-by: Matteo Mortari --- Makefile | 10 +++++---- clients/python/tests/test_client.py | 34 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 72204844..b4c906b2 100644 --- a/Makefile +++ b/Makefile @@ -100,8 +100,7 @@ internal/server/openapi/api_model_registry_service.go: bin/openapi-generator-cli .PHONY: gen/openapi gen/openapi: bin/openapi-generator-cli openapi/validate pkg/openapi/client.go -pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml - rm -rf pkg/openapi +pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml clean-pkg-openapi ${OPENAPI_GENERATOR} generate \ -i api/openapi/model-registry.yaml -g go -o pkg/openapi --package-name openapi \ --ignore-file-override ./.openapi-generator-ignore --additional-properties=isGoSubmodule=true,enumClassPrefix=true,useOneOfDiscriminatorLookup=true @@ -111,9 +110,12 @@ pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml vet: ${GO} vet ./... -.PHONY: clean +.PHONY: clean-pkg-openapi + while IFS= read -r file; do rm -f "pkg/openapi/$file"; done < pkg/openapi/.openapi-generator/FILES + +.PHONY: clean clean-pkg-openapi clean: - rm -Rf ./model-registry internal/ml_metadata/proto/*.go internal/converter/generated/*.go pkg/openapi internal/server/openapi/api_model_registry_service.go + rm -Rf ./model-registry internal/ml_metadata/proto/*.go internal/converter/generated/*.go internal/server/openapi/api_model_registry_service.go .PHONY: clean/odh clean/odh: diff --git a/clients/python/tests/test_client.py b/clients/python/tests/test_client.py index 4cd93764..88fd3e0e 100644 --- a/clients/python/tests/test_client.py +++ b/clients/python/tests/test_client.py @@ -2,6 +2,7 @@ from itertools import islice import pytest +import requests from model_registry import ModelRegistry, utils from model_registry.exceptions import StoreError @@ -162,6 +163,39 @@ async def test_update_logical_model_with_labels(client: ModelRegistry): assert ma.custom_properties == ma_labels +@pytest.mark.e2e +async def test_patch_mm(client: ModelRegistry): + """Patching ModelArtifact requires `artifactType` value which was previously not required + + reported with https://issues.redhat.com/browse/RHOAIENG-15326 + """ + name = "test_model" + version = "1.0.0" + rm = client.register_model( + name, + "s3", + model_format_name="test_format", + model_format_version="test_version", + version=version, + ) + assert rm.id + mv = client.get_model_version(name, version) + assert mv + assert mv.id + ma = client.get_model_artifact(name, version) + assert ma + assert ma.id + + payload = { "modelFormatName": "foo" } + from .conftest import REGISTRY_HOST, REGISTRY_PORT + response = requests.patch(url=f"{REGISTRY_HOST}:{REGISTRY_PORT}/api/model_registry/v1alpha3/model_artifacts/{ma.id}", json=payload, 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_update_preserves_model_info(client: ModelRegistry): name = "test_model"