Skip to content

Commit

Permalink
Use hf_raise_for_status instead of deprecated _raise_for_status (h…
Browse files Browse the repository at this point in the history
…uggingface#19244)

* Use  instead of  from huggingface_hub

* bump huggingface_hub to 0.10.0 + make deps_table_update
  • Loading branch information
Wauplin authored Sep 29, 2022
1 parent 3a27ba3 commit 902d30b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"fugashi>=1.0",
"GitPython<3.1.19",
"hf-doc-builder>=0.3.0",
"huggingface-hub>=0.9.0,<1.0",
"huggingface-hub>=0.10.0,<1.0",
"importlib_metadata",
"ipadic>=1.0.0,<2.0",
"isort>=5.5.4",
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/dependency_versions_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fugashi": "fugashi>=1.0",
"GitPython": "GitPython<3.1.19",
"hf-doc-builder": "hf-doc-builder>=0.3.0",
"huggingface-hub": "huggingface-hub>=0.9.0,<1.0",
"huggingface-hub": "huggingface-hub>=0.10.0,<1.0",
"importlib_metadata": "importlib_metadata",
"ipadic": "ipadic>=1.0.0,<2.0",
"isort": "isort>=5.5.4",
Expand Down
5 changes: 3 additions & 2 deletions src/transformers/utils/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
LocalEntryNotFoundError,
RepositoryNotFoundError,
RevisionNotFoundError,
hf_raise_for_status,
)
from requests.exceptions import HTTPError
from transformers.utils.logging import tqdm
Expand Down Expand Up @@ -607,7 +608,7 @@ def has_file(

r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10)
try:
huggingface_hub.utils._errors._raise_for_status(r)
hf_raise_for_status(r)
return True
except RepositoryNotFoundError as e:
logger.error(e)
Expand Down Expand Up @@ -993,7 +994,7 @@ def get_hub_metadata(url, token=None):
r = huggingface_hub.file_download._request_with_retry(
method="HEAD", url=url, headers=headers, allow_redirects=False
)
huggingface_hub.file_download._raise_for_status(r)
hf_raise_for_status(r)
commit_hash = r.headers.get(HUGGINGFACE_HEADER_X_REPO_COMMIT)
etag = r.headers.get(HUGGINGFACE_HEADER_X_LINKED_ETAG) or r.headers.get("ETag")
if etag is not None:
Expand Down

0 comments on commit 902d30b

Please sign in to comment.