Skip to content

add kwargs to all methods in the CallbackHandler class#45353

Merged
SunMarc merged 1 commit intohuggingface:mainfrom
wilnn:add_kwargs_to_CallbackHandler_methods
Apr 10, 2026
Merged

add kwargs to all methods in the CallbackHandler class#45353
SunMarc merged 1 commit intohuggingface:mainfrom
wilnn:add_kwargs_to_CallbackHandler_methods

Conversation

@wilnn
Copy link
Copy Markdown
Contributor

@wilnn wilnn commented Apr 9, 2026

What does this PR do?

Add **kwargs to all methods in the CallbackHandler class. Previously, only the CallbackHandler.on_push_begin() method accepted **kwargs, while all other methods did not. This forces users who want to customize the Trainer class for their own use cases to modify methods in the CallbackHandler class, which is inconvenient. Adding **kwargs allows them to pass whatever they want to the CallbackHandler method calls and access those values in their own callback classes. Additionally, this makes the methods consistent with the template methods in TrainerCallback.

Fixes # (issue)

Code Agent Policy

  • I confirm that this is not a pure code agent PR.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@SunMarc

@Rocketknight1
Copy link
Copy Markdown
Member

cc @SunMarc

Copy link
Copy Markdown
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@SunMarc SunMarc enabled auto-merge April 10, 2026 13:55
@SunMarc SunMarc added this pull request to the merge queue Apr 10, 2026
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Merged via the queue into huggingface:main with commit 520005e Apr 10, 2026
29 checks passed
sirzechs66 pushed a commit to sirzechs66/transformers that referenced this pull request Apr 18, 2026
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.

4 participants