Skip to content

Commit 59e57c4

Browse files
authored
fix: update automation to reflect the changes around new source for other models (#1232)
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com>
1 parent f44bd9a commit 59e57c4

File tree

6 files changed

+42
-15
lines changed

6 files changed

+42
-15
lines changed

tests/model_registry/model_catalog/catalog_config/test_default_model_catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TestModelCatalogGeneral:
5959
),
6060
pytest.param(
6161
{"configmap_name": DEFAULT_MODEL_CATALOG_CM},
62-
2,
62+
3,
6363
True,
6464
id="test_model_catalog_default_sources_configmap",
6565
),

tests/model_registry/model_catalog/catalog_config/test_default_source_inclusion_exclusion_cleanup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def test_model_cleanup_on_exclusion_change(
208208
model_registry_rest_headers=model_registry_rest_headers,
209209
source_label=REDHAT_AI_CATALOG_NAME,
210210
expected_models=granite_models,
211+
source_id=REDHAT_AI_CATALOG_ID,
211212
)
212213
except TimeoutExpiredError as e:
213214
pytest.fail(f"Phase 1: Timeout waiting for granite models {granite_models}: {e}")
@@ -245,6 +246,7 @@ def test_model_cleanup_on_exclusion_change(
245246
model_registry_rest_headers=model_registry_rest_headers,
246247
source_label=REDHAT_AI_CATALOG_NAME,
247248
expected_models=prometheus_models,
249+
source_id=REDHAT_AI_CATALOG_ID,
248250
)
249251
except TimeoutExpiredError as e:
250252
pytest.fail(f"Phase 2: Timeout waiting for prometheus models {prometheus_models}: {e}")

tests/model_registry/model_catalog/catalog_config/utils.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def validate_default_catalog(catalogs: list[dict[Any, Any]]) -> None:
6161

6262

6363
def get_validate_default_model_catalog_source(catalogs: list[dict[Any, Any]]) -> None:
64-
assert len(catalogs) == 2, f"Expected no custom models to be present. Actual: {catalogs}"
64+
assert len(catalogs) == 3, f"Expected no custom models to be present. Actual: {catalogs}"
6565
ids_actual = [entry["id"] for entry in catalogs]
6666
assert sorted(ids_actual) == sorted(DEFAULT_CATALOGS.keys()), (
6767
f"Actual default catalog entries: {ids_actual},Expected: {DEFAULT_CATALOGS.keys()}"
@@ -206,6 +206,7 @@ def validate_filter_test_result(
206206
model_registry_rest_headers=model_registry_rest_headers,
207207
source_label=REDHAT_AI_CATALOG_NAME,
208208
expected_models=expected_models,
209+
source_id=REDHAT_AI_CATALOG_ID,
209210
)
210211

211212
# Get database models
@@ -426,6 +427,7 @@ def wait_for_model_set_match(
426427
model_catalog_rest_url: list[str],
427428
model_registry_rest_headers: dict[str, str],
428429
source_label: str,
430+
source_id: str,
429431
expected_models: set[str],
430432
) -> set[str]:
431433
"""
@@ -436,6 +438,7 @@ def wait_for_model_set_match(
436438
model_registry_rest_headers: API headers
437439
source_label: Source to query
438440
expected_models: Expected set of model names
441+
source_id: Source to query
439442
440443
Returns:
441444
Set of matched models
@@ -445,10 +448,13 @@ def wait_for_model_set_match(
445448
AssertionError: If models don't match (retried automatically)
446449
Exception: If API errors occur (retried automatically)
447450
"""
448-
current_models = get_api_models_by_source_label(
449-
model_catalog_rest_url=model_catalog_rest_url,
450-
model_registry_rest_headers=model_registry_rest_headers,
451-
source_label=source_label,
451+
current_models = models_with_source_id(
452+
models=get_api_models_by_source_label(
453+
model_catalog_rest_url=model_catalog_rest_url,
454+
model_registry_rest_headers=model_registry_rest_headers,
455+
source_label=source_label,
456+
),
457+
source_id=source_id,
452458
)
453459
# Raise AssertionError if condition not met - this will be retried
454460
assert current_models == expected_models, f"Expected models {expected_models}, got {current_models}"
@@ -528,6 +534,11 @@ def wait_for_catalog_source_restore(
528534
return True
529535

530536

537+
def models_with_source_id(models: set[str], source_id: str) -> set[str]:
538+
"""Prefix each model name with the source ID to create unique identifiers across sources."""
539+
return {f"{source_id}:{model}" for model in models}
540+
541+
531542
def validate_model_catalog_sources(
532543
model_catalog_sources_url: str, rest_headers: dict[str, str], expected_catalog_values: dict[str, str]
533544
) -> None:

tests/model_registry/model_catalog/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def baseline_redhat_ai_models(
459459
model_registry_rest_headers=model_registry_rest_headers,
460460
source_label="Red Hat AI",
461461
)
462-
api_models = {model["name"] for model in api_response.get("items", [])}
462+
api_models = {f"{REDHAT_AI_CATALOG_ID}:{model['name']}" for model in api_response.get("items", [])}
463463

464464
db_models = get_models_from_database_by_source(
465465
admin_client=admin_client, source_id=REDHAT_AI_CATALOG_ID, namespace=model_registry_namespace

tests/model_registry/model_catalog/constants.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,38 @@
1616
REDHAT_AI_VALIDATED_UNESCAPED_CATALOG_NAME: str = "Red Hat AI Validated"
1717
REDHAT_AI_FILTER: str = "Red+Hat+AI"
1818
REDHAT_AI_VALIDATED_FILTER = "Red+Hat+AI+Validated"
19-
19+
OTHER_MODELS_CATALOG_ID: str = "other_models"
2020
SAMPLE_MODEL_NAME3 = "mistralai/Ministral-8B-Instruct-2410"
2121
CATALOG_CONTAINER: str = "catalog"
22+
REDHAT_AI_CATALOG_ID: str = "redhat_ai_models"
23+
OTHER_MODELS: str = "Other Models"
24+
VALIDATED_CATALOG_ID: str = "redhat_ai_validated_models"
2225
DEFAULT_CATALOGS: dict[str, Any] = {
23-
"redhat_ai_models": {
26+
REDHAT_AI_CATALOG_ID: {
2427
"name": REDHAT_AI_CATALOG_NAME,
2528
"type": "yaml",
2629
"properties": {"yamlCatalogPath": "/shared-data/models-catalog.yaml"},
2730
"labels": [REDHAT_AI_CATALOG_NAME],
2831
"enabled": True,
2932
},
30-
"redhat_ai_validated_models": {
33+
VALIDATED_CATALOG_ID: {
3134
"name": REDHAT_AI_VALIDATED_CATALOG_NAME,
3235
"type": "yaml",
3336
"properties": {"yamlCatalogPath": "/shared-data/validated-models-catalog.yaml"},
3437
"labels": [REDHAT_AI_VALIDATED_CATALOG_NAME],
3538
"enabled": True,
3639
},
40+
OTHER_MODELS_CATALOG_ID: {
41+
"name": OTHER_MODELS,
42+
"type": "yaml",
43+
"properties": {"yamlCatalogPath": "/shared-data/other-models-catalog.yaml"},
44+
"labels": None,
45+
"enabled": True,
46+
},
3747
}
38-
REDHAT_AI_CATALOG_ID: str = "redhat_ai_models"
48+
3949
DEFAULT_CATALOG_FILE: str = DEFAULT_CATALOGS[REDHAT_AI_CATALOG_ID]["properties"]["yamlCatalogPath"]
40-
VALIDATED_CATALOG_ID: str = "redhat_ai_validated_models"
50+
4151
VALIDATED_CATALOG_FILE: str = DEFAULT_CATALOGS[VALIDATED_CATALOG_ID]["properties"]["yamlCatalogPath"]
4252

4353
MODEL_ARTIFACT_TYPE: str = "model-artifact"

tests/model_registry/model_catalog/metadata/test_sources_endpoint.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from simple_logger.logger import get_logger
55

66
from tests.model_registry.mcp_servers.constants import MCP_CATALOG_SOURCE_ID
7-
from tests.model_registry.model_catalog.constants import REDHAT_AI_CATALOG_ID, VALIDATED_CATALOG_ID
7+
from tests.model_registry.model_catalog.constants import (
8+
OTHER_MODELS_CATALOG_ID,
9+
REDHAT_AI_CATALOG_ID,
10+
VALIDATED_CATALOG_ID,
11+
)
812
from tests.model_registry.utils import execute_get_command
913

1014
pytestmark = [pytest.mark.usefixtures("updated_dsc_component_state_scope_session", "model_registry_namespace")]
@@ -58,8 +62,8 @@ class TestAssetTypeFilter:
5862
@pytest.mark.parametrize(
5963
"asset_type,expected_ids",
6064
[
61-
(None, {REDHAT_AI_CATALOG_ID, VALIDATED_CATALOG_ID}),
62-
("models", {REDHAT_AI_CATALOG_ID, VALIDATED_CATALOG_ID}),
65+
(None, {REDHAT_AI_CATALOG_ID, VALIDATED_CATALOG_ID, OTHER_MODELS_CATALOG_ID}),
66+
("models", {REDHAT_AI_CATALOG_ID, VALIDATED_CATALOG_ID, OTHER_MODELS_CATALOG_ID}),
6367
("mcp_servers", {MCP_CATALOG_SOURCE_ID}),
6468
("invalid_value", set()),
6569
],

0 commit comments

Comments
 (0)