Offload retry logic to hf hub (#1382)

* remove requirement for requests
This commit is contained in:
Mahmoud Ashraf
2025-10-30 22:11:01 +03:00
committed by GitHub
parent 9090997d25
commit 00a5b26b1f
2 changed files with 2 additions and 20 deletions

View File

@@ -5,7 +5,6 @@ import re
from typing import List, Optional, Union
import huggingface_hub
import requests
from tqdm.auto import tqdm
@@ -114,24 +113,7 @@ def download_model(
if use_auth_token is not None:
kwargs["token"] = use_auth_token
try:
return huggingface_hub.snapshot_download(repo_id, **kwargs)
except (
huggingface_hub.utils.HfHubHTTPError,
requests.exceptions.ConnectionError,
) as exception:
logger = get_logger()
logger.warning(
"An error occured while synchronizing the model %s from the Hugging Face Hub:\n%s",
repo_id,
exception,
)
logger.warning(
"Trying to load the model directly from the local cache, if it exists."
)
kwargs["local_files_only"] = True
return huggingface_hub.snapshot_download(repo_id, **kwargs)
return huggingface_hub.snapshot_download(repo_id, **kwargs)
def format_timestamp(

View File

@@ -1,5 +1,5 @@
ctranslate2>=4.0,<5
huggingface_hub>=0.13
huggingface_hub>=0.21
tokenizers>=0.13,<1
onnxruntime>=1.14,<2
av>=11