-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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 a bug for CallbackHandler.callback_list
#8052
Conversation
Do I need to add a test in # this should not fail
trainer = self.get_trainer(
callbacks=[MyTestTrainerCallback, MyTestTrainerCallback],
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks for fixing! Any test you want to add is more than welcome as this new API is not super well tested yet.
@sgugger Thanks for the approval. I just added a test that verifies the following:
|
trainer = self.get_trainer( | ||
callbacks=[MyTestTrainerCallback, MyTestTrainerCallback], | ||
) | ||
assert str(MyTestTrainerCallback) in warn_mock.call_args[0][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message emitted here looks like:
You are adding a <class 'tests.test_trainer_callback.MyTestTrainerCallback'> to
the callbacks of this Trainer, but there is already one. The currentlist of callbacks is
:DefaultFlowCallback
TensorBoardCallback
MyTestTrainerCallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call_args[0][0]
corresponds to the first positional argument of logger.warn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
* Fix callback_list * Add test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Fix test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
…)" This reverts commit d8380db.
What does this PR do?
Fix a bug where
CallbackHandler.callback_list
fails when given callbacks are duplicated:Code to reproduce the bug:
Before submitting
Pull Request section?
to the it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sgugger
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.