Use hf_raise_for_status instead of deprecated _raise_for_status (#19244)
* Use instead of from huggingface_hub * bump huggingface_hub to 0.10.0 + make deps_table_update
This commit is contained in:
2
setup.py
2
setup.py
@@ -116,7 +116,7 @@ _deps = [
|
|||||||
"fugashi>=1.0",
|
"fugashi>=1.0",
|
||||||
"GitPython<3.1.19",
|
"GitPython<3.1.19",
|
||||||
"hf-doc-builder>=0.3.0",
|
"hf-doc-builder>=0.3.0",
|
||||||
"huggingface-hub>=0.9.0,<1.0",
|
"huggingface-hub>=0.10.0,<1.0",
|
||||||
"importlib_metadata",
|
"importlib_metadata",
|
||||||
"ipadic>=1.0.0,<2.0",
|
"ipadic>=1.0.0,<2.0",
|
||||||
"isort>=5.5.4",
|
"isort>=5.5.4",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ deps = {
|
|||||||
"fugashi": "fugashi>=1.0",
|
"fugashi": "fugashi>=1.0",
|
||||||
"GitPython": "GitPython<3.1.19",
|
"GitPython": "GitPython<3.1.19",
|
||||||
"hf-doc-builder": "hf-doc-builder>=0.3.0",
|
"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",
|
"importlib_metadata": "importlib_metadata",
|
||||||
"ipadic": "ipadic>=1.0.0,<2.0",
|
"ipadic": "ipadic>=1.0.0,<2.0",
|
||||||
"isort": "isort>=5.5.4",
|
"isort": "isort>=5.5.4",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ from huggingface_hub.utils import (
|
|||||||
LocalEntryNotFoundError,
|
LocalEntryNotFoundError,
|
||||||
RepositoryNotFoundError,
|
RepositoryNotFoundError,
|
||||||
RevisionNotFoundError,
|
RevisionNotFoundError,
|
||||||
|
hf_raise_for_status,
|
||||||
)
|
)
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
from transformers.utils.logging import tqdm
|
from transformers.utils.logging import tqdm
|
||||||
@@ -607,7 +608,7 @@ def has_file(
|
|||||||
|
|
||||||
r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10)
|
r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10)
|
||||||
try:
|
try:
|
||||||
huggingface_hub.utils._errors._raise_for_status(r)
|
hf_raise_for_status(r)
|
||||||
return True
|
return True
|
||||||
except RepositoryNotFoundError as e:
|
except RepositoryNotFoundError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
@@ -993,7 +994,7 @@ def get_hub_metadata(url, token=None):
|
|||||||
r = huggingface_hub.file_download._request_with_retry(
|
r = huggingface_hub.file_download._request_with_retry(
|
||||||
method="HEAD", url=url, headers=headers, allow_redirects=False
|
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)
|
commit_hash = r.headers.get(HUGGINGFACE_HEADER_X_REPO_COMMIT)
|
||||||
etag = r.headers.get(HUGGINGFACE_HEADER_X_LINKED_ETAG) or r.headers.get("ETag")
|
etag = r.headers.get(HUGGINGFACE_HEADER_X_LINKED_ETAG) or r.headers.get("ETag")
|
||||||
if etag is not None:
|
if etag is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user