Skip to content

fix(logging): drop dead _HFSymlinksInfoFilter and redundant TasksManager demote filter#953

Merged
timenick merged 1 commit into
mainfrom
timenick-hf-symlinks-filter-dead-code
Jun 24, 2026
Merged

fix(logging): drop dead _HFSymlinksInfoFilter and redundant TasksManager demote filter#953
timenick merged 1 commit into
mainfrom
timenick-hf-symlinks-filter-dead-code

Conversation

@timenick

Copy link
Copy Markdown
Collaborator

Closes #909.

_warnings.py had two "demote WARNINGINFO" logging filters that relabel records but don't actually suppress them. The CLI uses the root logger level as the sole emit-time gate (handler is NOTSET), so a filter that rewrites levelno after the gate has passed cannot hide a record — it only changes the printed label.

_HFSymlinksInfoFilter was dead code

_TasksManagerFilter was redundant

  • It demoted optimum's "TasksManager returned …" WARNING on optimum.exporters.tasks.
  • fix(cli): quiet third-party optimum logger noise in normal output #904 added a verbosity-conditional ERROR floor on the parent optimum logger in configure_logging. Because optimum.exporters.tasks inherits its effective level from optimum, the notice is already gated at the source: hidden by default, shown at -v/-vv. The demote filter only relabeled the record at -v; it provided no suppression.

Changes

  • Remove both filter classes and their addFilter registrations in src/winml/modelkit/_warnings.py.
  • Keep the filterwarnings("ignore") suppressor; refresh its comment and add a NOTE that optimum's informational WARNINGs are gated by the ERROR floor in utils/logging.py (so no demote filter is needed and one must not be re-added).
  • Replace the obsolete _HFSymlinksInfoFilter test in tests/unit/test_warnings_configure.py with a regression test that the HF symlinks UserWarning is suppressed (plus a specificity check that unrelated symlinks warnings pass through).
  • Add test_optimum_child_logger_gated_by_parent_floor to tests/unit/utils/test_logging.py proving optimum.exporters.tasks is isEnabledFor(WARNING) False at default and True at -v — locking in floor-based gating.

Behavior

  • HF symlinks warning: unchanged (fully suppressed before and after).
  • TasksManager notice: hidden by default (unchanged); at -v it now prints at its native WARNING level instead of a relabeled INFO line — more truthful.

…ger demote filter (#909)

_HFSymlinksInfoFilter (added #647) never ran: #709's
filterwarnings("ignore", ...huggingface_hub...symlinks...) drops the
warning at the Python warnings layer before captureWarnings can route it
to the py.warnings logger, so the demote-to-INFO filter never executed.
It only relabeled records anyway -- the root-level gate runs at emit time
before a filter can rewrite levelno, so it never suppressed anything.

_TasksManagerFilter is now redundant: #904 floors the optimum logger at
ERROR in configure_logging (verbosity-conditional), which gates the child
optimum.exporters.tasks where the "TasksManager returned ..." notice
originates -- hidden by default, shown at -v/-vv.

Remove both filters; keep the filterwarnings("ignore") suppressor and add
a NOTE pointing to the optimum floor. Replace the obsolete
_HFSymlinksInfoFilter test with a suppression regression test and add a
floor-gating test for the optimum child logger.
@timenick timenick requested a review from a team as a code owner June 24, 2026 05:57

@DingmaomaoBJTU DingmaomaoBJTU left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both removed filters are verified dead/redundant after tracing the execution path.

_HFSymlinksInfoFilter: The filterwarnings(ignore) added in #709 suppresses the warning at the Python warnings layer, before captureWarnings(True) can route it to the py.warnings logger. The demote filter never had a record to process. Dead code confirmed.

_TasksManagerFilter: optimum.exporters.tasks inherits its effective level from the optimum parent. configure_logging (#904) pins optimum at ERROR at default verbosity, so WARNING records are rejected by level check before reaching any filter. At -v the floor drops, but the filter only relabeled records anyway. Redundant confirmed.

Remaining references: Only a clarifying comment in test_logging.py -- no live code references to either symbol.

Tests: Old tests covered the dead demote-filter behavior; new tests correctly exercise the actual suppression mechanism. All 7 tests pass.

Minor observation: _restore_logging_filters does not restore warnings module state, but both new tests use catch_warnings(record=True) + resetwarnings() which fully own the warnings stack inside their context.

@timenick timenick merged commit e244e35 into main Jun 24, 2026
9 checks passed
@timenick timenick deleted the timenick-hf-symlinks-filter-dead-code branch June 24, 2026 06:36
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.

_HFSymlinksInfoFilter is dead code; demote-to-INFO log filters relabel but don't suppress

2 participants