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

feat: Adds a new environment variable HF_HUB_USER_AGENT_ORIGIN to set origin of calls in user-agent #2869

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

Hugoch
Copy link
Member

@Hugoch Hugoch commented Feb 17, 2025

Adds a new HF_HUB_USER_AGENT_ORIGIN environment variable that allows to set an origin to HTTP headers. It is convenient to track requests made by partners during collaborations.

…agent. This can be used to track calls for partners for collaborations.
@HuggingFaceDocBuilderDev

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.

@@ -125,6 +125,16 @@ def build_hf_headers(
# Get auth token to send
token_to_send = get_token_to_send(token)

# Retrieve user-agent origin headers from environment variable
origin = constants.HF_HUB_USER_AGENT_ORIGIN
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid the if isinstance(...): ... elif: ... else: ... logic I would move this logic inside _http_user_agent directly.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

As mentioned on slack (private link) I'm fine with this solution. Feel free to ping me and @hanouticelina once you've agreed on the convention internally and we should be able to merge quite quickly.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

looks good to me, thanks @Hugoch

@Hugoch Hugoch marked this pull request as ready for review February 18, 2025 08:44
@Hugoch
Copy link
Member Author

Hugoch commented Feb 18, 2025

Good to merge for me @Wauplin @hanouticelina if you are 👍

@hanouticelina
Copy link
Contributor

@Hugoch all good on my side!

@Hugoch Hugoch merged commit a7f3151 into huggingface:main Feb 18, 2025
16 checks passed
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