Add register_tracker_class to register custom trackers by name#4060
Open
javierdejesusda wants to merge 1 commit into
Open
Add register_tracker_class to register custom trackers by name#4060javierdejesusda wants to merge 1 commit into
javierdejesusda wants to merge 1 commit into
Conversation
Add register_tracker_class to register a custom GeneralTracker subclass into the LOGGER_TYPE_TO_CLASS registry so it can be selected by string name in Accelerator(log_with=...), the same way as the built-in trackers. Expose both a module-level register_tracker_class and a thin Accelerator.register_tracker_class static method. Validate that the class subclasses GeneralTracker and defines name and requires_logging_directory, and warn when an existing name is overwritten. Extend filter_trackers so registered custom names resolve through the registry, including when combined with 'all', with the same logging-directory guard as the built-in trackers. Add tests and documentation for registering and using a custom tracker by name. Fixes huggingface#2734
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds
register_tracker_class, a small public API to register a customGeneralTrackersubclass into the internalLOGGER_TYPE_TO_CLASSregistry, so it can be selected by string name inAccelerator(log_with=...), exactly like the built-in trackers.This removes the boilerplate described in #2734, where users currently have to special-case custom trackers when building
log_with:With this change:
The API matches what was agreed in the issue thread (
nametaken from the class attribute, per @muellerzr's suggestion). It is exposed both as a module-levelregister_tracker_classand asAccelerator.register_tracker_class.Details
GeneralTrackerand definesnameandrequires_logging_directory.filter_trackersso registered names resolve through the registry, including when combined with"all", with the same logging-directory guard applied to the built-in trackers.requires_logging_directorypath, overwrite warnings, validation errors, and the"all"combination, plus usage-guide and API-reference docs.Fixes #2734
Before submitting
Who can review?
@SunMarc @BenjaminBossan