fix(logging): drop dead _HFSymlinksInfoFilter and redundant TasksManager demote filter#953
Conversation
…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.
DingmaomaoBJTU
left a comment
There was a problem hiding this comment.
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.
Closes #909.
_warnings.pyhad two "demoteWARNING→INFO" 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 isNOTSET), so a filter that rewriteslevelnoafter the gate has passed cannot hide a record — it only changes the printed label._HFSymlinksInfoFilterwas dead codepy.warningslogger to demote the huggingface_hub symlinksUserWarningto INFO.warnings.filterwarnings("ignore", message=r".*huggingface_hub.*cache-system.*symlinks.*"), which drops the warning at the Pythonwarningslayer beforecaptureWarningscould route it topy.warnings. The demote filter never executed._TasksManagerFilterwas redundantWARNINGonoptimum.exporters.tasks.optimumlogger inconfigure_logging. Becauseoptimum.exporters.tasksinherits its effective level fromoptimum, 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
addFilterregistrations insrc/winml/modelkit/_warnings.py.filterwarnings("ignore")suppressor; refresh its comment and add a NOTE that optimum's informational WARNINGs are gated by the ERROR floor inutils/logging.py(so no demote filter is needed and one must not be re-added)._HFSymlinksInfoFiltertest intests/unit/test_warnings_configure.pywith a regression test that the HF symlinksUserWarningis suppressed (plus a specificity check that unrelatedsymlinkswarnings pass through).test_optimum_child_logger_gated_by_parent_floortotests/unit/utils/test_logging.pyprovingoptimum.exporters.tasksisisEnabledFor(WARNING)False at default and True at-v— locking in floor-based gating.Behavior
-vit now prints at its native WARNING level instead of a relabeled INFO line — more truthful.