Repository navigation
docs: fix the filter that silences the auroc_confidence_metric warning - #504
pcbeingused333 wants to merge 10 commits into
Conversation
The documented filter matched module comparison_engine, but the warning is attributed to structured_model.py, so it never silenced anything. Filter by message instead, and drop the 'already migrated' framing: the warning fires on any compare_with(add_confidence_metrics=True) call. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
sromoam
left a comment
There was a problem hiding this comment.
Thank you, @pcbeingused333! This is a real improvement. The message= filter does match the warning, which the old module= filter never did, and the diagnosis in your description is spot on. A few things still need to change before this fully fixes #493.
Needs changes
-
Add the pytest form. Under pytest, a module-level
warnings.filterwarnings("ignore", ...)doesn't silence the warning. pytest wraps each test in its own warnings context and showsDeprecationWarnings regardless. Most users see this warning in their test suite, so please give the config form next to the code form, for example:[tool.pytest.ini_options] filterwarnings = [ "ignore:The 'auroc_confidence_metric' result key is deprecated:DeprecationWarning", ]
-
Remove the sentence saying the warning is attributed to
structured_model.py(around:141). That attribution is a bug in how the warning is raised (itsstacklevel), not intended behaviour. Once that bug is fixed, the sentence would be wrong. Themessage=advice stands without it. -
Correct "once per process" (
:129). With Python's default filters the warning isn't shown at all, because it's attributed to library code. Under-W erroror pytest'sfilterwarnings = error, it raises on every call, not just the first. Saying "emits aDeprecationWarning" without the frequency is accurate. -
Mention the second warning. The same
add_confidence_metrics=Truecall also emits aUserWarning("Single-document confidence metrics are a quick sanity check..."). A reader who applies your filter will still see that one and think the recipe is broken. One sentence naming it, with its ownmessage=filter, would cover it. -
Add a CHANGELOG entry under
[Unreleased], since people pasted the old filter and it never worked (see RELEASING.md).
Would be great, but optional: a test that installs the documented filter and asserts no DeprecationWarning is recorded from compare_with(add_confidence_metrics=True). That would stop the recipe from silently breaking again when the message changes.
The stacklevel bug itself is out of scope here. We'll track it in a separate issue, so please don't feel you need to fix it in this PR.
Also, a heads-up: #525 targets the same issue. Whichever lands first, we'll close the other, so it's worth a quick look to avoid duplicate effort.
On timing: I'm away until Tuesday, November 10, so my next review will be after that. Thanks again!
|
As mentioned in the review, the |
Add the pytest filterwarnings form, drop the structured_model.py attribution and the 'once per process' claim, document the second UserWarning with its own filter, add a CHANGELOG entry and a test that the documented filters silence both warnings. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
|
Thanks for the review, all points addressed in 81e87cf:
The PR body's "No CHANGELOG entry" note is now outdated; the entry is in. This comment was drafted with Claude Code. |
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com> # Conflicts: # CHANGELOG.md
sromoam
left a comment
There was a problem hiding this comment.
Thank you, @pcbeingused333, this is a really thorough follow-up! Every point from the last review is addressed, and the optional test is a great addition. Three small things before we merge:
-
Narrow the pytest claim (around
confidence-evaluation.md:141). Under pytest, only a filter set at module import time is overridden by pytest's per-test filters. Awarnings.filterwarnings(...)call inside a test or a fixture works fine (we checked with a probe test). Something like "a filter set at module level does not apply under pytest; set it in a fixture, or use thefilterwarningsconfig below" keeps readers away from a dead end without steering them off a fix that works. -
Add the pytest form for the
UserWarningtoo (around:150). Right now it only has the Python form, just after the doc explains why the Python form isn't enough under pytest. One more line in the TOML block covers it, for example:"ignore:Single-document confidence metrics are a quick sanity check:UserWarning", -
Loosen the test assertion (
tests/test_confidence_warning_filter.py:45).assert _recorded(AUROC, SINGLE_DOC) == []fails ifcompare_withever emits any unrelated warning. Please assert that neither of the two messages appears in the recorded warnings instead.
Optional, only if you have time:
- The test copies the filter strings rather than reading them from the doc, so the two could drift apart. A comment pointing at the doc section would be enough.
tests/structured_object_evaluator/conftest.pyalready resetsdeprecation._warnedautomatically. Moving the test intotests/structured_object_evaluator/(next to the existing deprecation tests intest_confidence_metrics.py) would let you drop the local fixture.- The PR description still says there's no CHANGELOG entry. A quick refresh would help the next reviewer.
Thanks again, this is very close!
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
|
Thanks for the review. The pytest wording now distinguishes import-time filters from filters installed inside tests or fixtures, and the TOML example includes the separate UserWarning filter. The test now checks only the two documented message prefixes, so unrelated warnings do not fail it; a comment links the filter constants to the documentation section. All three warning-filter tests and an unrelated-warning probe pass. The refreshed description also records the existing CHANGELOG entry. The UserWarning paragraph now explicitly refers to the AUROC Python filter, since the TOML example already covers both warnings. The test stays at the top level of This response was drafted with Codex. |
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
|
Thanks for the review. The pytest wording now distinguishes import-time filters from filters installed inside tests or fixtures, and the TOML example includes the separate UserWarning filter. The test now checks only the two documented message prefixes, so unrelated warnings do not fail it; a comment links the filter constants to the documentation section. All three warning-filter tests and an unrelated-warning probe pass. The refreshed description also records the existing CHANGELOG entry. The UserWarning paragraph now explicitly refers to the AUROC Python filter, since the TOML example already covers both warnings. The test stays at the top level of This response was drafted with Codex. |
Fixes #493
Description of Changes
The documented AUROC warning recipe now filters by message rather than the comparison engine module. It includes Python and pytest configuration forms for both the legacy AUROC
DeprecationWarningand the single-document confidenceUserWarning.A filter installed at module import time is overridden by pytest's per-test filters; installing it inside a test or fixture also works. The wording avoids relying on the warning's stacklevel attribution or frequency. A
CHANGELOG.mdentry is included.Testing
The three warning-filter tests pass. Their assertion checks that neither documented message is recorded while allowing unrelated warnings. An additional probe injecting an unrelated warning failed before this follow-up and passes afterward. Filter constants point to the corresponding documentation section.
Additional Notes
This PR was prepared with assistance from AI coding agents (Claude Code and Codex).