Compare commits

...

4 Commits

Author SHA1 Message Date
Sylvain Gugger
dcb08b99f4 Release v4.19.4
Some checks failed
Release - Conda / build_and_package (push) Has been cancelled
2022-06-10 15:04:34 -04:00
Simon Brandeis
e3711e2391 Merge 2022-06-10 15:04:00 -04:00
Sylvain Gugger
a727db62f4 Release v4.19.3
Some checks failed
Release - Conda / build_and_package (push) Has been cancelled
2022-06-09 12:12:15 -04:00
Sylvain Gugger
9c1d8d84fa Pin protobouf that breaks TensorBoard in PyTorch (#17440) 2022-06-09 12:11:28 -04:00
7 changed files with 33 additions and 16 deletions

View File

@@ -6,7 +6,7 @@
"metadata": {},
"outputs": [],
"source": [
"#%pip install-r requirements.txt"
"# %pip install-r requirements.txt"
]
},
{

View File

@@ -4,7 +4,7 @@
"cell_type": "code",
"execution_count": 1,
"source": [
"#%pip install-r requirements.txt"
"# %pip install-r requirements.txt"
],
"outputs": [],
"metadata": {}

View File

@@ -131,7 +131,7 @@ _deps = [
"packaging>=20.0",
"parameterized",
"phonemizer",
"protobuf",
"protobuf<=3.20.1",
"psutil",
"pyyaml>=5.1",
"pydantic",
@@ -291,6 +291,7 @@ extras["testing"] = (
"nltk",
"GitPython",
"hf-doc-builder",
"protobuf", # Can be removed once we can unpin protobuf
"sacremoses",
"rjieba"
)
@@ -392,7 +393,7 @@ install_requires = [
setup(
name="transformers",
version="4.19.2", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
version="4.19.4", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
author="The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)",
author_email="transformers@huggingface.co",
description="State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow",

View File

@@ -22,7 +22,7 @@
# to defer the actual importing for when the objects are requested. This way `import transformers` provides the names
# in the namespace without actually importing anything (and especially none of the backends).
__version__ = "4.19.2"
__version__ = "4.19.4"
from typing import TYPE_CHECKING

View File

@@ -37,7 +37,7 @@ deps = {
"packaging": "packaging>=20.0",
"parameterized": "parameterized",
"phonemizer": "phonemizer",
"protobuf": "protobuf",
"protobuf": "protobuf<=3.20.1",
"psutil": "psutil",
"pyyaml": "pyyaml>=5.1",
"pydantic": "pydantic",

View File

@@ -38,6 +38,7 @@ import requests
from filelock import FileLock
from huggingface_hub import HfFolder, Repository, create_repo, list_repo_files, whoami
from requests.exceptions import HTTPError
from requests.models import Response
from transformers.utils.logging import tqdm
from . import __version__, logging
@@ -397,20 +398,27 @@ class RevisionNotFoundError(HTTPError):
"""Raised when trying to access a hf.co URL with a valid repository but an invalid revision."""
def _raise_for_status(request):
def _raise_for_status(response: Response):
"""
Internal version of `request.raise_for_status()` that will refine a potential HTTPError.
"""
if "X-Error-Code" in request.headers:
error_code = request.headers["X-Error-Code"]
if "X-Error-Code" in response.headers:
error_code = response.headers["X-Error-Code"]
if error_code == "RepoNotFound":
raise RepositoryNotFoundError(f"404 Client Error: Repository Not Found for url: {request.url}")
raise RepositoryNotFoundError(f"404 Client Error: Repository Not Found for url: {response.url}")
elif error_code == "EntryNotFound":
raise EntryNotFoundError(f"404 Client Error: Entry Not Found for url: {request.url}")
raise EntryNotFoundError(f"404 Client Error: Entry Not Found for url: {response.url}")
elif error_code == "RevisionNotFound":
raise RevisionNotFoundError((f"404 Client Error: Revision Not Found for url: {request.url}"))
raise RevisionNotFoundError(f"404 Client Error: Revision Not Found for url: {response.url}")
request.raise_for_status()
if response.status_code == 401:
# The repo was not found and the user is not Authenticated
raise RepositoryNotFoundError(
f"401 Client Error: Repository not found for url: {response.url}. "
"If the repo is private, make sure you are authenticated."
)
response.raise_for_status()
def http_get(url: str, temp_file: BinaryIO, proxies=None, resume_size=0, headers: Optional[Dict[str, str]] = None):

View File

@@ -99,11 +99,19 @@ class GetFromCacheTests(unittest.TestCase):
with self.assertRaisesRegex(EntryNotFoundError, "404 Client Error"):
_ = get_from_cache(url)
def test_model_not_found(self):
# Invalid model file.
def test_model_not_found_not_authenticated(self):
# Invalid model id.
url = hf_bucket_url("bert-base", filename="pytorch_model.bin")
with self.assertRaisesRegex(RepositoryNotFoundError, "401 Client Error"):
_ = get_from_cache(url)
@unittest.skip("No authentication when testing against prod")
def test_model_not_found_authenticated(self):
# Invalid model id.
url = hf_bucket_url("bert-base", filename="pytorch_model.bin")
with self.assertRaisesRegex(RepositoryNotFoundError, "404 Client Error"):
_ = get_from_cache(url)
_ = get_from_cache(url, use_auth_token="hf_sometoken")
# ^ TODO - if we decide to unskip this: use a real / functional token
def test_revision_not_found(self):
# Valid file but missing revision