huggingface-hub 0.35.0rc0__py3-none-any.whl → 0.35.1__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 +19 -1
- huggingface_hub/_jobs_api.py +168 -12
- huggingface_hub/_local_folder.py +1 -1
- huggingface_hub/_oauth.py +5 -9
- huggingface_hub/_tensorboard_logger.py +9 -10
- huggingface_hub/_upload_large_folder.py +108 -1
- huggingface_hub/cli/auth.py +4 -1
- huggingface_hub/cli/cache.py +7 -9
- huggingface_hub/cli/hf.py +2 -5
- huggingface_hub/cli/jobs.py +591 -13
- huggingface_hub/cli/repo.py +10 -4
- huggingface_hub/commands/delete_cache.py +2 -2
- huggingface_hub/commands/scan_cache.py +1 -1
- huggingface_hub/dataclasses.py +3 -0
- huggingface_hub/file_download.py +12 -10
- huggingface_hub/hf_api.py +549 -95
- huggingface_hub/hf_file_system.py +4 -10
- huggingface_hub/hub_mixin.py +5 -3
- huggingface_hub/inference/_client.py +98 -181
- huggingface_hub/inference/_common.py +72 -70
- huggingface_hub/inference/_generated/_async_client.py +116 -201
- huggingface_hub/inference/_generated/types/chat_completion.py +2 -0
- huggingface_hub/inference/_mcp/_cli_hacks.py +3 -3
- huggingface_hub/inference/_mcp/cli.py +1 -1
- huggingface_hub/inference/_mcp/constants.py +1 -1
- huggingface_hub/inference/_mcp/mcp_client.py +28 -11
- huggingface_hub/inference/_mcp/types.py +3 -0
- huggingface_hub/inference/_mcp/utils.py +7 -3
- huggingface_hub/inference/_providers/__init__.py +13 -0
- huggingface_hub/inference/_providers/_common.py +29 -4
- huggingface_hub/inference/_providers/black_forest_labs.py +1 -1
- huggingface_hub/inference/_providers/fal_ai.py +33 -2
- huggingface_hub/inference/_providers/hf_inference.py +15 -7
- huggingface_hub/inference/_providers/publicai.py +6 -0
- huggingface_hub/inference/_providers/replicate.py +1 -1
- huggingface_hub/inference/_providers/scaleway.py +28 -0
- huggingface_hub/lfs.py +2 -4
- huggingface_hub/repocard.py +2 -1
- huggingface_hub/utils/_dotenv.py +24 -20
- huggingface_hub/utils/_git_credential.py +1 -1
- huggingface_hub/utils/_http.py +3 -5
- huggingface_hub/utils/_runtime.py +1 -0
- huggingface_hub/utils/_typing.py +24 -4
- huggingface_hub/utils/_xet_progress_reporting.py +31 -10
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/METADATA +7 -4
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/RECORD +50 -48
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-0.35.1.dist-info}/top_level.txt +0 -0
huggingface_hub/cli/repo.py
CHANGED
|
@@ -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(
|
|
@@ -179,7 +183,9 @@ class RepoTagCommand:
|
|
|
179
183
|
|
|
180
184
|
class RepoTagCreateCommand(RepoTagCommand):
|
|
181
185
|
def run(self):
|
|
182
|
-
print(
|
|
186
|
+
print(
|
|
187
|
+
f"You are about to create tag {ANSI.bold(str(self.args.tag))} on {self.repo_type} {ANSI.bold(self.repo_id)}"
|
|
188
|
+
)
|
|
183
189
|
try:
|
|
184
190
|
self.api.create_tag(
|
|
185
191
|
repo_id=self.repo_id,
|
|
@@ -192,14 +198,14 @@ class RepoTagCreateCommand(RepoTagCommand):
|
|
|
192
198
|
print(f"{self.repo_type.capitalize()} {ANSI.bold(self.repo_id)} not found.")
|
|
193
199
|
exit(1)
|
|
194
200
|
except RevisionNotFoundError:
|
|
195
|
-
print(f"Revision {ANSI.bold(getattr(self.args, 'revision', None))} not found.")
|
|
201
|
+
print(f"Revision {ANSI.bold(str(getattr(self.args, 'revision', None)))} not found.")
|
|
196
202
|
exit(1)
|
|
197
203
|
except HfHubHTTPError as e:
|
|
198
204
|
if e.response.status_code == 409:
|
|
199
|
-
print(f"Tag {ANSI.bold(self.args.tag)} already exists on {ANSI.bold(self.repo_id)}")
|
|
205
|
+
print(f"Tag {ANSI.bold(str(self.args.tag))} already exists on {ANSI.bold(self.repo_id)}")
|
|
200
206
|
exit(1)
|
|
201
207
|
raise e
|
|
202
|
-
print(f"Tag {ANSI.bold(self.args.tag)} created on {ANSI.bold(self.repo_id)}")
|
|
208
|
+
print(f"Tag {ANSI.bold(str(self.args.tag))} created on {ANSI.bold(self.repo_id)}")
|
|
203
209
|
|
|
204
210
|
|
|
205
211
|
class RepoTagListCommand(RepoTagCommand):
|
|
@@ -22,7 +22,7 @@ Usage:
|
|
|
22
22
|
|
|
23
23
|
NOTE:
|
|
24
24
|
This command is based on `InquirerPy` to build the multiselect menu in the terminal.
|
|
25
|
-
This dependency has to be installed with `pip install huggingface_hub[cli]`. Since
|
|
25
|
+
This dependency has to be installed with `pip install "huggingface_hub[cli]"`. Since
|
|
26
26
|
we want to avoid as much as possible cross-platform issues, I chose a library that
|
|
27
27
|
is built on top of `python-prompt-toolkit` which seems to be a reference in terminal
|
|
28
28
|
GUI (actively maintained on both Unix and Windows, 7.9k stars).
|
|
@@ -88,7 +88,7 @@ def require_inquirer_py(fn: Callable) -> Callable:
|
|
|
88
88
|
if not _inquirer_py_available:
|
|
89
89
|
raise ImportError(
|
|
90
90
|
"The `delete-cache` command requires extra dependencies to work with"
|
|
91
|
-
|
|
91
|
+
' the TUI.\nPlease run `pip install "huggingface_hub[cli]"` to install'
|
|
92
92
|
" them.\nOtherwise, disable TUI using the `--disable-tui` flag."
|
|
93
93
|
)
|
|
94
94
|
|
|
@@ -77,7 +77,7 @@ class ScanCacheCommand(BaseHuggingfaceCLICommand):
|
|
|
77
77
|
if self.verbosity >= 3:
|
|
78
78
|
print(ANSI.gray(message))
|
|
79
79
|
for warning in hf_cache_info.warnings:
|
|
80
|
-
print(ANSI.gray(warning))
|
|
80
|
+
print(ANSI.gray(str(warning)))
|
|
81
81
|
else:
|
|
82
82
|
print(ANSI.gray(message + " Use -vvv to print details."))
|
|
83
83
|
|
huggingface_hub/dataclasses.py
CHANGED
|
@@ -5,6 +5,7 @@ from typing import (
|
|
|
5
5
|
Any,
|
|
6
6
|
Callable,
|
|
7
7
|
Dict,
|
|
8
|
+
ForwardRef,
|
|
8
9
|
List,
|
|
9
10
|
Literal,
|
|
10
11
|
Optional,
|
|
@@ -325,6 +326,8 @@ def type_validator(name: str, value: Any, expected_type: Any) -> None:
|
|
|
325
326
|
validator(name, value, args)
|
|
326
327
|
elif isinstance(expected_type, type): # simple types
|
|
327
328
|
_validate_simple_type(name, value, expected_type)
|
|
329
|
+
elif isinstance(expected_type, ForwardRef) or isinstance(expected_type, str):
|
|
330
|
+
return
|
|
328
331
|
else:
|
|
329
332
|
raise TypeError(f"Unsupported type for field '{name}': {expected_type}")
|
|
330
333
|
|
huggingface_hub/file_download.py
CHANGED
|
@@ -267,7 +267,7 @@ def _request_wrapper(
|
|
|
267
267
|
"""Wrapper around requests methods to follow relative redirects if `follow_relative_redirects=True` even when
|
|
268
268
|
`allow_redirection=False`.
|
|
269
269
|
|
|
270
|
-
A backoff mechanism retries the HTTP call on
|
|
270
|
+
A backoff mechanism retries the HTTP call on 5xx errors and network errors.
|
|
271
271
|
|
|
272
272
|
Args:
|
|
273
273
|
method (`str`):
|
|
@@ -306,7 +306,7 @@ def _request_wrapper(
|
|
|
306
306
|
return response
|
|
307
307
|
|
|
308
308
|
# Perform request and return if status_code is not in the retry list.
|
|
309
|
-
response = http_backoff(method=method, url=url, **params
|
|
309
|
+
response = http_backoff(method=method, url=url, **params)
|
|
310
310
|
hf_raise_for_status(response)
|
|
311
311
|
return response
|
|
312
312
|
|
|
@@ -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
|
-
|
|
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
|