Skip to content

Commit 8e38f5b

Browse files
committed
fix: correct Catalog names
Added catalog names as constants and included labels field in catalog definitions. Renamed REDHATI_AI_FILTER to REDHAT_AI_FILTER and REDHATI_AI_VALIDATED_FILTER to REDHAT_AI_VALIDATED_FILTER for consistency.
1 parent 1e1e28f commit 8e38f5b

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

tests/model_registry/model_catalog/constants.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,28 @@
1111
{"id": CUSTOM_CATALOG_ID2, "model_name": SAMPLE_MODEL_NAME2},
1212
]
1313

14+
REDHAT_AI_CATALOG_NAME: str = "Red Hat AI"
15+
REDHAT_AI_VALIDATED_CATALOG_NAME: str = "Red Hat AI validated"
16+
1417
SAMPLE_MODEL_NAME3 = "mistralai/Ministral-8B-Instruct-2410"
1518
CATALOG_CONTAINER: str = "catalog"
1619
DEFAULT_CATALOGS: dict[str, Any] = {
1720
"redhat_ai_models": {
18-
"name": "Red Hat AI models",
21+
"name": REDHAT_AI_CATALOG_NAME,
1922
"type": "yaml",
2023
"properties": {"yamlCatalogPath": "/shared-data/models-catalog.yaml"},
24+
"labels": [REDHAT_AI_CATALOG_NAME],
2125
},
2226
"redhat_ai_validated_models": {
23-
"name": "Red Hat AI validated models",
27+
"name": REDHAT_AI_VALIDATED_CATALOG_NAME,
2428
"type": "yaml",
2529
"properties": {"yamlCatalogPath": "/shared-data/validated-models-catalog.yaml"},
30+
"labels": [REDHAT_AI_VALIDATED_CATALOG_NAME],
2631
},
2732
}
2833
REDHAT_AI_CATALOG_ID: str = next(iter(DEFAULT_CATALOGS))
2934
DEFAULT_CATALOG_FILE: str = DEFAULT_CATALOGS[REDHAT_AI_CATALOG_ID]["properties"]["yamlCatalogPath"]
3035
VALIDATED_CATALOG_ID: str = tuple(DEFAULT_CATALOGS.keys())[1]
3136

32-
REDHATI_AI_FILTER: str = "Red+Hat+AI"
33-
REDHATI_AI_VALIDATED_FILTER = "Red+Hat+AI+Validated"
37+
REDHAT_AI_FILTER: str = "Red+Hat+AI"
38+
REDHAT_AI_VALIDATED_FILTER = "Red+Hat+AI+Validated"

tests/model_registry/model_catalog/test_model_search.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from simple_logger.logger import get_logger
55
from typing import Self, Any
66
from tests.model_registry.model_catalog.constants import (
7-
REDHATI_AI_FILTER,
8-
REDHATI_AI_VALIDATED_FILTER,
7+
REDHAT_AI_FILTER,
8+
REDHAT_AI_VALIDATED_FILTER,
99
REDHAT_AI_CATALOG_ID,
1010
VALIDATED_CATALOG_ID,
1111
)
@@ -29,13 +29,13 @@ def test_search_model_catalog_source_label(
2929
"""
3030

3131
result = execute_get_command(
32-
url=f"{model_catalog_rest_url[0]}models?sourceLabel={REDHATI_AI_FILTER}&pageSize=100",
32+
url=f"{model_catalog_rest_url[0]}models?sourceLabel={REDHAT_AI_FILTER}&pageSize=100",
3333
headers=model_registry_rest_headers,
3434
)
3535
redhai_ai_filter_moldels_size = result["size"]
3636

3737
result = execute_get_command(
38-
url=f"{model_catalog_rest_url[0]}models?sourceLabel={REDHATI_AI_VALIDATED_FILTER}&pageSize=100",
38+
url=f"{model_catalog_rest_url[0]}models?sourceLabel={REDHAT_AI_VALIDATED_FILTER}&pageSize=100",
3939
headers=model_registry_rest_headers,
4040
)
4141
redhai_ai_validated_filter_models_size = result["size"]
@@ -48,7 +48,7 @@ def test_search_model_catalog_source_label(
4848
result = execute_get_command(
4949
url=(
5050
f"{model_catalog_rest_url[0]}models?"
51-
f"sourceLabel={REDHATI_AI_VALIDATED_FILTER},{REDHATI_AI_FILTER}&pageSize=100"
51+
f"sourceLabel={REDHAT_AI_VALIDATED_FILTER},{REDHAT_AI_FILTER}&pageSize=100"
5252
),
5353
headers=model_registry_rest_headers,
5454
)
@@ -85,11 +85,11 @@ def test_search_model_catalog_invalid_source_label(
8585
[
8686
pytest.param(
8787
{"source": VALIDATED_CATALOG_ID},
88-
REDHATI_AI_VALIDATED_FILTER,
88+
REDHAT_AI_VALIDATED_FILTER,
8989
id="test_search_model_catalog_redhat_ai_validated",
9090
),
9191
pytest.param(
92-
{"source": REDHAT_AI_CATALOG_ID}, REDHATI_AI_FILTER, id="test_search_model_catalog_redhat_ai_default"
92+
{"source": REDHAT_AI_CATALOG_ID}, REDHAT_AI_FILTER, id="test_search_model_catalog_redhat_ai_default"
9393
),
9494
],
9595
indirect=["randomly_picked_model"],

tests/model_registry/model_catalog/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ def validate_model_catalog_resource(
9191

9292

9393
def validate_default_catalog(catalogs: list[dict[Any, Any]]) -> None:
94-
errors = ""
94+
errors = []
9595
for catalog in catalogs:
9696
expected_catalog = DEFAULT_CATALOGS.get(catalog["id"])
9797
assert expected_catalog, f"Unexpected catalog: {catalog}"
98-
for field in ["type", "name", "properties"]:
99-
if catalog[field] != expected_catalog[field]:
100-
errors += f"For {catalog['id']} expected {field}={expected_catalog[field]}, but got {catalog[field]}"
98+
for key, expected_value in expected_catalog.items():
99+
actual_value = catalog.get(key)
100+
if actual_value != expected_value:
101+
errors.append(f"For catalog '{catalog['id']}': expected {key}={expected_value}, but got {actual_value}")
101102

102-
assert not errors, errors
103+
assert not errors, "\n".join(errors)
103104

104105

105106
def get_catalog_str(ids: list[str]) -> str:

0 commit comments

Comments
 (0)