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

Fix HF_ENDPOINT not handled correctly #2155

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Mar 25, 2024

Fix #2152. Related to #2120 and to this internal slack thread.

Uploading an LFS file fails because RepoUrl(...).endpoint was not correctly overwritten with HF_ENDPOINT. We were only overwriting RepoUrl(...).endpoint but not the inner value str(RepoUrl(...)). This PR definitely fixes this by replacing it before parsing the string value. cc @padeoe.


Tips from @padeoe to reproduce the issue:

  1. Add this line to /etc/hosts or `` to deactivate traffic to huggingace.co
127.0.0.1 [huggingface.co](http://huggingface.co/)
  1. Run this script
import os


os.environ['HF_ENDPOINT'] = "https://hf-mirror.com"

from huggingface_hub import HfApi


api = HfApi() # optionally add your token here
repo_url = api.create_repo("tmp_test_mir", exist_ok=True)
repo_id = repo_url.repo_id
api.upload_file(repo_id=repo_id, path_or_fileobj=b"content", path_in_repo="file.txt")
api.upload_file(repo_id=repo_id, path_or_fileobj=b"content", path_in_repo="lfs.bin")

@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.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Ok, LGTM! Thanks @Wauplin

@Wauplin
Copy link
Contributor Author

Wauplin commented Mar 28, 2024

Thanks for the review! :)

@Wauplin Wauplin merged commit 031e714 into main Mar 28, 2024
16 checks passed
@Wauplin Wauplin deleted the 2152-fix-hf-endpoint-not-handled-correctly branch March 28, 2024 08:58
Wauplin added a commit that referenced this pull request Mar 29, 2024
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.

use HF_ENDPOINT will still be connected to huggingface.co
3 participants