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
54 changes: 1 addition & 53 deletions tests/model_registry/model_catalog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
REDHAT_AI_CATALOG_ID,
DEFAULT_CATALOGS,
)
from tests.model_registry.model_catalog.utils import get_models_from_catalog_api, get_catalog_url_and_headers
from tests.model_registry.model_catalog.utils import get_models_from_catalog_api
from tests.model_registry.constants import (
CUSTOM_CATALOG_ID1,
DEFAULT_MODEL_CATALOG_CM,
DEFAULT_CUSTOM_MODEL_CATALOG,
)
from tests.model_registry.utils import (
Expand All @@ -38,57 +37,6 @@
LOGGER = get_logger(name=__name__)


@pytest.fixture(scope="session")
def enabled_model_catalog_config_map(
admin_client: DynamicClient,
model_registry_namespace: str,
current_client_token: str,
) -> ConfigMap:
"""
Enable all catalogs in the default model catalog configmap
"""
# Get operator-managed default sources ConfigMap
default_sources_cm = ConfigMap(
name=DEFAULT_MODEL_CATALOG_CM, client=admin_client, namespace=model_registry_namespace, ensure_exists=True
)

# Get the sources.yaml content from default sources
default_sources_yaml = default_sources_cm.instance.data.get("sources.yaml", "")

# Parse the YAML and extract only catalogs, enabling each one
parsed_yaml = yaml.safe_load(default_sources_yaml)
if not parsed_yaml or "catalogs" not in parsed_yaml:
raise RuntimeError("No catalogs found in default sources ConfigMap")

for catalog in parsed_yaml["catalogs"]:
catalog["enabled"] = True
enabled_yaml_dict = {"catalogs": parsed_yaml["catalogs"]}
enabled_sources_yaml = yaml.dump(enabled_yaml_dict, default_flow_style=False, sort_keys=False)

LOGGER.info("Adding enabled catalogs to model-catalog-sources ConfigMap")

# Get user-managed sources ConfigMap
user_sources_cm = ConfigMap(
name=DEFAULT_CUSTOM_MODEL_CATALOG, client=admin_client, namespace=model_registry_namespace, ensure_exists=True
)

patches = {"data": {"sources.yaml": enabled_sources_yaml}}

with ResourceEditor(patches={user_sources_cm: patches}):
# Wait for the model catalog pod to be ready
is_model_catalog_ready(client=admin_client, model_registry_namespace=model_registry_namespace)

# Get the model catalog URL and headers and wait for the API to be fully ready
catalog_url, headers = get_catalog_url_and_headers(
admin_client=admin_client,
model_registry_namespace=model_registry_namespace,
token=current_client_token,
)
wait_for_model_catalog_api(url=catalog_url, headers=headers)

yield user_sources_cm


@pytest.fixture(scope="class")
def model_catalog_config_map(
request: pytest.FixtureRequest, admin_client: DynamicClient, model_registry_namespace: str
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from typing import Self, Any
import random
from ocp_resources.config_map import ConfigMap
from tests.model_registry.model_catalog.search.utils import (
fetch_all_artifacts_with_dynamic_paging,
validate_model_artifacts_match_criteria_and,
Expand Down Expand Up @@ -49,7 +48,6 @@ class TestSearchArtifactsByFilterQuery:
)
def test_search_artifacts_by_invalid_filter_query(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict, str, str],
Expand Down Expand Up @@ -150,7 +148,6 @@ def test_search_artifacts_by_invalid_filter_query(
)
def test_filter_query_advanced_artifact_search(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict, str, str],
Expand Down Expand Up @@ -222,7 +219,6 @@ def test_filter_query_advanced_artifact_search(
)
def test_performance_artifacts_recommendations_parameter(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict, str, str],
Expand Down
15 changes: 0 additions & 15 deletions tests/model_registry/model_catalog/search/test_model_search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from dictdiffer import diff
from ocp_resources.config_map import ConfigMap
from simple_logger.logger import get_logger
from typing import Self, Any
from tests.model_registry.model_catalog.constants import (
Expand Down Expand Up @@ -33,7 +32,6 @@ class TestSearchModelCatalog:
@pytest.mark.smoke
def test_search_model_catalog_source_label(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
):
Expand Down Expand Up @@ -66,7 +64,6 @@ def test_search_model_catalog_source_label(

def test_search_model_catalog_invalid_source_label(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
):
Expand Down Expand Up @@ -109,7 +106,6 @@ def test_search_model_catalog_invalid_source_label(
)
def test_search_model_catalog_match(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict[Any, Any], str, str],
Expand Down Expand Up @@ -153,7 +149,6 @@ class TestSearchModelArtifact:
)
def test_validate_model_artifacts_by_artifact_type(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict[Any, Any], str, str],
Expand Down Expand Up @@ -219,7 +214,6 @@ def test_validate_model_artifacts_by_artifact_type(
)
def test_error_handled_for_invalid_artifact_type(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict[Any, Any], str, str],
Expand Down Expand Up @@ -258,7 +252,6 @@ def test_error_handled_for_invalid_artifact_type(
)
def test_multiple_artifact_type_filtering(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
randomly_picked_model_from_catalog_api_by_source: tuple[dict[Any, Any], str, str],
Expand Down Expand Up @@ -310,7 +303,6 @@ class TestSearchModelCatalogQParameter:
)
def test_q_parameter_basic_search(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
search_term: str,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
Expand Down Expand Up @@ -350,7 +342,6 @@ def test_q_parameter_basic_search(
)
def test_q_parameter_case_insensitive(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
search_term: str,
case_variant: str,
model_catalog_rest_url: list[str],
Expand Down Expand Up @@ -401,7 +392,6 @@ def test_q_parameter_case_insensitive(

def test_q_parameter_no_results(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
model_registry_namespace: str,
Expand Down Expand Up @@ -431,7 +421,6 @@ def test_q_parameter_no_results(
def test_q_parameter_empty_query(
self: Self,
search_term,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
):
Expand All @@ -449,7 +438,6 @@ def test_q_parameter_empty_query(

def test_q_parameter_with_source_label_filter(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
):
Expand Down Expand Up @@ -495,7 +483,6 @@ def test_q_parameter_with_source_label_filter(
class TestSearchModelsByFilterQuery:
def test_search_models_by_filter_query(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
model_registry_namespace: str,
Expand Down Expand Up @@ -541,7 +528,6 @@ def test_search_models_by_filter_query(

def test_search_models_by_invalid_filter_query(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
model_registry_namespace: str,
Expand Down Expand Up @@ -581,7 +567,6 @@ def test_search_models_by_invalid_filter_query(
@pytest.mark.downstream_only
def test_presence_performance_data_on_pod(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
admin_client: DynamicClient,
model_registry_namespace: str,
):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from typing import Self
import random
from ocp_resources.config_map import ConfigMap
from simple_logger.logger import get_logger
from tests.model_registry.model_catalog.sorting.utils import (
get_artifacts_with_sorting,
Expand Down Expand Up @@ -74,7 +73,6 @@ class TestArtifactsSorting:
)
def test_artifacts_sorting_works_correctly(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
order_by: str,
sort_order: str,
model_catalog_rest_url: list[str],
Expand Down Expand Up @@ -191,7 +189,6 @@ class TestCustomPropertiesSorting:
)
def test_custom_properties_sorting_works_correctly(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
order_by: str,
sort_order: str,
model_catalog_rest_url: list[str],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class TestModelsSorting:
)
def test_models_sorting_works_correctly(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
order_by: str,
sort_order: str,
model_catalog_rest_url: list[str],
Expand Down Expand Up @@ -62,7 +61,6 @@ class TestAccuracySorting:
)
def test_accuracy_sorting_works_correctly(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
sort_order: str | None,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
Expand Down Expand Up @@ -107,7 +105,6 @@ def test_accuracy_sorting_works_correctly(
)
def test_accuracy_sorting_works_correctly_with_filter(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
sort_order: str,
filter_query: str,
model_catalog_rest_url: list[str],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from typing import Self
from ocp_resources.config_map import ConfigMap
from simple_logger.logger import get_logger
from tests.model_registry.model_catalog.sorting.utils import (
get_sources_with_sorting,
Expand All @@ -26,7 +25,6 @@ class TestSourcesSorting:
)
def test_sources_sorting_works_correctly(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
order_by: str,
sort_order: str,
model_catalog_rest_url: list[str],
Expand All @@ -49,7 +47,6 @@ def test_sources_sorting_works_correctly(
@pytest.mark.parametrize("unsupported_field", ["CREATE_TIME", "LAST_UPDATE_TIME"])
def test_sources_rejects_unsupported_fields(
self: Self,
enabled_model_catalog_config_map: ConfigMap,
unsupported_field: str,
model_catalog_rest_url: list[str],
model_registry_rest_headers: dict[str, str],
Expand Down
5 changes: 0 additions & 5 deletions tests/model_registry/model_catalog/test_catalog_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestCatalogPreviewExistingSource:

@pytest.mark.parametrize("default_model_catalog_yaml_content", [VALIDATED_CATALOG_ID], indirect=True)
@pytest.mark.usefixtures(
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
def test_catalog_preview_included_and_excluded_models_filters(
Expand Down Expand Up @@ -82,7 +81,6 @@ def test_catalog_preview_included_and_excluded_models_filters(

@pytest.mark.parametrize("default_model_catalog_yaml_content", [VALIDATED_CATALOG_ID], indirect=True)
@pytest.mark.usefixtures(
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
def test_catalog_preview_no_filters(
Expand Down Expand Up @@ -130,7 +128,6 @@ def test_catalog_preview_no_filters(

@pytest.mark.parametrize("default_model_catalog_yaml_content", [VALIDATED_CATALOG_ID], indirect=True)
@pytest.mark.usefixtures(
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -241,7 +238,6 @@ class TestCatalogPreviewErrorHandling:
],
)
@pytest.mark.usefixtures(
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
def test_catalog_preview_invalid_config(
Expand Down Expand Up @@ -295,7 +291,6 @@ class TestCatalogPreviewUserProvidedData:
"""

@pytest.mark.usefixtures(
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
def test_catalog_preview_with_custom_catalog_data(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
pytestmark = [
pytest.mark.usefixtures(
"updated_dsc_component_state_scope_session",
"enabled_model_catalog_config_map",
"model_registry_namespace",
)
]
Expand Down
Loading