Skip to content

Remove unused fixture and update tox to include fixtures that are not easy to find#522

Merged
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:handle_unused_code
Aug 14, 2025
Merged

Remove unused fixture and update tox to include fixtures that are not easy to find#522
dbasunag merged 2 commits intoopendatahub-io:mainfrom
dbasunag:handle_unused_code

Conversation

@dbasunag
Copy link
Copy Markdown
Collaborator

@dbasunag dbasunag commented Aug 13, 2025

These are going to cause tox failures soon.
RedHatQE/python-utility-scripts#203

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
    • Removed an obsolete fixture used for per-component state updates in integration tests; affected tests will use explicit setup or other fixtures.
  • Chores
    • Refined unused-code tooling configuration to exclude additional helper patterns, reducing false positives during analysis.

@dbasunag dbasunag requested a review from a team as a code owner August 13, 2025 22:59
@github-actions
Copy link
Copy Markdown

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

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 13, 2025

📝 Walkthrough

Walkthrough

Removed a pytest fixture from tests/conftest.py and updated tox.ini’s unused code check configuration by consolidating and expanding excluded function prefixes. No other files or public interfaces were modified.

Changes

Cohort / File(s) Summary
Test fixtures
tests/conftest.py
Removed module-scoped fixture updated_dsc_component_state that updated a single DSC component via update_components_in_dsc using request.param; other DSC-related fixtures remain unchanged.
Tooling and CI config
tox.ini
In [testenv:unused-code], consolidated --exclude-function-prefixes into a comma-separated list including pytest_, fail_if_missing_dependent_operators, enabled_kserve_in_dsc, enabled_modelmesh_in_dsc, http_s3_ovms_external_route_model_mesh_serving_runtime; retained --exclude-files generation_pb2_grpc.py.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the "Integrations" page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (3)
tox.ini (3)

14-14: Pin or bound python-utility-scripts to a version that supports these flags.

Unpinned deps can break this env if the CLI behavior/flags change (e.g., around RedHatQE/python-utility-scripts#203). Recommend pinning or setting a minimum version once verified.

After confirming which version introduced the desired behavior, update deps accordingly. Example (adjust version as appropriate):

[testenv:unused-code]
deps =
    python-utility-scripts>=X.Y.Z

If you want, I can look up the exact released version that includes the needed behavior and propose the precise constraint.


14-14: Reduce maintenance burden by factoring excludes into a variable.

The long, quoted CSV is hard to maintain and review. Factor it into an env var so changes are localized and readable.

Apply this change to the command (within the current line):

-    pyutils-unusedcode --exclude-function-prefixes "pytest_,fail_if_missing_dependent_operators,enabled_kserve_in_dsc,enabled_modelmesh_in_dsc,http_s3_ovms_external_route_model_mesh_serving_runtime" --exclude-files "generation_pb2_grpc.py"
+    pyutils-unusedcode --exclude-function-prefixes "{env:UNUSED_EXCLUDE_PREFIXES}" --exclude-files "generation_pb2_grpc.py"

And add this to setenv (outside the changed line; illustrative snippet):

setenv =
    PYTHONPATH = {toxinidir}
    UNUSED_EXCLUDE_PREFIXES = pytest_,fail_if_missing_dependent_operators,enabled_kserve_in_dsc,enabled_modelmesh_in_dsc,http_s3_ovms_external_route_model_mesh_serving_runtime

14-14: Add a short comment explaining why these are excluded (link to the upstream context).

Future maintainers will benefit from knowing these are dynamically used fixtures/hooks and intentionally excluded to avoid false positives related to RedHatQE/python-utility-scripts#203.

You could add above the command:

# These fixtures/hooks are discovered/used dynamically in pytest and can appear "unused".
# Exclusions prevent false positives; context: https://github.com/RedHatQE/python-utility-scripts/pull/203
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddc5f02 and 3f47b37.

📒 Files selected for processing (2)
  • tests/conftest.py (0 hunks)
  • tox.ini (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/conftest.py
🔇 Additional comments (3)
tox.ini (3)

14-14: Consolidating exclude prefixes into a single flag looks good.

This aligns with the PR goal to prevent upcoming tox failures by making hard-to-detect fixtures ignored by the unused-code checker.


14-14: No action required — excluded prefixes match real pytest hooks/fixtures

Search results show each excluded prefix corresponds to real definitions (pytest hooks and the specific fixtures), so the exclusion does not appear to be masking unrelated symbols.

Matches found:

  • tests/conftest.py:420 — enabled_modelmesh_in_dsc
  • tests/conftest.py:431 — enabled_kserve_in_dsc
  • tests/model_serving/model_runtime/model_validation/conftest.py:199 — pytest_generate_tests
  • tests/model_serving/model_server/conftest.py:443 — http_s3_ovms_external_route_model_mesh_serving_runtime
  • conftest.py:45 — pytest_addoption
  • conftest.py:202 — pytest_cmdline_main
  • conftest.py:206 — pytest_collection_modifyitems
  • conftest.py:274 — pytest_sessionstart
  • conftest.py:329 — pytest_fixture_setup
  • conftest.py:333 — pytest_runtest_setup
  • conftest.py:371 — pytest_runtest_call
  • conftest.py:375 — pytest_runtest_teardown
  • conftest.py:383 — pytest_report_teststatus
  • conftest.py:401 — pytest_sessionfinish
  • conftest.py:437 — pytest_exception_interact
  • conftest.py:461 — fail_if_missing_dependent_operators

No unrelated matches observed; the current exclusion list is appropriate.


14-14: Verify pyutils-unusedcode --exclude-function-prefixes accepts CSV vs repeatable flags

I couldn't find the pyutils-unusedcode implementation in this repo, so please confirm the CLI syntax locally — the flag in tox.ini may be ineffective if the tool expects repeated flags instead of a comma-separated string.

  • File/line to check:
    • tox.ini (around line 14)
    • Snippet:
      pyutils-unusedcode --exclude-function-prefixes "pytest_,fail_if_missing_dependent_operators,enabled_kserve_in_dsc,enabled_modelmesh_in_dsc,http_s3_ovms_external_route_model_mesh_serving_runtime" --exclude-files "generation_pb2_grpc.py"

Quick ways to verify (pick one):

  • Run: pyutils-unusedcode --help — check the option description (shows “repeatable” or “comma-separated”).
  • Functional test:
    • CSV form: pyutils-unusedcode --exclude-function-prefixes prefix1,prefix2
    • Repeatable form: pyutils-unusedcode --exclude-function-prefixes prefix1 --exclude-function-prefixes prefix2
    • Compare outputs.
  • Or paste the add_argument/option definition from the pyutils-unusedcode source here and I’ll confirm the exact behavior.

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
Copy link
Copy Markdown
Collaborator Author

/build-push-pr-image

@github-actions
Copy link
Copy Markdown

Status of building tag pr-522: success.
Status of pushing tag pr-522 to image registry: success.

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

@dbasunag dbasunag merged commit c91f913 into opendatahub-io:main Aug 14, 2025
10 checks passed
@dbasunag dbasunag deleted the handle_unused_code branch August 14, 2025 16:26
@github-actions
Copy link
Copy Markdown

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.

5 participants