Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix 404 NOT FOUND issue caused by endpoint tail slash #2721

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/huggingface_hub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import typing
from typing import Literal, Optional, Tuple

form urllib.parse import urljoin
Mingqi2 marked this conversation as resolved.
Show resolved Hide resolved

# Possible values for env variables

Expand Down Expand Up @@ -65,7 +65,7 @@ def _as_int(value: Optional[str]) -> Optional[int]:
_HF_DEFAULT_STAGING_ENDPOINT = "https://hub-ci.huggingface.co"
ENDPOINT = os.getenv("HF_ENDPOINT") or (_HF_DEFAULT_STAGING_ENDPOINT if _staging_mode else _HF_DEFAULT_ENDPOINT)
Mingqi2 marked this conversation as resolved.
Show resolved Hide resolved

HUGGINGFACE_CO_URL_TEMPLATE = ENDPOINT + "/{repo_id}/resolve/{revision}/{filename}"
HUGGINGFACE_CO_URL_TEMPLATE = urljoin(ENDPOINT, "/{repo_id}/resolve/{revision}/{filename}")
hanouticelina marked this conversation as resolved.
Show resolved Hide resolved
HUGGINGFACE_HEADER_X_REPO_COMMIT = "X-Repo-Commit"
HUGGINGFACE_HEADER_X_LINKED_ETAG = "X-Linked-Etag"
HUGGINGFACE_HEADER_X_LINKED_SIZE = "X-Linked-Size"
Expand Down
1 change: 1 addition & 0 deletions src/huggingface_hub/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def fix_hf_endpoint_in_url(url: str, endpoint: Optional[str]) -> str:
endpoint = endpoint or constants.ENDPOINT
Mingqi2 marked this conversation as resolved.
Show resolved Hide resolved
# check if a proxy has been set => if yes, update the returned URL to use the proxy
if endpoint not in (None, constants._HF_DEFAULT_ENDPOINT, constants._HF_DEFAULT_STAGING_ENDPOINT):
endpoint.rstrip('/')
Mingqi2 marked this conversation as resolved.
Show resolved Hide resolved
url = url.replace(constants._HF_DEFAULT_ENDPOINT, endpoint)
url = url.replace(constants._HF_DEFAULT_STAGING_ENDPOINT, endpoint)
return url
Expand Down
Loading