Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: try 2 - prevent logging config clobbering #10192

Merged
merged 4 commits into from
Nov 17, 2022
Merged

fix: try 2 - prevent logging config clobbering #10192

merged 4 commits into from
Nov 17, 2022

Conversation

rkechols
Copy link
Contributor

@rkechols rkechols commented Nov 17, 2022

Fix for issue #10132

  • Previous behavior: loading this repository with torch.hub.load clobbers the existing logging configuration by modifying the root logger's configuration.
  • New behavior: loading this repository with torch.hub.load only clobbers the logging configuration for logger yolov5 and its descendants. This is done in a way compatible with Google Colab.

The new set_logging function uses "disable_existing_loggers": False so that any existing logging configurations are left unchanged. It also uses "propagate": False on the logger in question so that any log records sent to this logger are not also sent through any handlers from pre-existing logging configurations (which would duplicate messages).

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improved logging configurability in yolov5 utils.

πŸ“Š Key Changes

  • Added logging.config import to manage logging configurations.
  • Created a new constant LOGGING_NAME set to "yolov5" to unify logger naming.
  • Redefined set_logging function to use logging.config.dictConfig for logging setup.
  • Streamlined the process of defining log formatters, handlers, and loggers.

🎯 Purpose & Impact

  • ✨ Enhanced Customization: Utilizing dictConfig allows for more advanced logging customization and potential future expansion of logging capabilities.
  • πŸ”„ Consistency and Maintenance: Introduction of LOGGING_NAME aids in maintaining consistent logger references across the codebase.
  • πŸ›‘οΈ Isolation: Newly configured loggers do not propagate messages to parent loggers, reducing potential logging noise.
  • πŸ” Debugging and Control: The changes provide better control over the logging levels and output formats, which can aid in debugging and monitoring the application behavior, especially in multi-GPU training scenarios.

rkechols and others added 4 commits November 17, 2022 10:45
Previous behavior: loading this repository with `torch.hub.load` clobbers the existing logging configuration by modifying the root logger's configuration.
New behavior: loading this repository with `torch.hub.load` only clobbers the logging configuration for logger `yolov5` and its descendants. This is done in a way compatible with Google Colab

Signed-off-by: Ryan Echols <ryan@shadylakemedia.com>
no-op so a pre-commit hook can auto-format files

Signed-off-by: Ryan Echols <ryan@shadylakemedia.com>
@glenn-jocher glenn-jocher merged commit ff6e6e3 into ultralytics:master Nov 17, 2022
@glenn-jocher
Copy link
Member

@rkechols looks good! PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

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.

None yet

2 participants