-
Notifications
You must be signed in to change notification settings - Fork 507
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
It seem that proxies doesn't pass to get the model info when use snapshot_download #2343
Comments
This is indeed a bug, thanks for identifying and reporting it! Would you mind open a PR for it? I would simply add import requests
from huggingface_hub import configure_http_backend, get_session
# Create a factory function that returns a Session with configured proxies
def backend_factory() -> requests.Session:
session = requests.Session()
session.proxies = {"http": "http://10.10.1.10:3128", "https": "https://10.10.1.11:1080"}
return session
# Set it as the default session factory
configure_http_backend(backend_factory=backend_factory) |
I am very happy to submit this PR. Can I submit it this weekend? This way, I will have enough time to test the code. |
Describe the bug
my code is :
`
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="meta-llama/Meta-Llama-3-8B",
repo_type = None,
local_dir=r"D:\model\qwen",
token = "xxx",
proxies={"https": "http://127.0.0.1:7890"},
max_workers=8
)`
because of some reason, my network can't connect to huggingface.co,my proxy can connect to.
When I try this code to download some models,i got this error:
huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.
From the code, I think when we call the function (HfApi.repo_info),and this functio will call HfApi.model_info.It finally will call requests.Session.get function. the code showed the proxies doesn't pass it request.
`
headers = self._build_hf_headers(token=token)
path = (
f"{self.endpoint}/api/models/{repo_id}"
if revision is None
else (f"{self.endpoint}/api/models/{repo_id}/revision/{quote(revision, safe='')}")
)
params = {}
if securityStatus:
params["securityStatus"] = True
if files_metadata:
params["blobs"] = True
r = get_session().get(path, headers=headers, timeout=timeout, params=params)
`
After I pass the proxies when get model info,it's works.
can you fix this problem,or I can commit my code.
Reproduction
1.get a network that can't connect to huggingface.io
2.run a proxy server that can connect to huggingface.io.
3. run the code ,download anything.
`
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="meta-llama/Meta-Llama-3-8B",
repo_type = None,
local_dir=r"D:\model\qwen",
token = "xxx",
proxies={"https": "http://127.0.0.1:7890"},
max_workers=8
`
Logs
System info
The text was updated successfully, but these errors were encountered: