huggingface-hub 0.34.1__py3-none-any.whl → 0.34.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.

@@ -46,7 +46,7 @@ import sys
46
46
  from typing import TYPE_CHECKING
47
47
 
48
48
 
49
- __version__ = "0.34.1"
49
+ __version__ = "0.34.2"
50
50
 
51
51
  # Alphabetical order of definitions is ensured in tests
52
52
  # WARNING: any comment added in this dictionary definition will be lost when
@@ -90,7 +90,7 @@ class LocalDownloadFilePaths:
90
90
  resolved_path = str(path.resolve())
91
91
  # Some Windows versions do not allow for paths longer than 255 characters.
92
92
  # In this case, we must specify it as an extended path by using the "\\?\" prefix.
93
- if len(resolved_path) > 255 and not resolved_path.startswith("\\\\?\\"):
93
+ if os.name == "nt" and len(resolved_path) > 255 and not resolved_path.startswith("\\\\?\\"):
94
94
  path = Path("\\\\?\\" + resolved_path)
95
95
  return path
96
96
 
@@ -317,9 +317,6 @@ def _get_file_length_from_http_response(response: requests.Response) -> Optional
317
317
 
318
318
  This function extracts the file size from the HTTP response headers, either from the
319
319
  `Content-Range` or `Content-Length` header, if available (in that order).
320
- The HTTP response object containing the headers.
321
- `int` or `None`: The length of the file in bytes if the information is available,
322
- otherwise `None`.
323
320
 
324
321
  Args:
325
322
  response (`requests.Response`):
@@ -329,6 +326,15 @@ def _get_file_length_from_http_response(response: requests.Response) -> Optional
329
326
  `int` or `None`: The length of the file in bytes, or None if not available.
330
327
  """
331
328
 
329
+ # If HTTP response contains compressed body (e.g. gzip), the `Content-Length` header will
330
+ # contain the length of the compressed body, not the uncompressed file size.
331
+ # And at the start of transmission there's no way to know the uncompressed file size for gzip,
332
+ # thus we return None in that case.
333
+ content_encoding = response.headers.get("Content-Encoding", "identity").lower()
334
+ if content_encoding != "identity":
335
+ # gzip/br/deflate/zstd etc
336
+ return None
337
+
332
338
  content_range = response.headers.get("Content-Range")
333
339
  if content_range is not None:
334
340
  return int(content_range.rsplit("/")[-1])
@@ -422,11 +428,7 @@ def http_get(
422
428
  )
423
429
 
424
430
  hf_raise_for_status(r)
425
- content_length = _get_file_length_from_http_response(r)
426
-
427
- # NOTE: 'total' is the total number of bytes to download, not the number of bytes in the file.
428
- # If the file is compressed, the number of bytes in the saved file will be higher than 'total'.
429
- total = resume_size + int(content_length) if content_length is not None else None
431
+ total: Optional[int] = _get_file_length_from_http_response(r)
430
432
 
431
433
  if displayed_filename is None:
432
434
  displayed_filename = url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: huggingface-hub
3
- Version: 0.34.1
3
+ Version: 0.34.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,9 +1,9 @@
1
- huggingface_hub/__init__.py,sha256=3BWbuLHQ7NvAfv9C4WFRMK1hgiwDBg-YBbQFRoTaqRw,51837
1
+ huggingface_hub/__init__.py,sha256=hpNfH8kc3rj-VJC9V2jof7kCBJ_9Ao5Ly9nDJa6TeTc,51837
2
2
  huggingface_hub/_commit_api.py,sha256=68HxFnJE2s-QmGZRHQav5kOMTseYV_ZQi04ADaQmZUk,38979
3
3
  huggingface_hub/_commit_scheduler.py,sha256=tfIoO1xWHjTJ6qy6VS6HIoymDycFPg0d6pBSZprrU2U,14679
4
4
  huggingface_hub/_inference_endpoints.py,sha256=ahmbPcEXsJ_JcMb9TDgdkD8Z2z9uytkFG3_1o6dTm8g,17598
5
5
  huggingface_hub/_jobs_api.py,sha256=XPiQypEwcZQWuEEEAv5MhRak3SV8Y8jyusocjNVAefI,5399
6
- huggingface_hub/_local_folder.py,sha256=2Sf-f9GdNoYW-oFliM5bytRDaAEs6phWknPhuaVa42k,17285
6
+ huggingface_hub/_local_folder.py,sha256=2iHXNgIT3UdSt2PvCovd0NzgVxTRypKb-rvAFLK-gZU,17305
7
7
  huggingface_hub/_login.py,sha256=rcwx9EZdFUB3vuowC5QBiSYS4ImUnBzo04igR1Z8l40,20256
8
8
  huggingface_hub/_oauth.py,sha256=75ya9toHxC0WRKsLOAI212CrssRjTSxs16mHWWNMb3w,18714
9
9
  huggingface_hub/_snapshot_download.py,sha256=b-NzYQcvktsAirIfGQKgzQwu8w0S6lhBTvnJ5S6saw8,16166
@@ -17,7 +17,7 @@ huggingface_hub/constants.py,sha256=nILseAp4rqLu_KQTZDpPGOhepVAPanD7azbomAvovj0,
17
17
  huggingface_hub/dataclasses.py,sha256=sgPdEi2UDprhNPP2PPkiSlzsHdC1WcpwVTLwlHAEcr0,17224
18
18
  huggingface_hub/errors.py,sha256=D7Lw0Jjrf8vfmD0B26LEvg-JWkU8Zq0KDPJOzFY4QLw,11201
19
19
  huggingface_hub/fastai_utils.py,sha256=DpeH9d-6ut2k_nCAAwglM51XmRmgfbRe2SPifpVL5Yk,16745
20
- huggingface_hub/file_download.py,sha256=dt31o0xnWBbguTZuAAuejfJVsR7aUuidVNFvu_LP6wU,78940
20
+ huggingface_hub/file_download.py,sha256=E-NWON01pprbAsw7Kz477JX6f8HTWsdpEdQAtA37t5c,78974
21
21
  huggingface_hub/hf_api.py,sha256=SXuzqHExwpRmrzfbS4Y_ty4FrcYalR5Vuj1K2dxXdMw,464596
22
22
  huggingface_hub/hf_file_system.py,sha256=nrNOoNHRwf1swebtQvZExSblRjQg9rHKxL7Cslk72uw,46899
23
23
  huggingface_hub/hub_mixin.py,sha256=MArtbUxjXiYeOvOmNBG9I_j5t02m2xCVAcge4waip1w,38091
@@ -158,9 +158,9 @@ huggingface_hub/utils/insecure_hashlib.py,sha256=iAaepavFZ5Dhfa5n8KozRfQprKmvcjS
158
158
  huggingface_hub/utils/logging.py,sha256=0A8fF1yh3L9Ka_bCDX2ml4U5Ht0tY8Dr3JcbRvWFuwo,4909
159
159
  huggingface_hub/utils/sha.py,sha256=OFnNGCba0sNcT2gUwaVCJnldxlltrHHe0DS_PCpV3C4,2134
160
160
  huggingface_hub/utils/tqdm.py,sha256=xAKcyfnNHsZ7L09WuEM5Ew5-MDhiahLACbbN2zMmcLs,10671
161
- huggingface_hub-0.34.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
162
- huggingface_hub-0.34.1.dist-info/METADATA,sha256=xaTr-pbrzBfbAB1RTLrAXPON2rCp2nJeYcmvA6DGPKM,14699
163
- huggingface_hub-0.34.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
164
- huggingface_hub-0.34.1.dist-info/entry_points.txt,sha256=HIzLhjwPTO7U_ncpW4AkmzAuaadr1ajmYagW5mdb5TM,217
165
- huggingface_hub-0.34.1.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
166
- huggingface_hub-0.34.1.dist-info/RECORD,,
161
+ huggingface_hub-0.34.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
162
+ huggingface_hub-0.34.2.dist-info/METADATA,sha256=d4FiB50593tyle_zc-tcq9YDMmyWDiSUqPqMKuRgfbw,14699
163
+ huggingface_hub-0.34.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
164
+ huggingface_hub-0.34.2.dist-info/entry_points.txt,sha256=HIzLhjwPTO7U_ncpW4AkmzAuaadr1ajmYagW5mdb5TM,217
165
+ huggingface_hub-0.34.2.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
166
+ huggingface_hub-0.34.2.dist-info/RECORD,,