MCPcopy Create free account
hub / github.com/AMAP-ML/EMF / warning_handler

Function warning_handler

trl/trl/scripts/utils.py:107–108  ·  view source on GitHub ↗
(message, category, filename, lineno, file=None, line=None)

Source from the content-addressed store, hash-verified

105
106 # Custom warning handler to redirect warnings to the logging system
107 def warning_handler(message, category, filename, lineno, file=None, line=None):
108 logging.warning(f"{filename}:{lineno}: {category.__name__}: {message}")
109
110 # Add the custom warning handler - we need to do that before importing anything to make sure the loggers work well
111 warnings.showwarning = warning_handler

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected