Skip to content

Commit

Permalink
Revert from bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
younesbelkada committed Aug 9, 2022
1 parent 0c6554b commit 915a17c
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/transformers/utils/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,6 @@ def _patch_hf_hub_tqdm():
huggingface_hub.file_download.tqdm = old_tqdm


def get_redirected_link(repo_id):
r"""
Tries to get a redirected link, otherwise return the same repo_id. Code inspired from:
https://stackoverflow.com/questions/20475552/python-requests-library-redirect-new-url
"""
temp_link = f"{HUGGINGFACE_CO_RESOLVE_ENDPOINT}/{repo_id}"
try:
r = requests.head(temp_link, allow_redirects=True)
repo_id = r.url.replace(f"{HUGGINGFACE_CO_RESOLVE_ENDPOINT}/", "")
except BaseException:
pass # Do nothing if the link is not redirected
return repo_id


def cached_file(
path_or_repo_id: Union[str, os.PathLike],
filename: str,
Expand Down Expand Up @@ -355,9 +341,6 @@ def cached_file(
cache_dir = str(cache_dir)
user_agent = http_user_agent(user_agent)
try:
# Load from redirected link if necessary
path_or_repo_id = get_redirected_link(path_or_repo_id)

# Load from URL or cache if already cached
with _patch_hf_hub_tqdm():
resolved_file = hf_hub_download(
Expand Down

0 comments on commit 915a17c

Please sign in to comment.