-
Notifications
You must be signed in to change notification settings - Fork 631
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
Conversation
…agent. This can be used to track calls for partners for collaborations.
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 |
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.
To avoid the if isinstance(...): ... elif: ... else: ...
logic I would move this logic inside _http_user_agent
directly.
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.
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.
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 to me, thanks @Hugoch
Good to merge for me @Wauplin @hanouticelina if you are 👍 |
@Hugoch all good on my side! |
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.