-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
staleIssues that haven't received updatesIssues that haven't received updates
Description
Describe the bug
in utils/logging.py there the function remove_handler seems to have a faulty assertion in it.
def add_handler(handler: logging.Handler) -> None:
"""adds a handler to the HuggingFace Diffusers' root logger."""
_configure_library_root_logger()
assert handler is not None
_get_library_root_logger().addHandler(handler)
def remove_handler(handler: logging.Handler) -> None:
"""removes given handler from the HuggingFace Diffusers' root logger."""
_configure_library_root_logger()
assert handler is not None and handler not in _get_library_root_logger().handlers # <<< THIS ONE
_get_library_root_logger().removeHandler(handler)That line seems to have a not that shouldn't be there. (the not in to be precise)
Normally I'd just do a PR to remove it, but as I'm not that familiar with the codebase, nor Python in general, and don't yet have a solid grasp of what these things actually do (I'm just playing around trying to familiarize myself), I decided to make an issue instead so people who actually know the codebase can do it.
Reproduction
from diffusers import logging
from logging import Handler
class TestHandler(Handler):
def __init__(self):
super().__init__()
def emit(self):
pass
handler = TestHandler()
logging.add_handler(handler)
logging.remove_handler(handler)Logs
Traceback (most recent call last):
File ".\test.py", line 14, in <module>
logging.remove_handler(handler)
File "C:\Users\XXX\XXX\venv\lib\site-packages\diffusers\utils\logging.py", line 221, in remove_handler
assert handler is not None and handler not in _get_library_root_logger().handlers
AssertionErrorSystem Info
diffusersversion: 0.3.0- Platform: Windows-10-10.0.19041-SP0
- Python version: 3.8.9
- PyTorch version (GPU?): 1.12.1+cpu (False)
- Huggingface_hub version: 0.9.1
- Transformers version: 4.21.3
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: Don't understand the question, but seems irrelevant.
Metadata
Metadata
Assignees
Labels
staleIssues that haven't received updatesIssues that haven't received updates