Skip to content

Reorganize HF tests and add filter by name tests for HF models#986

Merged
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:hf_filter
Jan 7, 2026
Merged

Reorganize HF tests and add filter by name tests for HF models#986
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:hf_filter

Conversation

@dbasunag
Copy link
Copy Markdown
Collaborator

@dbasunag dbasunag commented Jan 6, 2026

Description

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Summary by CodeRabbit

  • Tests
    • Added tests for HuggingFace model search filtering capability
    • Added tests for HuggingFace model sorting functionality across multiple fields and directions
    • Added tests for model artifact search and artifact-type filtering
    • Reorganized test structure for improved maintainability

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 6, 2026

The following are automatically added/executed:

  • PR size label.
  • Run pre-commit
  • Run tox
  • Add PR author as the PR assignee
  • Build image based on the PR

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To Cherry-pick a merged PR /cherry-pick <target_branch_name> to the PR. If <target_branch_name> is valid,
    and the current PR is merged, a cherry-picked PR would be created and linked to the current PR.
  • To build and push image to quay, add /build-push-pr-image in a comment. This would create an image with tag
    pr-<pr_number> to quay repository. This image tag, however would be deleted on PR merge or close action.
Supported labels

{'/hold', '/wip', '/cherry-pick', '/build-push-pr-image', '/lgtm', '/verified'}

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

This change refactors test organization by extracting specialized test classes into dedicated modules: HuggingFace model search and sorting tests are created in new files, artifact search tests are moved from the general test_model_search.py to a dedicated test_model_artifact_search.py file, and corresponding imports are cleaned up.

Changes

Cohort / File(s) Summary
New HuggingFace test modules
tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py, tests/model_registry/model_catalog/huggingface/test_huggingface_model_sorting.py
Adds new test classes for HuggingFace-specific functionality: TestHuggingFaceModelSearch validates catalog filtering by model name; TestHuggingFaceModelsSorting validates sorting by ID, NAME, CREATE_TIME, and LAST_UPDATE_TIME in both ASC/DESC directions. Both use fixtures for configuration and API interaction.
Artifact search test extraction
tests/model_registry/model_catalog/search/test_model_artifact_search.py
New file introducing TestSearchModelArtifact with three parameterized tests: validates artifact filtering by type, error handling for invalid types, and multi-type filtering. Uses dictdiffer.diff for cross-validation and adds imports for MODEL_ARTIFACT_TYPE and METRICS_ARTIFACT_TYPE.
Test reorganization and cleanup
tests/model_registry/model_catalog/search/test_model_search.py, tests/model_registry/model_catalog/sorting/test_model_sorting.py
Removes TestSearchModelArtifact class and its parameterized tests from test_model_search.py; removes TestHuggingFaceModelsSorting class from test_model_sorting.py. Corresponding imports (MODEL_ARTIFACT_TYPE, METRICS_ARTIFACT_TYPE, get_hf_catalog_str) are eliminated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: reorganizing HuggingFace tests into separate files and adding new test coverage for filtering HF models by name.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In
@tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py:
- Around line 46-47: The test indexes result["items"][0] without ensuring items
is non-empty; add a bounds check (e.g., assert result.get("items") and
len(result["items"]) > 0 or assert result.get("size", 0) > 0) before accessing
the first element so the assertion hf_model_name == result["items"][0]["name"]
cannot raise IndexError and provides a clear failure message if no items are
returned.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ce4e49 and e2fa09f.

📒 Files selected for processing (5)
  • tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py
  • tests/model_registry/model_catalog/huggingface/test_huggingface_model_sorting.py
  • tests/model_registry/model_catalog/search/test_model_artifact_search.py
  • tests/model_registry/model_catalog/search/test_model_search.py
  • tests/model_registry/model_catalog/sorting/test_model_sorting.py
💤 Files with no reviewable changes (1)
  • tests/model_registry/model_catalog/search/test_model_search.py
🧰 Additional context used
🧬 Code graph analysis (4)
tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py (3)
tests/model_registry/model_catalog/utils.py (2)
  • get_hf_catalog_str (632-674)
  • get_models_from_catalog_api (504-557)
tests/model_registry/model_catalog/conftest.py (1)
  • updated_catalog_config_map (103-124)
tests/model_registry/conftest.py (2)
  • model_catalog_rest_url (641-650)
  • model_registry_rest_headers (325-326)
tests/model_registry/model_catalog/search/test_model_artifact_search.py (2)
tests/model_registry/model_catalog/conftest.py (1)
  • randomly_picked_model_from_catalog_api_by_source (204-257)
tests/model_registry/model_catalog/search/utils.py (1)
  • fetch_all_artifacts_with_dynamic_paging (261-292)
tests/model_registry/model_catalog/huggingface/test_huggingface_model_sorting.py (3)
tests/model_registry/model_catalog/sorting/utils.py (1)
  • assert_model_sorting (409-424)
tests/model_registry/model_catalog/utils.py (1)
  • get_hf_catalog_str (632-674)
tests/model_registry/conftest.py (2)
  • model_catalog_rest_url (641-650)
  • model_registry_rest_headers (325-326)
tests/model_registry/model_catalog/sorting/test_model_sorting.py (1)
tests/model_registry/model_catalog/utils.py (1)
  • get_models_from_catalog_api (504-557)
🪛 Ruff (0.14.10)
tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py

29-29: Unused method argument: updated_catalog_config_map

(ARG002)

tests/model_registry/model_catalog/search/test_model_artifact_search.py

296-296: Unused method argument: enabled_model_catalog_config_map

(ARG002)


362-362: Unused method argument: enabled_model_catalog_config_map

(ARG002)


401-401: Unused method argument: enabled_model_catalog_config_map

(ARG002)

tests/model_registry/model_catalog/huggingface/test_huggingface_model_sorting.py

40-40: Unused method argument: updated_catalog_config_map

(ARG002)

🔇 Additional comments (6)
tests/model_registry/model_catalog/sorting/test_model_sorting.py (1)

5-5: LGTM! Clean refactoring.

The removal of the get_hf_catalog_str import aligns with the extraction of HuggingFace-specific tests to a dedicated module. The import cleanup is correct since this utility is no longer referenced in this file.

tests/model_registry/model_catalog/huggingface/test_huggingface_model_search.py (1)

29-29: False positive from static analysis.

The updated_catalog_config_map parameter is required for the fixture's side effects (configuring the catalog with HuggingFace sources). This is a standard pytest pattern where fixtures are used for setup even when not directly referenced in the test body.

tests/model_registry/model_catalog/huggingface/test_huggingface_model_sorting.py (1)

1-49: LGTM! Well-structured HuggingFace sorting tests.

The test follows established patterns from the original test_model_sorting.py and provides comprehensive coverage of sorting functionality across all standard fields (ID, NAME, CREATE_TIME, LAST_UPDATE_TIME) in both directions. The reuse of the assert_model_sorting utility maintains consistency across the test suite.

Note: The static analysis warning about unused updated_catalog_config_map (line 40) is a false positive—the fixture is required for its side effects (catalog configuration setup).

tests/model_registry/model_catalog/search/test_model_artifact_search.py (3)

277-348: LGTM! Thorough artifact type validation.

The test validates artifact type filtering comprehensively:

  1. Fetches both complete and filtered artifact sets with dynamic paging
  2. Creates a lookup structure for efficient validation
  3. Verifies each filtered artifact exists in the complete set using dictdiffer.diff for exact matching
  4. Confirms no artifacts of the specified type were missed by the filter

The two-way validation (existence + completeness) ensures the filter returns exactly the expected artifacts.

Note: The static analysis warning about unused enabled_model_catalog_config_map (line 296) is a false positive—the fixture is required for catalog setup.


360-387: LGTM! Proper error handling validation.

The test correctly verifies that invalid artifact types raise ResourceNotFoundError with the expected error message format. This ensures API consumers receive clear, actionable error messages.

Note: The static analysis warning about unused enabled_model_catalog_config_map (line 362) is a false positive—the fixture is required for catalog setup.


399-433: LGTM! Multi-type filtering validation.

The test validates that filtering by multiple artifact types (METRICS and MODEL) returns the complete set of artifacts for a model, confirming that the comma-separated artifactType parameter works as expected.

Note: The static analysis warning about unused enabled_model_catalog_config_map (line 401) is a false positive—the fixture is required for catalog setup.

Copy link
Copy Markdown
Contributor

@fege fege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@dbasunag dbasunag enabled auto-merge (squash) January 7, 2026 10:53
@dbasunag dbasunag merged commit d7158b9 into opendatahub-io:main Jan 7, 2026
10 checks passed
@dbasunag dbasunag deleted the hf_filter branch January 7, 2026 10:53
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 7, 2026

Status of building tag latest: success.
Status of pushing tag latest to image registry: success.

mwaykole pushed a commit to mwaykole/opendatahub-tests that referenced this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants