Skip to content

ci: mute dynamic __warningregistry__ logs noise in pytest suite#8893

Open
Priyanshu31102003 wants to merge 1 commit into
Project-MONAI:devfrom
Priyanshu31102003:fix-warning-registry-noise
Open

ci: mute dynamic __warningregistry__ logs noise in pytest suite#8893
Priyanshu31102003 wants to merge 1 commit into
Project-MONAI:devfrom
Priyanshu31102003:fix-warning-registry-noise

Conversation

@Priyanshu31102003
Copy link
Copy Markdown

Fixes #8892

Description

During automated test execution, the logs were getting flooded with thousands of verbose lines when unittest.TestCase.assertWarns internally triggered property accessors for __warningregistry__ on dynamic configurations.

This PR globally configures pytest inside setup.cfg to ignore and suppress regex pattern filter hits matching .*__warningregistry__.*, significantly cleaning up the CI/CD pipeline output logs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds a single warning filter to the test utilities module to suppress warnings about __warningregistry__ access that are generated when tests use unittest.TestCase.assertWarns. The filter is applied at module import time and targets warnings matching the pattern .*Accessing.*__warningregistry__.*, preventing thousands of unrelated warning lines from cluttering test output.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive Description explains the problem, solution, and expected outcome. However, the PR description template requires completion of specific checkboxes that are missing. Complete the 'Types of changes' checkboxes and verify test execution statements in the template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly describes the main change: suppressing warningregistry logs in pytest suite via CI configuration.
Linked Issues check ✅ Passed Changes suppress warningregistry messages by filtering warnings in test utilities, directly addressing issue #8892's excessive warning logs during test execution.
Out of Scope Changes check ✅ Passed The single change (adding a warnings filter) is narrowly scoped to address the excessive warningregistry logs objective.

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

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

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.

@Priyanshu31102003 Priyanshu31102003 force-pushed the fix-warning-registry-noise branch 3 times, most recently from 472987e to 3cce064 Compare June 2, 2026 00:01
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/test_utils.py (1)

31-31: ⚡ Quick win

Add explanatory comment.

No comment documents why this filter exists. Future maintainers may not understand the context.

Suggested documentation
 import warnings
+# Suppress noisy __warningregistry__ access warnings triggered by unittest.assertWarns (see `#8892`)
 warnings.filterwarnings("ignore", message=".*Accessing.*__warningregistry__.*")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_utils.py` at line 31, Add a brief explanatory comment directly
above the warnings.filterwarnings("ignore",
message=".*Accessing.*__warningregistry__.*") call describing why this specific
warning is being suppressed (e.g., which test/actions trigger it and that it is
an expected, benign Python-internal warning), so future maintainers understand
the intent; keep the comment concise and reference the exact filter line in the
comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_utils.py`:
- Line 31: The warnings.filterwarnings call in tests/test_utils.py currently
uses message=".*Accessing.*__warningregistry__.*", which diverges from the test
runner's PYTHONWARNINGS pattern; change the message argument in the
warnings.filterwarnings(...) invocation to "Accessing.*__warningregistry__.*"
(or alternately add a brief comment next to that warnings.filterwarnings call
explaining why the leading ".*" was removed) so the regex matching behavior is
aligned with runtests.sh's PYTHONWARNINGS setting.

---

Nitpick comments:
In `@tests/test_utils.py`:
- Line 31: Add a brief explanatory comment directly above the
warnings.filterwarnings("ignore", message=".*Accessing.*__warningregistry__.*")
call describing why this specific warning is being suppressed (e.g., which
test/actions trigger it and that it is an expected, benign Python-internal
warning), so future maintainers understand the intent; keep the comment concise
and reference the exact filter line in the comment.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ca429843-c7ea-4cfe-bc10-0277f2ebdc6b

📥 Commits

Reviewing files that changed from the base of the PR and between 472987e and 3cce064.

📒 Files selected for processing (3)
  • runtests.sh
  • setup.cfg
  • tests/test_utils.py
✅ Files skipped from review due to trivial changes (1)
  • setup.cfg
🚧 Files skipped from review as they are similar to previous changes (1)
  • runtests.sh

Comment thread tests/test_utils.py Outdated
@Priyanshu31102003 Priyanshu31102003 force-pushed the fix-warning-registry-noise branch 2 times, most recently from e4bb54f to c8d201c Compare June 2, 2026 00:11
Signed-off-by: jet1technology-tech <jet1technology@ryngo.in>
@Priyanshu31102003 Priyanshu31102003 force-pushed the fix-warning-registry-noise branch from c8d201c to f20fb9b Compare June 2, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excessive Warning Printing During Tests

2 participants