Skip to content

feat(infra): diagnostics utils, better terminal warnings#124

Open
stanlrt wants to merge 16 commits intomainfrom
123-create-the-errorwarning-tracking-logic
Open

feat(infra): diagnostics utils, better terminal warnings#124
stanlrt wants to merge 16 commits intomainfrom
123-create-the-errorwarning-tracking-logic

Conversation

@stanlrt
Copy link
Copy Markdown
Collaborator

@stanlrt stanlrt commented May 8, 2026

Summary

  • New src/raitap/utils/warnings.py module: WarningOrigin dataclass, resolve_warn_origin (frame walk for raitap subsystem + third-party lib detection), suppress_warning adapter helper, is_dev_install heuristic, docs_url mapper.
  • RaitapRichHandler._emit_panel now branches on is_dev_install() and the resolved origin: dev shows <Subsystem> · path:line, installed shows <Subsystem> linked to docs, third-party adds via <lib>. Frame-walk logic moved out of console.py.
  • Captum adapter now calls suppress_warning(...) at import to silence the Input Tensor … required_grads UserWarning that captum auto-fixes anyway.

Closes #123 (infra portion). Out of scope per plan: full error-message rewrap (issue #22) — this only ships the infrastructure that #22 will build on, plus one captum smoke-test.

Test plan

  • uv run pytest — 573 passed, 22 skipped (pre-existing failures gated on missing optional deps unaffected).
  • 13 new unit tests for resolve_warn_origin, is_dev_install (mocked __file__), docs_url, suppress_warning.
  • uv run ruff check . + uv run ruff format --check . clean.
  • uv run pyright on changed files: 0 errors.
  • uv run raitap smoke test: dev mode renders ▲ Warning · Metrics · <full path>; captum warning no longer appears.
  • Installed-mode rendering (post-merge wheel install) shows ▲ Warning · Metrics linked to docs (manual verification when wheel published).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 8, 2026 16:21
@stanlrt stanlrt linked an issue May 8, 2026 that may be closed by this pull request
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a centralized warning infrastructure to classify warning origins (raitap subsystem + known third-party libraries), render warning panels differently for dev vs installed users (paths vs docs links), and suppress a noisy Captum UserWarning at runtime.

Changes:

  • Added raitap.utils.warnings for origin resolution, docs-link mapping, dev-install detection, and a suppress_warning() helper.
  • Updated Rich warning panel rendering to use resolved origins and audience-aware headers (dev: path/line; installed: docs link; third-party: “via ”).
  • Suppressed Captum’s repetitive “required_grads” warning at import time and aligned pytest warning filters accordingly; added unit tests for the new warnings utilities.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/raitap/utils/warnings.py New warning infrastructure (origin classification, suppression helper, dev-install heuristic, docs URL mapping, origin stash queue).
src/raitap/utils/tests/test_warnings.py New unit tests covering origin resolution, suppression, dev-install detection, and docs URL generation.
src/raitap/utils/console.py Moves frame-walk logic out of console; warning panel header now uses resolved origin + dev/install branching.
src/raitap/utils/__init__.py Exposes WarningOrigin and suppress_warning from the utils package.
src/raitap/transparency/explainers/captum_explainer.py Silences Captum’s noisy UserWarning at import time via suppress_warning().
pyproject.toml Documents/keeps pytest filterwarnings entry to match runtime suppression behavior.

Comment thread src/raitap/utils/console.py Outdated
Comment thread src/raitap/utils/warnings.py Outdated
Comment thread src/raitap/utils/warnings.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Comment thread src/raitap/transparency/explainers/captum_explainer.py
Comment thread src/raitap/utils/warnings.py Outdated
Comment thread src/raitap/utils/warnings.py Outdated
@stanlrt stanlrt requested a review from pizzajojo May 8, 2026 18:32
@stanlrt stanlrt changed the title feat(infra): warning infra module + audience-aware panels + captum suppression feat(infra): diagnostics module + audience-aware panels + captum suppression May 8, 2026
@stanlrt stanlrt changed the title feat(infra): diagnostics module + audience-aware panels + captum suppression feat(infra): diagnostics module, better terminal warnings May 8, 2026
@stanlrt stanlrt changed the title feat(infra): diagnostics module, better terminal warnings feat(infra): diagnostics utils, better terminal warnings May 8, 2026
@stanlrt stanlrt self-assigned this May 8, 2026
@stanlrt stanlrt mentioned this pull request May 8, 2026
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.

Create the error/warning tracking logic

2 participants