huggingface-hub 0.34.0rc0__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.0.rc0"
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
 
huggingface_hub/_oauth.py CHANGED
@@ -6,7 +6,7 @@ import time
6
6
  import urllib.parse
7
7
  import warnings
8
8
  from dataclasses import dataclass
9
- from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
9
+ from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Tuple, Union
10
10
 
11
11
  from . import constants
12
12
  from .hf_api import whoami
@@ -39,10 +39,8 @@ class OAuthOrgInfo:
39
39
  Whether the org has a payment method set up. Hugging Face field.
40
40
  role_in_org (`Optional[str]`, *optional*):
41
41
  The user's role in the org. Hugging Face field.
42
- pending_sso (`Optional[bool]`, *optional*):
43
- Indicates if the user granted the OAuth app access to the org but didn't complete SSO. Hugging Face field.
44
- missing_mfa (`Optional[bool]`, *optional*):
45
- Indicates if the user granted the OAuth app access to the org but didn't complete MFA. Hugging Face field.
42
+ security_restrictions (`Optional[List[Literal["ip", "token-policy", "mfa", "sso"]]]`, *optional*):
43
+ Array of security restrictions that the user hasn't completed for this org. Possible values: "ip", "token-policy", "mfa", "sso". Hugging Face field.
46
44
  """
47
45
 
48
46
  sub: str
@@ -52,8 +50,7 @@ class OAuthOrgInfo:
52
50
  is_enterprise: bool
53
51
  can_pay: Optional[bool] = None
54
52
  role_in_org: Optional[str] = None
55
- pending_sso: Optional[bool] = None
56
- missing_mfa: Optional[bool] = None
53
+ security_restrictions: Optional[List[Literal["ip", "token-policy", "mfa", "sso"]]] = None
57
54
 
58
55
 
59
56
  @dataclass
@@ -221,8 +218,7 @@ def parse_huggingface_oauth(request: "fastapi.Request") -> Optional[OAuthInfo]:
221
218
  is_enterprise=org.get("isEnterprise"),
222
219
  can_pay=org.get("canPay"),
223
220
  role_in_org=org.get("roleInOrg"),
224
- pending_sso=org.get("pendingSSO"),
225
- missing_mfa=org.get("missingMFA"),
221
+ security_restrictions=org.get("securityRestrictions"),
226
222
  )
227
223
  for org in orgs_data
228
224
  ]
@@ -62,6 +62,9 @@ class AuthCommands(BaseHuggingfaceCLICommand):
62
62
  auth_parser = parser.add_parser("auth", help="Manage authentication (login, logout, etc.).")
63
63
  auth_subparsers = auth_parser.add_subparsers(help="Authentication subcommands")
64
64
 
65
+ # Show help if no subcommand is provided
66
+ auth_parser.set_defaults(func=lambda args: auth_parser.print_help())
67
+
65
68
  # Add 'login' as a subcommand of 'auth'
66
69
  login_parser = auth_subparsers.add_parser(
67
70
  "login", help="Log in using a token from huggingface.co/settings/tokens"
@@ -65,6 +65,10 @@ class CacheCommand(BaseHuggingfaceCLICommand):
65
65
  def register_subcommand(parser: _SubParsersAction):
66
66
  cache_parser = parser.add_parser("cache", help="Manage local cache directory.")
67
67
  cache_subparsers = cache_parser.add_subparsers(dest="cache_command", help="Cache subcommands")
68
+
69
+ # Show help if no subcommand is provided
70
+ cache_parser.set_defaults(func=lambda args: cache_parser.print_help())
71
+
68
72
  # Scan subcommand
69
73
  scan_parser = cache_subparsers.add_parser("scan", help="Scan cache directory.")
70
74
  scan_parser.add_argument(
huggingface_hub/cli/hf.py CHANGED
@@ -47,10 +47,6 @@ def main():
47
47
  # LFS commands (hidden in --help)
48
48
  LfsCommands.register_subcommand(commands_parser)
49
49
 
50
- # Legacy commands
51
-
52
- # Experimental
53
-
54
50
  # Let's go
55
51
  args = parser.parse_args()
56
52
  if not hasattr(args, "func"):
@@ -59,7 +55,8 @@ def main():
59
55
 
60
56
  # Run
61
57
  service = args.func(args)
62
- service.run()
58
+ if service is not None:
59
+ service.run()
63
60
 
64
61
 
65
62
  if __name__ == "__main__":
@@ -58,6 +58,9 @@ class JobsCommands(BaseHuggingfaceCLICommand):
58
58
  jobs_parser = parser.add_parser("jobs", help="Run and manage Jobs on the Hub.")
59
59
  jobs_subparsers = jobs_parser.add_subparsers(help="huggingface.co jobs related commands")
60
60
 
61
+ # Show help if no subcommand is provided
62
+ jobs_parser.set_defaults(func=lambda args: jobs_parser.print_help())
63
+
61
64
  # Register commands
62
65
  InspectCommand.register_subcommand(jobs_subparsers)
63
66
  LogsCommand.register_subcommand(jobs_subparsers)
@@ -43,6 +43,10 @@ class RepoCommands(BaseHuggingfaceCLICommand):
43
43
  def register_subcommand(parser: _SubParsersAction):
44
44
  repo_parser = parser.add_parser("repo", help="Manage repos on the Hub.")
45
45
  repo_subparsers = repo_parser.add_subparsers(help="huggingface.co repos related commands")
46
+
47
+ # Show help if no subcommand is provided
48
+ repo_parser.set_defaults(func=lambda args: repo_parser.print_help())
49
+
46
50
  # CREATE
47
51
  repo_create_parser = repo_subparsers.add_parser("create", help="Create a new repo on huggingface.co")
48
52
  repo_create_parser.add_argument(
@@ -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.0rc0
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,11 +1,11 @@
1
- huggingface_hub/__init__.py,sha256=d0jxVfb3BEbTd8KEZ-OAOGN5pOyNkQEsm8O5x8LD0xY,51841
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
- huggingface_hub/_oauth.py,sha256=iAuRaMvB2rw5yMIoty_ojeuqtV5sxs__TAMYKl8LrNU,18794
8
+ huggingface_hub/_oauth.py,sha256=75ya9toHxC0WRKsLOAI212CrssRjTSxs16mHWWNMb3w,18714
9
9
  huggingface_hub/_snapshot_download.py,sha256=b-NzYQcvktsAirIfGQKgzQwu8w0S6lhBTvnJ5S6saw8,16166
10
10
  huggingface_hub/_space_api.py,sha256=jb6rF8qLtjaNU12D-8ygAPM26xDiHCu8CHXHowhGTmg,5470
11
11
  huggingface_hub/_tensorboard_logger.py,sha256=ZkYcAUiRC8RGL214QUYtp58O8G5tn-HF6DCWha9imcA,8358
@@ -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
@@ -30,13 +30,13 @@ huggingface_hub/repocard_data.py,sha256=hr4ReFpEQMNdh_9Dx-L-IJoI1ElHyk-h-8ZRqwVY
30
30
  huggingface_hub/repository.py,sha256=Lerq3kr7tC-oUdZk5i1CdhAA84ZvYiqjaGR77j2iOyk,54536
31
31
  huggingface_hub/cli/__init__.py,sha256=xzX1qgAvrtAX4gP59WrPlvOZFLuzuTgcjvanQvcpgHc,928
32
32
  huggingface_hub/cli/_cli_utils.py,sha256=Nt6CjbkYqQQRuh70bUXVA6rZpbZt_Sa1WqBUxjQLu6g,2095
33
- huggingface_hub/cli/auth.py,sha256=igG0C90hL2jP8XMAb1SzziWLB4CjJab1ytOevM3ZcpA,7169
34
- huggingface_hub/cli/cache.py,sha256=YB_M4zbXibZ66eSCvXNKNyJTuAJlatT_z_3f-dZXAuM,15741
33
+ huggingface_hub/cli/auth.py,sha256=BO6sJJcdHhjouMEH5JpUmC0qg3vaukX4I5DtA7ohLes,7296
34
+ huggingface_hub/cli/cache.py,sha256=zPLEWP5MidLElo0FeLvkUjCT0EYlX1pmC-2TkCa8kD0,15871
35
35
  huggingface_hub/cli/download.py,sha256=PUpW-nbu6ZAP6P9DpVhliAKSSlxvXWkVh0U2KZoukhQ,7115
36
- huggingface_hub/cli/hf.py,sha256=37SD4_xnY0UeMPL5xRDI2ly6OxsGULDS0i7dD2FqN7c,2339
37
- huggingface_hub/cli/jobs.py,sha256=Nu0XwSJF2CiGRcgJesgkCWbZDABFkx7Erppa6TLHFdo,20464
36
+ huggingface_hub/cli/hf.py,sha256=SQ73_SXEQnWVJkhKT_6bwNQBHQXGOdI5qqlTTtI0XH0,2328
37
+ huggingface_hub/cli/jobs.py,sha256=_UoqggR7TvLuQmZLHgKSYqJVo2037UEeeAiLOGr5n8c,20591
38
38
  huggingface_hub/cli/lfs.py,sha256=J9MkKOGUW6GjBrKs2zZUCOaAGxpatxsEoSbBjuhDJV8,7230
39
- huggingface_hub/cli/repo.py,sha256=nTrWQ8pbO5Zv0Lw7nFAagow6BSCPYzed6IcWpVgOMb4,10448
39
+ huggingface_hub/cli/repo.py,sha256=lNDEZbOpLW8SQVBYDQ1xofw9nJ7M8AUsd2kBIV_m_do,10576
40
40
  huggingface_hub/cli/repo_files.py,sha256=L-Ku52l2vZ04GCabp_OhVXqLzE9dsKQqaQKudGzjWg4,4831
41
41
  huggingface_hub/cli/system.py,sha256=eLSYME7ywt5Ae3tYQnS43Tai2pR2JLtA1KGImzPt5pM,1707
42
42
  huggingface_hub/cli/upload.py,sha256=qOGccIcBYJtodmlQlFyGfV_ZGHYhWlAARr3fxgYLDnE,14349
@@ -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.0rc0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
162
- huggingface_hub-0.34.0rc0.dist-info/METADATA,sha256=KxzTCJQzEr_LX_CWrwfEe5Huuv5WcPwmhJPQeds4YYQ,14702
163
- huggingface_hub-0.34.0rc0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
164
- huggingface_hub-0.34.0rc0.dist-info/entry_points.txt,sha256=HIzLhjwPTO7U_ncpW4AkmzAuaadr1ajmYagW5mdb5TM,217
165
- huggingface_hub-0.34.0rc0.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
166
- huggingface_hub-0.34.0rc0.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,,