Skip to content

fix: label tests needed update to accomodate mcp labels#1362

Merged
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:label_mcp
Apr 6, 2026
Merged

fix: label tests needed update to accomodate mcp labels#1362
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:label_mcp

Conversation

@dbasunag
Copy link
Copy Markdown
Collaborator

@dbasunag dbasunag commented Apr 6, 2026

Pull Request

Summary

Fixes ODH nightly failures and failures against 3.4 smoke

Related Issues

  • Fixes:
  • JIRA:

Please review and indicate how it has been tested

  • Locally
  • Jenkins

Additional Requirements

  • If this PR introduces a new test image, did you create a PR to mirror it in disconnected environment?
  • If this PR introduces new marker(s)/adds a new component, was relevant ticket created to update relevant Jenkins job?

Summary by CodeRabbit

  • Tests
    • Converted a single-case labels test into parameterized smoke tests covering multiple asset types.
    • Added a shared fixture supplying expected label sets for each asset type and updated tests to validate API responses against those sets.
    • Adjusted test label data to include asset-type information so tests accurately reflect label classifications.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 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

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

sheltoncyril
sheltoncyril previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Contributor

@sheltoncyril sheltoncyril left a comment

Choose a reason for hiding this comment

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

/lgtm

SB159
SB159 previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Contributor

@SB159 SB159 left a comment

Choose a reason for hiding this comment

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

/lgtm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

Parameterized the labels endpoint test over asset_type ("models", "mcp_servers"), moved expected-label computation into a new fixture expected_labels_by_asset_type, and adjusted label filtering logic in an existing conftest to include assetType on a test label.

Changes

Cohort / File(s) Summary
Metadata test
tests/model_registry/model_catalog/metadata/test_labels_endpoint.py
Converted test_labels_endpoint_default_data into a parameterized smoke test over asset_type. Removed admin_client and model_registry_namespace params; added asset_type: Literal["models", "mcp_servers"] and expected_labels_by_asset_type. Test now calls get_labels_from_api(..., asset_type=asset_type) and verifies against the fixture-provided expected labels.
Fixture: expected labels
tests/model_registry/model_catalog/metadata/conftest.py
Added pytest fixture expected_labels_by_asset_type(request, admin_client, model_registry_namespace) that reads request.param, calls get_labels_from_configmaps, filters label dicts by assetType == asset_type, and returns the filtered list for the test.
Test data patch
tests/model_registry/model_catalog/conftest.py
Updated labels_configmap_patch to add assetType: "models" to the test-dynamic label entry so dynamic test label conforms to same schema used in filtering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly addresses the main change: updating label tests to accommodate MCP labels, which aligns with the changeset modifications across three test files.
Description check ✅ Passed Description includes a summary of changes and indicates local testing was performed, but lacks specific details about what was fixed and links to related issues/tickets are incomplete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com>

Co-Authored-By: Claude <noreply@anthropic.com>
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/model_registry/model_catalog/metadata/test_labels_endpoint.py`:
- Around line 29-33: The test signature includes a non-existent fixture
expected_labels_by_asset_type which breaks test collection; remove that fixture
parameter from test_labels_endpoint_default_data and instead derive the expected
labels inside the test using the existing fixtures and the asset_type parameter
(e.g., lookup expected labels from an available fixture or a small mapping keyed
by asset_type), and apply the same fix to the second parametrized case
referenced around line 42 so the test uses only valid fixtures
(model_catalog_rest_url, asset_type) and computes expected labels locally before
assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: d7ec1a97-fff2-4102-b0a2-ae84095e6317

📥 Commits

Reviewing files that changed from the base of the PR and between c74eb5a and cf41615.

📒 Files selected for processing (1)
  • tests/model_registry/model_catalog/metadata/test_labels_endpoint.py

Comment thread tests/model_registry/model_catalog/metadata/test_labels_endpoint.py
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

🧹 Nitpick comments (1)
tests/model_registry/model_catalog/metadata/conftest.py (1)

16-17: O(n²) complexity and implicit logic in label partitioning.

Line 17 uses label not in mcp_labels which performs a linear scan for each label. More critically, it relies on object identity rather than the explicit condition. For consistency with line 16 and clarity:

     mcp_labels = [label for label in all_labels if label.get("assetType") == "mcp_servers"]
-    model_labels = [label for label in all_labels if label not in mcp_labels]
+    model_labels = [label for label in all_labels if label.get("assetType") != "mcp_servers"]

This also correctly handles labels without an assetType field (they'll be included in model_labels).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/model_registry/model_catalog/metadata/conftest.py` around lines 16 -
17, The current partitioning creates mcp_labels and then builds model_labels
using "label not in mcp_labels", causing O(n²) behavior and relying on object
identity; change the model_labels comprehension to mirror the explicit condition
used for mcp_labels by using label.get("assetType") != "mcp_servers" so you
filter by the assetType key (which also correctly includes labels missing
assetType) rather than membership testing against mcp_labels.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/model_registry/model_catalog/metadata/test_labels_endpoint.py`:
- Around line 29-34: The test function test_labels_endpoint_default_data is
missing a return type annotation; update its signature to include "-> None"
(i.e., def test_labels_endpoint_default_data(... ) -> None:) so it satisfies
mypy's disallow_untyped_defs rule and preserves the existing parameters
(model_catalog_rest_url, expected_labels_by_asset_type, asset_type) and
behavior.

---

Nitpick comments:
In `@tests/model_registry/model_catalog/metadata/conftest.py`:
- Around line 16-17: The current partitioning creates mcp_labels and then builds
model_labels using "label not in mcp_labels", causing O(n²) behavior and relying
on object identity; change the model_labels comprehension to mirror the explicit
condition used for mcp_labels by using label.get("assetType") != "mcp_servers"
so you filter by the assetType key (which also correctly includes labels missing
assetType) rather than membership testing against mcp_labels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4db57763-de0a-43c2-84a5-7ddbbf37c151

📥 Commits

Reviewing files that changed from the base of the PR and between cf41615 and affe2b2.

📒 Files selected for processing (2)
  • tests/model_registry/model_catalog/metadata/conftest.py
  • tests/model_registry/model_catalog/metadata/test_labels_endpoint.py

Comment thread tests/model_registry/model_catalog/metadata/test_labels_endpoint.py
mwaykole
mwaykole previously approved these changes Apr 6, 2026
Comment thread tests/model_registry/model_catalog/metadata/conftest.py Outdated
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com>

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@kami619 kami619 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@SB159 SB159 left a comment

Choose a reason for hiding this comment

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

/lgtm

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.

♻️ Duplicate comments (1)
tests/model_registry/model_catalog/metadata/test_labels_endpoint.py (1)

30-35: ⚠️ Potential issue | 🟡 Minor

Add explicit -> None return annotation on the modified test method.

Line 30 defines test_labels_endpoint_default_data without a return type, which violates the repo’s mypy setting for untyped defs.

Suggested patch
     def test_labels_endpoint_default_data(
         self,
         model_catalog_rest_url: list[str],
         expected_labels_by_asset_type: list[dict[str, Any]],
         asset_type: Literal["models", "mcp_servers"],
-    ):
+    ) -> None:

As per coding guidelines, "Mypy: strict-ish settings—add type annotations for new defs, disallow untyped defs/incomplete defs, disallow implicit Optional, and enable error codes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/model_registry/model_catalog/metadata/test_labels_endpoint.py` around
lines 30 - 35, The test function test_labels_endpoint_default_data is missing an
explicit return annotation; update its signature to include "-> None" to satisfy
the repository's mypy rules (untyped defs disallowed). Locate the def
test_labels_endpoint_default_data(...) in
tests/model_registry/model_catalog/metadata/test_labels_endpoint.py and add the
"-> None" return type to the function signature while keeping parameters
unchanged; no other logic changes are required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/model_registry/model_catalog/metadata/test_labels_endpoint.py`:
- Around line 30-35: The test function test_labels_endpoint_default_data is
missing an explicit return annotation; update its signature to include "-> None"
to satisfy the repository's mypy rules (untyped defs disallowed). Locate the def
test_labels_endpoint_default_data(...) in
tests/model_registry/model_catalog/metadata/test_labels_endpoint.py and add the
"-> None" return type to the function signature while keeping parameters
unchanged; no other logic changes are required.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f05c869e-f05a-425d-a5e8-62efbb124d0e

📥 Commits

Reviewing files that changed from the base of the PR and between affe2b2 and b616ac0.

📒 Files selected for processing (3)
  • tests/model_registry/model_catalog/conftest.py
  • tests/model_registry/model_catalog/metadata/conftest.py
  • tests/model_registry/model_catalog/metadata/test_labels_endpoint.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/model_registry/model_catalog/metadata/conftest.py

@dbasunag dbasunag merged commit c5f1ce8 into opendatahub-io:main Apr 6, 2026
13 checks passed
@dbasunag dbasunag deleted the label_mcp branch April 6, 2026 16:41
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

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

Comment on lines +22 to +29
@pytest.mark.parametrize(
"expected_labels_by_asset_type, asset_type",
[
pytest.param("models", "models", id="test_models"),
pytest.param("mcp_servers", "mcp_servers", id="test_mcp_servers"),
],
indirect=["expected_labels_by_asset_type"],
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably we should test the case when no asset type is passed. It should return model labels if we are consistent with the other endpoints that have asset_type

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.

7 participants