transformers - ✅(Solved) Fix Pass library_name="transformers" to HfApi/Hub functions in push paths so commits attribute correctly [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#45721Fetched 2026-05-01 05:33:08
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Timeline (top)
mentioned ×3subscribed ×3commented ×2cross-referenced ×1

transformers downloads correctly report a User-Agent of transformers/<version>; python/...; session_id/... (built by http_user_agent() in src/transformers/utils/hub.py). Pushes do not — every HfApi(...) instantiation and every top-level call to create_repo / upload_folder / create_commit in src/transformers/ is bare, so commits made by model.push_to_hub(...), Trainer.push_to_hub(...), and the model conversion scripts attribute as unknown/None; hf_hub/X.Y.Z; ... rather than transformers/<version>; ....

Root Cause

transformers downloads correctly report a User-Agent of transformers/<version>; python/...; session_id/... (built by http_user_agent() in src/transformers/utils/hub.py). Pushes do not — every HfApi(...) instantiation and every top-level call to create_repo / upload_folder / create_commit in src/transformers/ is bare, so commits made by model.push_to_hub(...), Trainer.push_to_hub(...), and the model conversion scripts attribute as unknown/None; hf_hub/X.Y.Z; ... rather than transformers/<version>; ....

Fix Action

Fixed

PR fix notes

PR #45731: Added library_name and library_version to HfApi/Hub calls for proper attribution

Description (problem / solution / changelog)

What does this PR do?

Fixes #45721

Currently, pushes from transformers attribute as unknown/None; hf_hub/X.Y.Z instead of transformers/<version> because HfApi instantiations and top-level hub calls were missing library_name and library_version parameters.

This PR adds library_name="transformers" and library_version=__version__ to all relevant call sites across src/transformers/.

Changes

  • utils/hub.py —> create_commit, create_repo
  • trainer.py —> create_repo, upload_folder (3 call sites)
  • safetensors_conversion.py —> HfApi instantiation
  • modeling_utils.py, tokenization_utils_base.py, configuration_utils.py, generation/configuration_utils.py, processing_utils.py, feature_extraction_utils.py, video_processing_utils.py, image_processing_base.py, tokenization_mistral_common.py —> create_repo via setdefault pattern
  • convert_dinov3_convnext_to_hf.py, convert_dinov3_vit_to_hf.py, convert_vjepa2_classifier_to_hf.py, convert_blt_weights_to_hf.py —> HfApi/upload_folder

Before submitting

  • [yes] I confirm that this is not a pure code agent PR.
  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [yes] Did you read the contributor guideline, Pull Request section?
  • [yes] 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?

@Wauplin @davanstrien

Changed files

  • src/transformers/configuration_utils.py (modified, +5/-0)
  • src/transformers/feature_extraction_utils.py (modified, +5/-0)
  • src/transformers/generation/configuration_utils.py (modified, +5/-0)
  • src/transformers/image_processing_base.py (modified, +6/-0)
  • src/transformers/modeling_utils.py (modified, +6/-0)
  • src/transformers/models/blt/convert_blt_weights_to_hf.py (modified, +3/-1)
  • src/transformers/models/dinov3_convnext/convert_dinov3_convnext_to_hf.py (modified, +2/-2)
  • src/transformers/models/dinov3_vit/convert_dinov3_vit_to_hf.py (modified, +3/-3)
  • src/transformers/models/vjepa2/convert_vjepa2_classifier_to_hf.py (modified, +2/-2)
  • src/transformers/models/vjepa2/convert_vjepa2_to_hf.py (modified, +2/-2)
  • src/transformers/processing_utils.py (modified, +7/-0)
  • src/transformers/safetensors_conversion.py (modified, +7/-1)
  • src/transformers/tokenization_mistral_common.py (modified, +9/-1)
  • src/transformers/tokenization_utils_base.py (modified, +6/-1)
  • src/transformers/trainer.py (modified, +14/-1)
  • src/transformers/utils/hub.py (modified, +10/-1)
  • src/transformers/video_processing_utils.py (modified, +6/-0)
RAW_BUFFERClick to expand / collapse

Per the repo's agentic contribution policy, opening this issue first to coordinate before sending the PR.

Summary

transformers downloads correctly report a User-Agent of transformers/<version>; python/...; session_id/... (built by http_user_agent() in src/transformers/utils/hub.py). Pushes do not — every HfApi(...) instantiation and every top-level call to create_repo / upload_folder / create_commit in src/transformers/ is bare, so commits made by model.push_to_hub(...), Trainer.push_to_hub(...), and the model conversion scripts attribute as unknown/None; hf_hub/X.Y.Z; ... rather than transformers/<version>; ....

Proposal

Add library_name="transformers", library_version=__version__ to the bare HfApi(...) instantiations and to top-level create_repo / upload_folder / create_commit calls across src/transformers/ (~25 call sites: core push helper in utils/hub.py, the per-class push_to_hub / save_pretrained methods, trainer.py, and a handful of convert_*_to_hf.py scripts).

Precedent

Same gap in datasets was just closed by huggingface/datasets#8161. Motivated by Hub-side UA-attribution work.

Coordination

Happy to open the PR if the approach sounds good. cc @Wauplin for the convention check.

extent analysis

TL;DR

Add library_name and library_version parameters to HfApi instantiations and relevant function calls to correctly report the User-Agent.

Guidance

  • Identify the ~25 call sites in src/transformers/ where HfApi is instantiated or create_repo, upload_folder, or create_commit is called without the library_name and library_version parameters.
  • Add library_name="transformers" and library_version=__version__ to these calls to ensure correct User-Agent attribution.
  • Verify the fix by checking the User-Agent reported in pushes after applying the changes.
  • Review the changes to ensure consistency with the existing http_user_agent() function in src/transformers/utils/hub.py.

Notes

The proposed fix is based on a similar change made in the datasets repository, and it is essential to verify that the changes do not introduce any unintended behavior.

Recommendation

Apply the proposed workaround by adding the library_name and library_version parameters to the relevant function calls, as it is a targeted fix that addresses the specific issue of incorrect User-Agent attribution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING