huggingface-hub 0.22.1__py3-none-any.whl → 0.22.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- huggingface_hub/__init__.py +1 -1
- huggingface_hub/_commit_api.py +1 -1
- huggingface_hub/hf_api.py +2 -7
- huggingface_hub/lfs.py +7 -3
- huggingface_hub/utils/__init__.py +8 -1
- huggingface_hub/utils/_http.py +14 -1
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/METADATA +1 -1
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/RECORD +12 -12
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.22.1.dist-info → huggingface_hub-0.22.2.dist-info}/top_level.txt +0 -0
huggingface_hub/__init__.py
CHANGED
huggingface_hub/_commit_api.py
CHANGED
|
@@ -399,7 +399,7 @@ def _upload_lfs_files(
|
|
|
399
399
|
def _wrapped_lfs_upload(batch_action) -> None:
|
|
400
400
|
try:
|
|
401
401
|
operation = oid2addop[batch_action["oid"]]
|
|
402
|
-
lfs_upload(operation=operation, lfs_batch_action=batch_action, headers=headers)
|
|
402
|
+
lfs_upload(operation=operation, lfs_batch_action=batch_action, headers=headers, endpoint=endpoint)
|
|
403
403
|
except Exception as exc:
|
|
404
404
|
raise RuntimeError(f"Error while uploading '{operation.path_in_repo}' to the Hub.") from exc
|
|
405
405
|
|
huggingface_hub/hf_api.py
CHANGED
|
@@ -82,8 +82,6 @@ from .community import (
|
|
|
82
82
|
deserialize_event,
|
|
83
83
|
)
|
|
84
84
|
from .constants import (
|
|
85
|
-
_HF_DEFAULT_ENDPOINT,
|
|
86
|
-
_HF_DEFAULT_STAGING_ENDPOINT,
|
|
87
85
|
DEFAULT_ETAG_TIMEOUT,
|
|
88
86
|
DEFAULT_REQUEST_TIMEOUT,
|
|
89
87
|
DEFAULT_REVISION,
|
|
@@ -123,6 +121,7 @@ from .utils import ( # noqa: F401 # imported for backward compatibility
|
|
|
123
121
|
build_hf_headers,
|
|
124
122
|
experimental,
|
|
125
123
|
filter_repo_objects,
|
|
124
|
+
fix_hf_endpoint_in_url,
|
|
126
125
|
get_session,
|
|
127
126
|
hf_raise_for_status,
|
|
128
127
|
logging,
|
|
@@ -185,11 +184,6 @@ def repo_type_and_id_from_hf_id(hf_id: str, hub_url: Optional[str] = None) -> Tu
|
|
|
185
184
|
"""
|
|
186
185
|
input_hf_id = hf_id
|
|
187
186
|
|
|
188
|
-
# check if a proxy has been set => if yes, update the returned URL to use the proxy
|
|
189
|
-
if ENDPOINT not in (_HF_DEFAULT_ENDPOINT, _HF_DEFAULT_STAGING_ENDPOINT):
|
|
190
|
-
hf_id = hf_id.replace(_HF_DEFAULT_ENDPOINT, ENDPOINT)
|
|
191
|
-
hf_id = hf_id.replace(_HF_DEFAULT_STAGING_ENDPOINT, ENDPOINT)
|
|
192
|
-
|
|
193
187
|
hub_url = re.sub(r"https?://", "", hub_url if hub_url is not None else ENDPOINT)
|
|
194
188
|
is_hf_url = hub_url in hf_id and "@" not in hf_id
|
|
195
189
|
|
|
@@ -436,6 +430,7 @@ class RepoUrl(str):
|
|
|
436
430
|
"""
|
|
437
431
|
|
|
438
432
|
def __new__(cls, url: Any, endpoint: Optional[str] = None):
|
|
433
|
+
url = fix_hf_endpoint_in_url(url, endpoint=endpoint)
|
|
439
434
|
return super(RepoUrl, cls).__new__(cls, url)
|
|
440
435
|
|
|
441
436
|
def __init__(self, url: Any, endpoint: Optional[str] = None) -> None:
|
huggingface_hub/lfs.py
CHANGED
|
@@ -31,6 +31,7 @@ from huggingface_hub.constants import ENDPOINT, HF_HUB_ENABLE_HF_TRANSFER, REPO_
|
|
|
31
31
|
|
|
32
32
|
from .utils import (
|
|
33
33
|
build_hf_headers,
|
|
34
|
+
fix_hf_endpoint_in_url,
|
|
34
35
|
get_session,
|
|
35
36
|
hf_raise_for_status,
|
|
36
37
|
http_backoff,
|
|
@@ -193,6 +194,7 @@ def lfs_upload(
|
|
|
193
194
|
lfs_batch_action: Dict,
|
|
194
195
|
token: Optional[str] = None,
|
|
195
196
|
headers: Optional[Dict[str, str]] = None,
|
|
197
|
+
endpoint: Optional[str] = None,
|
|
196
198
|
) -> None:
|
|
197
199
|
"""
|
|
198
200
|
Handles uploading a given object to the Hub with the LFS protocol.
|
|
@@ -230,6 +232,7 @@ def lfs_upload(
|
|
|
230
232
|
# 2. Upload file (either single part or multi-part)
|
|
231
233
|
header = upload_action.get("header", {})
|
|
232
234
|
chunk_size = header.get("chunk_size")
|
|
235
|
+
upload_url = fix_hf_endpoint_in_url(upload_action["href"], endpoint=endpoint)
|
|
233
236
|
if chunk_size is not None:
|
|
234
237
|
try:
|
|
235
238
|
chunk_size = int(chunk_size)
|
|
@@ -237,15 +240,16 @@ def lfs_upload(
|
|
|
237
240
|
raise ValueError(
|
|
238
241
|
f"Malformed response from LFS batch endpoint: `chunk_size` should be an integer. Got '{chunk_size}'."
|
|
239
242
|
)
|
|
240
|
-
_upload_multi_part(operation=operation, header=header, chunk_size=chunk_size, upload_url=
|
|
243
|
+
_upload_multi_part(operation=operation, header=header, chunk_size=chunk_size, upload_url=upload_url)
|
|
241
244
|
else:
|
|
242
|
-
_upload_single_part(operation=operation, upload_url=
|
|
245
|
+
_upload_single_part(operation=operation, upload_url=upload_url)
|
|
243
246
|
|
|
244
247
|
# 3. Verify upload went well
|
|
245
248
|
if verify_action is not None:
|
|
246
249
|
_validate_lfs_action(verify_action)
|
|
250
|
+
verify_url = fix_hf_endpoint_in_url(verify_action["href"], endpoint)
|
|
247
251
|
verify_resp = get_session().post(
|
|
248
|
-
|
|
252
|
+
verify_url,
|
|
249
253
|
headers=build_hf_headers(token=token, headers=headers),
|
|
250
254
|
json={"oid": operation.upload_info.sha256.hex(), "size": operation.upload_info.size},
|
|
251
255
|
)
|
|
@@ -47,7 +47,14 @@ from ._fixes import SoftTemporaryDirectory, WeakFileLock, yaml_dump
|
|
|
47
47
|
from ._git_credential import list_credential_helpers, set_git_credential, unset_git_credential
|
|
48
48
|
from ._headers import LocalTokenNotFoundError, build_hf_headers, get_token_to_send
|
|
49
49
|
from ._hf_folder import HfFolder
|
|
50
|
-
from ._http import
|
|
50
|
+
from ._http import (
|
|
51
|
+
OfflineModeIsEnabled,
|
|
52
|
+
configure_http_backend,
|
|
53
|
+
fix_hf_endpoint_in_url,
|
|
54
|
+
get_session,
|
|
55
|
+
http_backoff,
|
|
56
|
+
reset_sessions,
|
|
57
|
+
)
|
|
51
58
|
from ._pagination import paginate
|
|
52
59
|
from ._paths import IGNORE_GIT_FOLDER_PATTERNS, filter_repo_objects
|
|
53
60
|
from ._runtime import (
|
huggingface_hub/utils/_http.py
CHANGED
|
@@ -21,7 +21,7 @@ import time
|
|
|
21
21
|
import uuid
|
|
22
22
|
from functools import lru_cache
|
|
23
23
|
from http import HTTPStatus
|
|
24
|
-
from typing import Callable, Tuple, Type, Union
|
|
24
|
+
from typing import Callable, Optional, Tuple, Type, Union
|
|
25
25
|
|
|
26
26
|
import requests
|
|
27
27
|
from requests import Response
|
|
@@ -306,3 +306,16 @@ def http_backoff(
|
|
|
306
306
|
|
|
307
307
|
# Update sleep time for next retry
|
|
308
308
|
sleep_time = min(max_wait_time, sleep_time * 2) # Exponential backoff
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def fix_hf_endpoint_in_url(url: str, endpoint: Optional[str]) -> str:
|
|
312
|
+
"""Replace the default endpoint in a URL by a custom one.
|
|
313
|
+
|
|
314
|
+
This is useful when using a proxy and the Hugging Face Hub returns a URL with the default endpoint.
|
|
315
|
+
"""
|
|
316
|
+
endpoint = endpoint or constants.ENDPOINT
|
|
317
|
+
# check if a proxy has been set => if yes, update the returned URL to use the proxy
|
|
318
|
+
if endpoint not in (None, constants._HF_DEFAULT_ENDPOINT, constants._HF_DEFAULT_STAGING_ENDPOINT):
|
|
319
|
+
url = url.replace(constants._HF_DEFAULT_ENDPOINT, endpoint)
|
|
320
|
+
url = url.replace(constants._HF_DEFAULT_STAGING_ENDPOINT, endpoint)
|
|
321
|
+
return url
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface-hub
|
|
3
|
-
Version: 0.22.
|
|
3
|
+
Version: 0.22.2
|
|
4
4
|
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
|
5
5
|
Home-page: https://github.com/huggingface/huggingface_hub
|
|
6
6
|
Author: Hugging Face, Inc.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
huggingface_hub/__init__.py,sha256=
|
|
2
|
-
huggingface_hub/_commit_api.py,sha256=
|
|
1
|
+
huggingface_hub/__init__.py,sha256=lDulrtedaTz17qYF0AzTHuRanxwgeGlVdq6TxmIcuQQ,31075
|
|
2
|
+
huggingface_hub/_commit_api.py,sha256=_6NggUJsCBdspCJjXbvZYXH6vLBOnkG6I2E1kc8aJm8,29194
|
|
3
3
|
huggingface_hub/_commit_scheduler.py,sha256=FgfjYv3E0oK3iBxDdy45Y7t78FWkmjnBR4dRd5aZviU,13653
|
|
4
4
|
huggingface_hub/_inference_endpoints.py,sha256=wGcnxZNFCbMK77SA90fPsZ9bqNGwPopSVr-sTbdw3o8,15763
|
|
5
5
|
huggingface_hub/_login.py,sha256=jNTFCnou-eZAtMWl1PDuyZhmpW3O-f4qff9m5hU0UGk,15364
|
|
@@ -14,12 +14,12 @@ huggingface_hub/constants.py,sha256=8r0JaNMhLR8X6pC6TnNBLQ-TVcHEbRWk1sJ-LSIj444,
|
|
|
14
14
|
huggingface_hub/errors.py,sha256=jCYKeSOsQNfH2t3TsW8kIAXXS1aWl9PaAq3prFfz4CI,704
|
|
15
15
|
huggingface_hub/fastai_utils.py,sha256=5I7zAfgHJU_mZnxnf9wgWTHrCRu_EAV8VTangDVfE_o,16676
|
|
16
16
|
huggingface_hub/file_download.py,sha256=DmOEVmhEsRnX8M0kZmLPLC76eptMT0riTwtThFioV8Q,77476
|
|
17
|
-
huggingface_hub/hf_api.py,sha256=
|
|
17
|
+
huggingface_hub/hf_api.py,sha256=dJsdtW6WJW04h84BE46FOg8Pp34AgYhg-NbMg9WrReY,367303
|
|
18
18
|
huggingface_hub/hf_file_system.py,sha256=JUCT-VZBesDCB-uN__fvQt3uprGQETGnUlzjC7StQLM,37272
|
|
19
19
|
huggingface_hub/hub_mixin.py,sha256=xkUTJiP5TiAiVj6ts9Thffcm4wufZS3jMWil3LB2uvw,30423
|
|
20
20
|
huggingface_hub/inference_api.py,sha256=UXOKu_Ez2I3hDsjguqCcCrj03WFDndehpngYiIAucdg,8331
|
|
21
21
|
huggingface_hub/keras_mixin.py,sha256=8L0FEIWy_kmKsGI5d61q_33dGYbmLGhy4kZbqn-YFns,19681
|
|
22
|
-
huggingface_hub/lfs.py,sha256=
|
|
22
|
+
huggingface_hub/lfs.py,sha256=p61RJK13gtgdu0og4KHFosy_GWYDFsQJa0JJoLYSLAk,19592
|
|
23
23
|
huggingface_hub/repocard.py,sha256=oUrGim27nCHkevPDZDbUp68uKTxB8xbdoyeqv24pexc,34605
|
|
24
24
|
huggingface_hub/repocard_data.py,sha256=1hIkI8xp0EmW2aR3LtHMrjIMk_W-KJxHslMjpNMwVPg,31911
|
|
25
25
|
huggingface_hub/repository.py,sha256=8oNhKNvJRye3dr67cTn8faKkBSiWFgvj7bIBlOpI-8U,54489
|
|
@@ -78,7 +78,7 @@ huggingface_hub/serialization/_tensorflow.py,sha256=Rf4kw1NYxEaoUXB8aLtQLHrTjgob
|
|
|
78
78
|
huggingface_hub/serialization/_torch.py,sha256=xYR6e_G9laMTroWLiQRABSuloTQuuRSQNyYHdT_rmXU,7687
|
|
79
79
|
huggingface_hub/templates/datasetcard_template.md,sha256=W-EMqR6wndbrnZorkVv56URWPG49l7MATGeI015kTvs,5503
|
|
80
80
|
huggingface_hub/templates/modelcard_template.md,sha256=4AqArS3cqdtbit5Bo-DhjcnDFR-pza5hErLLTPM4Yuc,6870
|
|
81
|
-
huggingface_hub/utils/__init__.py,sha256=
|
|
81
|
+
huggingface_hub/utils/__init__.py,sha256=XYIIkKiDeoy8dQQegBYSfILOzdt8NW_cfquY7omX0fQ,3478
|
|
82
82
|
huggingface_hub/utils/_cache_assets.py,sha256=kai77HPQMfYpROouMBQCr_gdBCaeTm996Sqj0dExbNg,5728
|
|
83
83
|
huggingface_hub/utils/_cache_manager.py,sha256=Fs1XVP1UGzUTogMfMfEi_MfpURzHyW__djX0s2oLmrY,29307
|
|
84
84
|
huggingface_hub/utils/_chunk_utils.py,sha256=kRCaj5228_vKcyLWspd8Xq01f17Jz6ds5Sr9ed5d_RU,2130
|
|
@@ -90,7 +90,7 @@ huggingface_hub/utils/_fixes.py,sha256=EqG7u36J9C3NtL5VukDilca90GV9idrENzsEVhtdb
|
|
|
90
90
|
huggingface_hub/utils/_git_credential.py,sha256=SDdsiREr1TcAR2Ze2TB0E5cYzVJgvDZrs60od9lAsMc,4596
|
|
91
91
|
huggingface_hub/utils/_headers.py,sha256=T_C1RA0bqEYL0oiE4WdFMAKXEUPHN-D43vchjiwKcZ4,9643
|
|
92
92
|
huggingface_hub/utils/_hf_folder.py,sha256=gWH-TT9h_6X_CyrtLTtKNEawf9kKlCHraFiOu09BuLk,3613
|
|
93
|
-
huggingface_hub/utils/_http.py,sha256=
|
|
93
|
+
huggingface_hub/utils/_http.py,sha256=VQcukUKXXDlDQwyG-LGVtAIr3DprVC-R_HcXZzbAfak,13543
|
|
94
94
|
huggingface_hub/utils/_pagination.py,sha256=hzLFLd8i_DKkPRVYzOx2CxLt5lcocEiAxDJriQUjAjY,1841
|
|
95
95
|
huggingface_hub/utils/_paths.py,sha256=Ah_diO-gSWw9TYylJl_HNB2XXftgIi36HNlKAYQHCms,4398
|
|
96
96
|
huggingface_hub/utils/_runtime.py,sha256=6PxkDPWj3ltRlE2-zAr3vZTXfi1OUjxILsmRN-s_wZY,10851
|
|
@@ -105,9 +105,9 @@ huggingface_hub/utils/insecure_hashlib.py,sha256=OjxlvtSQHpbLp9PWSrXBDJ0wHjxCBU-
|
|
|
105
105
|
huggingface_hub/utils/logging.py,sha256=Cp03s0uEl3kDM9XHQW9a8GAoExODQ-e7kEtgMt-_To8,4728
|
|
106
106
|
huggingface_hub/utils/sha.py,sha256=QLlIwPCyz46MmUc_4L8xl87KfYoBks9kPgsMZ5JCz-o,902
|
|
107
107
|
huggingface_hub/utils/tqdm.py,sha256=2H80n_kDpvp7P4i7MaYR47t41i0l6ODi5mab1oof1dk,6335
|
|
108
|
-
huggingface_hub-0.22.
|
|
109
|
-
huggingface_hub-0.22.
|
|
110
|
-
huggingface_hub-0.22.
|
|
111
|
-
huggingface_hub-0.22.
|
|
112
|
-
huggingface_hub-0.22.
|
|
113
|
-
huggingface_hub-0.22.
|
|
108
|
+
huggingface_hub-0.22.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
109
|
+
huggingface_hub-0.22.2.dist-info/METADATA,sha256=9S0T9nMXn6Q7cesvjVBiSk4oEid8LZ3gT9fuJLGrWNk,12869
|
|
110
|
+
huggingface_hub-0.22.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
111
|
+
huggingface_hub-0.22.2.dist-info/entry_points.txt,sha256=Y3Z2L02rBG7va_iE6RPXolIgwOdwUFONyRN3kXMxZ0g,131
|
|
112
|
+
huggingface_hub-0.22.2.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
|
|
113
|
+
huggingface_hub-0.22.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|