huggingface-hub 0.35.1__py3-none-any.whl → 1.0.0rc1__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 +28 -45
- huggingface_hub/_commit_api.py +28 -28
- huggingface_hub/_commit_scheduler.py +11 -8
- huggingface_hub/_inference_endpoints.py +8 -8
- huggingface_hub/_jobs_api.py +20 -20
- huggingface_hub/_login.py +13 -39
- huggingface_hub/_oauth.py +8 -8
- huggingface_hub/_snapshot_download.py +14 -28
- huggingface_hub/_space_api.py +4 -4
- huggingface_hub/_tensorboard_logger.py +5 -5
- huggingface_hub/_upload_large_folder.py +15 -15
- huggingface_hub/_webhooks_payload.py +3 -3
- huggingface_hub/_webhooks_server.py +2 -2
- huggingface_hub/cli/__init__.py +0 -14
- huggingface_hub/cli/_cli_utils.py +80 -3
- huggingface_hub/cli/auth.py +104 -150
- huggingface_hub/cli/cache.py +102 -126
- huggingface_hub/cli/download.py +93 -110
- huggingface_hub/cli/hf.py +37 -41
- huggingface_hub/cli/jobs.py +689 -1017
- huggingface_hub/cli/lfs.py +120 -143
- huggingface_hub/cli/repo.py +158 -216
- huggingface_hub/cli/repo_files.py +50 -84
- huggingface_hub/cli/system.py +6 -25
- huggingface_hub/cli/upload.py +198 -212
- huggingface_hub/cli/upload_large_folder.py +90 -105
- huggingface_hub/commands/_cli_utils.py +2 -2
- huggingface_hub/commands/delete_cache.py +11 -11
- huggingface_hub/commands/download.py +4 -13
- huggingface_hub/commands/lfs.py +4 -4
- huggingface_hub/commands/repo_files.py +2 -2
- huggingface_hub/commands/tag.py +1 -3
- huggingface_hub/commands/upload.py +4 -4
- huggingface_hub/commands/upload_large_folder.py +3 -3
- huggingface_hub/commands/user.py +4 -5
- huggingface_hub/community.py +5 -5
- huggingface_hub/constants.py +3 -41
- huggingface_hub/dataclasses.py +16 -22
- huggingface_hub/errors.py +43 -30
- huggingface_hub/fastai_utils.py +8 -9
- huggingface_hub/file_download.py +154 -253
- huggingface_hub/hf_api.py +329 -558
- huggingface_hub/hf_file_system.py +104 -62
- huggingface_hub/hub_mixin.py +32 -54
- huggingface_hub/inference/_client.py +178 -163
- huggingface_hub/inference/_common.py +38 -54
- huggingface_hub/inference/_generated/_async_client.py +219 -259
- huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +3 -3
- huggingface_hub/inference/_generated/types/base.py +10 -7
- huggingface_hub/inference/_generated/types/chat_completion.py +16 -16
- huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
- huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
- huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
- huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
- huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
- huggingface_hub/inference/_generated/types/summarization.py +2 -2
- huggingface_hub/inference/_generated/types/table_question_answering.py +4 -4
- huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
- huggingface_hub/inference/_generated/types/text_generation.py +10 -10
- huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
- huggingface_hub/inference/_generated/types/token_classification.py +2 -2
- huggingface_hub/inference/_generated/types/translation.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
- huggingface_hub/inference/_mcp/agent.py +3 -3
- huggingface_hub/inference/_mcp/constants.py +1 -2
- huggingface_hub/inference/_mcp/mcp_client.py +33 -22
- huggingface_hub/inference/_mcp/types.py +10 -10
- huggingface_hub/inference/_mcp/utils.py +4 -4
- huggingface_hub/inference/_providers/__init__.py +2 -13
- huggingface_hub/inference/_providers/_common.py +24 -25
- huggingface_hub/inference/_providers/black_forest_labs.py +6 -6
- huggingface_hub/inference/_providers/cohere.py +3 -3
- huggingface_hub/inference/_providers/fal_ai.py +25 -25
- huggingface_hub/inference/_providers/featherless_ai.py +4 -4
- huggingface_hub/inference/_providers/fireworks_ai.py +3 -3
- huggingface_hub/inference/_providers/hf_inference.py +13 -13
- huggingface_hub/inference/_providers/hyperbolic.py +4 -4
- huggingface_hub/inference/_providers/nebius.py +10 -10
- huggingface_hub/inference/_providers/novita.py +5 -5
- huggingface_hub/inference/_providers/nscale.py +4 -4
- huggingface_hub/inference/_providers/replicate.py +15 -15
- huggingface_hub/inference/_providers/sambanova.py +6 -6
- huggingface_hub/inference/_providers/together.py +7 -7
- huggingface_hub/lfs.py +24 -33
- huggingface_hub/repocard.py +16 -17
- huggingface_hub/repocard_data.py +56 -56
- huggingface_hub/serialization/__init__.py +0 -1
- huggingface_hub/serialization/_base.py +9 -9
- huggingface_hub/serialization/_dduf.py +7 -7
- huggingface_hub/serialization/_torch.py +28 -28
- huggingface_hub/utils/__init__.py +10 -4
- huggingface_hub/utils/_auth.py +5 -5
- huggingface_hub/utils/_cache_manager.py +31 -31
- huggingface_hub/utils/_deprecation.py +1 -1
- huggingface_hub/utils/_dotenv.py +3 -3
- huggingface_hub/utils/_fixes.py +0 -10
- huggingface_hub/utils/_git_credential.py +3 -3
- huggingface_hub/utils/_headers.py +7 -29
- huggingface_hub/utils/_http.py +369 -209
- huggingface_hub/utils/_pagination.py +4 -4
- huggingface_hub/utils/_paths.py +5 -5
- huggingface_hub/utils/_runtime.py +15 -13
- huggingface_hub/utils/_safetensors.py +21 -21
- huggingface_hub/utils/_subprocess.py +9 -9
- huggingface_hub/utils/_telemetry.py +3 -3
- huggingface_hub/utils/_typing.py +3 -3
- huggingface_hub/utils/_validators.py +53 -72
- huggingface_hub/utils/_xet.py +16 -16
- huggingface_hub/utils/_xet_progress_reporting.py +1 -1
- huggingface_hub/utils/insecure_hashlib.py +3 -9
- huggingface_hub/utils/tqdm.py +3 -3
- {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/METADATA +17 -26
- huggingface_hub-1.0.0rc1.dist-info/RECORD +161 -0
- huggingface_hub/inference/_providers/publicai.py +0 -6
- huggingface_hub/inference/_providers/scaleway.py +0 -28
- huggingface_hub/inference_api.py +0 -217
- huggingface_hub/keras_mixin.py +0 -500
- huggingface_hub/repository.py +0 -1477
- huggingface_hub/serialization/_tensorflow.py +0 -95
- huggingface_hub/utils/_hf_folder.py +0 -68
- huggingface_hub-0.35.1.dist-info/RECORD +0 -168
- {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -15,118 +15,103 @@
|
|
|
15
15
|
"""Contains command to upload a large folder with the CLI."""
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
|
-
from
|
|
19
|
-
|
|
18
|
+
from typing import Annotated, Optional
|
|
19
|
+
|
|
20
|
+
import typer
|
|
20
21
|
|
|
21
22
|
from huggingface_hub import logging
|
|
22
|
-
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
23
|
-
from huggingface_hub.hf_api import HfApi
|
|
24
23
|
from huggingface_hub.utils import disable_progress_bars
|
|
25
24
|
|
|
26
|
-
from ._cli_utils import ANSI
|
|
25
|
+
from ._cli_utils import ANSI, PrivateOpt, RepoIdArg, RepoType, RepoTypeOpt, RevisionOpt, TokenOpt, get_hf_api
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
logger = logging.get_logger(__name__)
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
help="
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
help="
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
" - Do not start several processes in parallel.\n"
|
|
102
|
-
" - You can interrupt and resume the process at any time. "
|
|
103
|
-
"The script will pick up where it left off except for partially uploaded files that would have to be entirely reuploaded.\n"
|
|
104
|
-
" - Do not upload the same folder to several repositories. If you need to do so, you must delete the `./.cache/huggingface/` folder first.\n"
|
|
105
|
-
"\n"
|
|
106
|
-
f"Some temporary metadata will be stored under `{self.local_path}/.cache/huggingface`.\n"
|
|
107
|
-
" - You must not modify those files manually.\n"
|
|
108
|
-
" - You must not delete the `./.cache/huggingface/` folder while a process is running.\n"
|
|
109
|
-
" - You can delete the `./.cache/huggingface/` folder to reinitialize the upload state when process is not running. Files will have to be hashed and preuploaded again, except for already committed files.\n"
|
|
110
|
-
"\n"
|
|
111
|
-
"If the process output is too verbose, you can disable the progress bars with `--no-bars`. "
|
|
112
|
-
"You can also entirely disable the status report with `--no-report`.\n"
|
|
113
|
-
"\n"
|
|
114
|
-
"For more details, run `hf upload-large-folder --help` or check the documentation at "
|
|
115
|
-
"https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-large-folder."
|
|
116
|
-
)
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
if self.no_bars:
|
|
120
|
-
disable_progress_bars()
|
|
121
|
-
|
|
122
|
-
self.api.upload_large_folder(
|
|
123
|
-
repo_id=self.repo_id,
|
|
124
|
-
folder_path=self.local_path,
|
|
125
|
-
repo_type=self.repo_type,
|
|
126
|
-
revision=self.revision,
|
|
127
|
-
private=self.private,
|
|
128
|
-
allow_patterns=self.include,
|
|
129
|
-
ignore_patterns=self.exclude,
|
|
130
|
-
num_workers=self.num_workers,
|
|
131
|
-
print_report=not self.no_report,
|
|
31
|
+
def upload_large_folder(
|
|
32
|
+
repo_id: RepoIdArg,
|
|
33
|
+
local_path: Annotated[
|
|
34
|
+
str,
|
|
35
|
+
typer.Argument(
|
|
36
|
+
help="Local path to the folder to upload.",
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
repo_type: RepoTypeOpt = RepoType.model,
|
|
40
|
+
revision: RevisionOpt = None,
|
|
41
|
+
private: PrivateOpt = False,
|
|
42
|
+
include: Annotated[
|
|
43
|
+
Optional[list[str]],
|
|
44
|
+
typer.Option(
|
|
45
|
+
help="Glob patterns to match files to upload.",
|
|
46
|
+
),
|
|
47
|
+
] = None,
|
|
48
|
+
exclude: Annotated[
|
|
49
|
+
Optional[list[str]],
|
|
50
|
+
typer.Option(
|
|
51
|
+
help="Glob patterns to exclude from files to upload.",
|
|
52
|
+
),
|
|
53
|
+
] = None,
|
|
54
|
+
token: TokenOpt = None,
|
|
55
|
+
num_workers: Annotated[
|
|
56
|
+
Optional[int],
|
|
57
|
+
typer.Option(
|
|
58
|
+
help="Number of workers to use to hash, upload and commit files.",
|
|
59
|
+
),
|
|
60
|
+
] = None,
|
|
61
|
+
no_report: Annotated[
|
|
62
|
+
bool,
|
|
63
|
+
typer.Option(
|
|
64
|
+
help="Whether to disable regular status report.",
|
|
65
|
+
),
|
|
66
|
+
] = False,
|
|
67
|
+
no_bars: Annotated[
|
|
68
|
+
bool,
|
|
69
|
+
typer.Option(
|
|
70
|
+
help="Whether to disable progress bars.",
|
|
71
|
+
),
|
|
72
|
+
] = False,
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Upload a large folder to the Hub. Recommended for resumable uploads."""
|
|
75
|
+
if not os.path.isdir(local_path):
|
|
76
|
+
raise typer.BadParameter("Large upload is only supported for folders.", param_hint="local_path")
|
|
77
|
+
|
|
78
|
+
print(
|
|
79
|
+
ANSI.yellow(
|
|
80
|
+
"You are about to upload a large folder to the Hub using `hf upload-large-folder`. "
|
|
81
|
+
"This is a new feature so feedback is very welcome!\n"
|
|
82
|
+
"\n"
|
|
83
|
+
"A few things to keep in mind:\n"
|
|
84
|
+
" - Repository limits still apply: https://huggingface.co/docs/hub/repositories-recommendations\n"
|
|
85
|
+
" - Do not start several processes in parallel.\n"
|
|
86
|
+
" - You can interrupt and resume the process at any time. "
|
|
87
|
+
"The script will pick up where it left off except for partially uploaded files that would have to be entirely reuploaded.\n"
|
|
88
|
+
" - Do not upload the same folder to several repositories. If you need to do so, you must delete the `./.cache/huggingface/` folder first.\n"
|
|
89
|
+
"\n"
|
|
90
|
+
f"Some temporary metadata will be stored under `{local_path}/.cache/huggingface`.\n"
|
|
91
|
+
" - You must not modify those files manually.\n"
|
|
92
|
+
" - You must not delete the `./.cache/huggingface/` folder while a process is running.\n"
|
|
93
|
+
" - You can delete the `./.cache/huggingface/` folder to reinitialize the upload state when process is not running. Files will have to be hashed and preuploaded again, except for already committed files.\n"
|
|
94
|
+
"\n"
|
|
95
|
+
"If the process output is too verbose, you can disable the progress bars with `--no-bars`. "
|
|
96
|
+
"You can also entirely disable the status report with `--no-report`.\n"
|
|
97
|
+
"\n"
|
|
98
|
+
"For more details, run `hf upload-large-folder --help` or check the documentation at "
|
|
99
|
+
"https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-large-folder."
|
|
132
100
|
)
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if no_bars:
|
|
104
|
+
disable_progress_bars()
|
|
105
|
+
|
|
106
|
+
api = get_hf_api(token=token)
|
|
107
|
+
api.upload_large_folder(
|
|
108
|
+
repo_id=repo_id,
|
|
109
|
+
folder_path=local_path,
|
|
110
|
+
repo_type=repo_type.value,
|
|
111
|
+
revision=revision,
|
|
112
|
+
private=private,
|
|
113
|
+
allow_patterns=include,
|
|
114
|
+
ignore_patterns=exclude,
|
|
115
|
+
num_workers=num_workers,
|
|
116
|
+
print_report=not no_report,
|
|
117
|
+
)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"""Contains a utility for good-looking prints."""
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Union
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class ANSI:
|
|
@@ -52,7 +52,7 @@ class ANSI:
|
|
|
52
52
|
return f"{code}{s}{cls._reset}"
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def tabulate(rows:
|
|
55
|
+
def tabulate(rows: list[list[Union[str, int]]], headers: list[str]) -> str:
|
|
56
56
|
"""
|
|
57
57
|
Inspired by:
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ import os
|
|
|
60
60
|
from argparse import Namespace, _SubParsersAction
|
|
61
61
|
from functools import wraps
|
|
62
62
|
from tempfile import mkstemp
|
|
63
|
-
from typing import Any, Callable, Iterable,
|
|
63
|
+
from typing import Any, Callable, Iterable, Literal, Optional, Union
|
|
64
64
|
|
|
65
65
|
from ..utils import CachedRepoInfo, CachedRevisionInfo, HFCacheInfo, scan_cache_dir
|
|
66
66
|
from . import BaseHuggingfaceCLICommand
|
|
@@ -197,9 +197,9 @@ def _get_repo_sorting_key(repo: CachedRepoInfo, sort_by: Optional[SortingOption_
|
|
|
197
197
|
@require_inquirer_py
|
|
198
198
|
def _manual_review_tui(
|
|
199
199
|
hf_cache_info: HFCacheInfo,
|
|
200
|
-
preselected:
|
|
200
|
+
preselected: list[str],
|
|
201
201
|
sort_by: Optional[SortingOption_T] = None,
|
|
202
|
-
) ->
|
|
202
|
+
) -> list[str]:
|
|
203
203
|
"""Ask the user for a manual review of the revisions to delete.
|
|
204
204
|
|
|
205
205
|
Displays a multi-select menu in the terminal (TUI).
|
|
@@ -254,15 +254,15 @@ def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
|
|
|
254
254
|
|
|
255
255
|
def _get_tui_choices_from_scan(
|
|
256
256
|
repos: Iterable[CachedRepoInfo],
|
|
257
|
-
preselected:
|
|
257
|
+
preselected: list[str],
|
|
258
258
|
sort_by: Optional[SortingOption_T] = None,
|
|
259
|
-
) ->
|
|
259
|
+
) -> list:
|
|
260
260
|
"""Build a list of choices from the scanned repos.
|
|
261
261
|
|
|
262
262
|
Args:
|
|
263
263
|
repos (*Iterable[`CachedRepoInfo`]*):
|
|
264
264
|
List of scanned repos on which we want to delete revisions.
|
|
265
|
-
preselected (*
|
|
265
|
+
preselected (*list[`str`]*):
|
|
266
266
|
List of revision hashes that will be preselected.
|
|
267
267
|
sort_by (*Optional[SortingOption_T]*):
|
|
268
268
|
Sorting direction. Choices: "alphabetical", "lastUpdated", "lastUsed", "size".
|
|
@@ -270,7 +270,7 @@ def _get_tui_choices_from_scan(
|
|
|
270
270
|
Return:
|
|
271
271
|
The list of choices to pass to `inquirer.checkbox`.
|
|
272
272
|
"""
|
|
273
|
-
choices:
|
|
273
|
+
choices: list[Union[Choice, Separator]] = []
|
|
274
274
|
|
|
275
275
|
# First choice is to cancel the deletion
|
|
276
276
|
choices.append(
|
|
@@ -312,9 +312,9 @@ def _get_tui_choices_from_scan(
|
|
|
312
312
|
|
|
313
313
|
def _manual_review_no_tui(
|
|
314
314
|
hf_cache_info: HFCacheInfo,
|
|
315
|
-
preselected:
|
|
315
|
+
preselected: list[str],
|
|
316
316
|
sort_by: Optional[SortingOption_T] = None,
|
|
317
|
-
) ->
|
|
317
|
+
) -> list[str]:
|
|
318
318
|
"""Ask the user for a manual review of the revisions to delete.
|
|
319
319
|
|
|
320
320
|
Used when TUI is disabled. Manual review happens in a separate tmp file that the
|
|
@@ -390,7 +390,7 @@ def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
|
|
|
390
390
|
print(f"Invalid input. Must be one of {ALL}")
|
|
391
391
|
|
|
392
392
|
|
|
393
|
-
def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes:
|
|
393
|
+
def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: list[str]) -> str:
|
|
394
394
|
"""Format a string to display to the user how much space would be saved.
|
|
395
395
|
|
|
396
396
|
Example:
|
|
@@ -405,7 +405,7 @@ def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]
|
|
|
405
405
|
return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
|
|
406
406
|
|
|
407
407
|
|
|
408
|
-
def _read_manual_review_tmp_file(tmp_path: str) ->
|
|
408
|
+
def _read_manual_review_tmp_file(tmp_path: str) -> list[str]:
|
|
409
409
|
"""Read the manually reviewed instruction file and return a list of revision hash.
|
|
410
410
|
|
|
411
411
|
Example:
|
|
@@ -38,7 +38,7 @@ Usage:
|
|
|
38
38
|
|
|
39
39
|
import warnings
|
|
40
40
|
from argparse import Namespace, _SubParsersAction
|
|
41
|
-
from typing import
|
|
41
|
+
from typing import Optional
|
|
42
42
|
|
|
43
43
|
from huggingface_hub import logging
|
|
44
44
|
from huggingface_hub._snapshot_download import snapshot_download
|
|
@@ -125,24 +125,17 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
|
|
|
125
125
|
def __init__(self, args: Namespace) -> None:
|
|
126
126
|
self.token = args.token
|
|
127
127
|
self.repo_id: str = args.repo_id
|
|
128
|
-
self.filenames:
|
|
128
|
+
self.filenames: list[str] = args.filenames
|
|
129
129
|
self.repo_type: str = args.repo_type
|
|
130
130
|
self.revision: Optional[str] = args.revision
|
|
131
|
-
self.include: Optional[
|
|
132
|
-
self.exclude: Optional[
|
|
131
|
+
self.include: Optional[list[str]] = args.include
|
|
132
|
+
self.exclude: Optional[list[str]] = args.exclude
|
|
133
133
|
self.cache_dir: Optional[str] = args.cache_dir
|
|
134
134
|
self.local_dir: Optional[str] = args.local_dir
|
|
135
135
|
self.force_download: bool = args.force_download
|
|
136
|
-
self.resume_download: Optional[bool] = args.resume_download or None
|
|
137
136
|
self.quiet: bool = args.quiet
|
|
138
137
|
self.max_workers: int = args.max_workers
|
|
139
138
|
|
|
140
|
-
if args.local_dir_use_symlinks is not None:
|
|
141
|
-
warnings.warn(
|
|
142
|
-
"Ignoring --local-dir-use-symlinks. Downloading to a local directory does not use symlinks anymore.",
|
|
143
|
-
FutureWarning,
|
|
144
|
-
)
|
|
145
|
-
|
|
146
139
|
def run(self) -> None:
|
|
147
140
|
show_deprecation_warning("huggingface-cli download", "hf download")
|
|
148
141
|
|
|
@@ -173,7 +166,6 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
|
|
|
173
166
|
revision=self.revision,
|
|
174
167
|
filename=self.filenames[0],
|
|
175
168
|
cache_dir=self.cache_dir,
|
|
176
|
-
resume_download=self.resume_download,
|
|
177
169
|
force_download=self.force_download,
|
|
178
170
|
token=self.token,
|
|
179
171
|
local_dir=self.local_dir,
|
|
@@ -194,7 +186,6 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
|
|
|
194
186
|
revision=self.revision,
|
|
195
187
|
allow_patterns=allow_patterns,
|
|
196
188
|
ignore_patterns=ignore_patterns,
|
|
197
|
-
resume_download=self.resume_download,
|
|
198
189
|
force_download=self.force_download,
|
|
199
190
|
cache_dir=self.cache_dir,
|
|
200
191
|
token=self.token,
|
huggingface_hub/commands/lfs.py
CHANGED
|
@@ -21,7 +21,7 @@ import os
|
|
|
21
21
|
import subprocess
|
|
22
22
|
import sys
|
|
23
23
|
from argparse import _SubParsersAction
|
|
24
|
-
from typing import
|
|
24
|
+
from typing import Optional
|
|
25
25
|
|
|
26
26
|
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
27
27
|
from huggingface_hub.lfs import LFS_MULTIPART_UPLOAD_COMMAND
|
|
@@ -89,14 +89,14 @@ class LfsEnableCommand:
|
|
|
89
89
|
print("Local repo set up for largefiles")
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def write_msg(msg:
|
|
92
|
+
def write_msg(msg: dict):
|
|
93
93
|
"""Write out the message in Line delimited JSON."""
|
|
94
94
|
msg_str = json.dumps(msg) + "\n"
|
|
95
95
|
sys.stdout.write(msg_str)
|
|
96
96
|
sys.stdout.flush()
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
def read_msg() -> Optional[
|
|
99
|
+
def read_msg() -> Optional[dict]:
|
|
100
100
|
"""Read Line delimited JSON from stdin."""
|
|
101
101
|
msg = json.loads(sys.stdin.readline().strip())
|
|
102
102
|
|
|
@@ -146,7 +146,7 @@ class LfsUploadCommand:
|
|
|
146
146
|
completion_url = msg["action"]["href"]
|
|
147
147
|
header = msg["action"]["header"]
|
|
148
148
|
chunk_size = int(header.pop("chunk_size"))
|
|
149
|
-
presigned_urls:
|
|
149
|
+
presigned_urls: list[str] = list(header.values())
|
|
150
150
|
|
|
151
151
|
# Send a "started" progress event to allow other workers to start.
|
|
152
152
|
# Otherwise they're delayed until first "progress" event is reported,
|
|
@@ -35,7 +35,7 @@ Usage:
|
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
37
|
from argparse import _SubParsersAction
|
|
38
|
-
from typing import
|
|
38
|
+
from typing import Optional
|
|
39
39
|
|
|
40
40
|
from huggingface_hub import logging
|
|
41
41
|
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
@@ -54,7 +54,7 @@ class DeleteFilesSubCommand:
|
|
|
54
54
|
self.repo_type: Optional[str] = args.repo_type
|
|
55
55
|
self.revision: Optional[str] = args.revision
|
|
56
56
|
self.api: HfApi = HfApi(token=args.token, library_name="huggingface-cli")
|
|
57
|
-
self.patterns:
|
|
57
|
+
self.patterns: list[str] = args.patterns
|
|
58
58
|
self.commit_message: Optional[str] = args.commit_message
|
|
59
59
|
self.commit_description: Optional[str] = args.commit_description
|
|
60
60
|
self.create_pr: bool = args.create_pr
|
huggingface_hub/commands/tag.py
CHANGED
|
@@ -32,8 +32,6 @@ Usage Examples:
|
|
|
32
32
|
|
|
33
33
|
from argparse import Namespace, _SubParsersAction
|
|
34
34
|
|
|
35
|
-
from requests.exceptions import HTTPError
|
|
36
|
-
|
|
37
35
|
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
38
36
|
from huggingface_hub.constants import (
|
|
39
37
|
REPO_TYPES,
|
|
@@ -129,7 +127,7 @@ class TagListCommand(TagCommand):
|
|
|
129
127
|
except RepositoryNotFoundError:
|
|
130
128
|
print(f"{self.repo_type.capitalize()} {ANSI.bold(self.repo_id)} not found.")
|
|
131
129
|
exit(1)
|
|
132
|
-
except
|
|
130
|
+
except HfHubHTTPError as e:
|
|
133
131
|
print(e)
|
|
134
132
|
print(ANSI.red(e.response.text))
|
|
135
133
|
exit(1)
|
|
@@ -50,7 +50,7 @@ import os
|
|
|
50
50
|
import time
|
|
51
51
|
import warnings
|
|
52
52
|
from argparse import Namespace, _SubParsersAction
|
|
53
|
-
from typing import
|
|
53
|
+
from typing import Optional
|
|
54
54
|
|
|
55
55
|
from huggingface_hub import logging
|
|
56
56
|
from huggingface_hub._commit_scheduler import CommitScheduler
|
|
@@ -144,9 +144,9 @@ class UploadCommand(BaseHuggingfaceCLICommand):
|
|
|
144
144
|
self.revision: Optional[str] = args.revision
|
|
145
145
|
self.private: bool = args.private
|
|
146
146
|
|
|
147
|
-
self.include: Optional[
|
|
148
|
-
self.exclude: Optional[
|
|
149
|
-
self.delete: Optional[
|
|
147
|
+
self.include: Optional[list[str]] = args.include
|
|
148
|
+
self.exclude: Optional[list[str]] = args.exclude
|
|
149
|
+
self.delete: Optional[list[str]] = args.delete
|
|
150
150
|
|
|
151
151
|
self.commit_message: Optional[str] = args.commit_message
|
|
152
152
|
self.commit_description: Optional[str] = args.commit_description
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
18
|
from argparse import Namespace, _SubParsersAction
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import Optional
|
|
20
20
|
|
|
21
21
|
from huggingface_hub import logging
|
|
22
22
|
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
@@ -73,8 +73,8 @@ class UploadLargeFolderCommand(BaseHuggingfaceCLICommand):
|
|
|
73
73
|
self.revision: Optional[str] = args.revision
|
|
74
74
|
self.private: bool = args.private
|
|
75
75
|
|
|
76
|
-
self.include: Optional[
|
|
77
|
-
self.exclude: Optional[
|
|
76
|
+
self.include: Optional[list[str]] = args.include
|
|
77
|
+
self.exclude: Optional[list[str]] = args.exclude
|
|
78
78
|
|
|
79
79
|
self.api: HfApi = HfApi(token=args.token, library_name="huggingface-cli")
|
|
80
80
|
|
huggingface_hub/commands/user.py
CHANGED
|
@@ -31,12 +31,11 @@ Usage:
|
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
33
|
from argparse import _SubParsersAction
|
|
34
|
-
from typing import
|
|
35
|
-
|
|
36
|
-
from requests.exceptions import HTTPError
|
|
34
|
+
from typing import Optional
|
|
37
35
|
|
|
38
36
|
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
39
37
|
from huggingface_hub.constants import ENDPOINT
|
|
38
|
+
from huggingface_hub.errors import HfHubHTTPError
|
|
40
39
|
from huggingface_hub.hf_api import HfApi
|
|
41
40
|
|
|
42
41
|
from .._login import auth_list, auth_switch, login, logout
|
|
@@ -164,7 +163,7 @@ class AuthSwitchCommand(BaseUserCommand):
|
|
|
164
163
|
except ValueError:
|
|
165
164
|
print("Invalid input. Please enter a number or 'q' to quit.")
|
|
166
165
|
|
|
167
|
-
def _select_token_name_tui(self, token_names:
|
|
166
|
+
def _select_token_name_tui(self, token_names: list[str]) -> Optional[str]:
|
|
168
167
|
choices = [Choice(token_name, name=token_name) for token_name in token_names]
|
|
169
168
|
try:
|
|
170
169
|
return inquirer.select(
|
|
@@ -202,7 +201,7 @@ class WhoamiCommand(BaseUserCommand):
|
|
|
202
201
|
|
|
203
202
|
if ENDPOINT != "https://huggingface.co":
|
|
204
203
|
print(f"Authenticated through private endpoint: {ENDPOINT}")
|
|
205
|
-
except
|
|
204
|
+
except HfHubHTTPError as e:
|
|
206
205
|
print(e)
|
|
207
206
|
print(ANSI.red(e.response.text))
|
|
208
207
|
exit(1)
|
huggingface_hub/community.py
CHANGED
|
@@ -7,7 +7,7 @@ for more information on Pull Requests, Discussions, and the community tab.
|
|
|
7
7
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
from datetime import datetime
|
|
10
|
-
from typing import
|
|
10
|
+
from typing import Literal, Optional, Union
|
|
11
11
|
|
|
12
12
|
from . import constants
|
|
13
13
|
from .utils import parse_datetime
|
|
@@ -116,7 +116,7 @@ class DiscussionWithDetails(Discussion):
|
|
|
116
116
|
The `datetime` of creation of the Discussion / Pull Request.
|
|
117
117
|
events (`list` of [`DiscussionEvent`])
|
|
118
118
|
The list of [`DiscussionEvents`] in this Discussion or Pull Request.
|
|
119
|
-
conflicting_files (`Union[
|
|
119
|
+
conflicting_files (`Union[list[str], bool, None]`, *optional*):
|
|
120
120
|
A list of conflicting files if this is a Pull Request.
|
|
121
121
|
`None` if `self.is_pull_request` is `False`.
|
|
122
122
|
`True` if there are conflicting files but the list can't be retrieved.
|
|
@@ -136,8 +136,8 @@ class DiscussionWithDetails(Discussion):
|
|
|
136
136
|
(property) URL of the discussion on the Hub.
|
|
137
137
|
"""
|
|
138
138
|
|
|
139
|
-
events:
|
|
140
|
-
conflicting_files: Union[
|
|
139
|
+
events: list["DiscussionEvent"]
|
|
140
|
+
conflicting_files: Union[list[str], bool, None]
|
|
141
141
|
target_branch: Optional[str]
|
|
142
142
|
merge_commit_oid: Optional[str]
|
|
143
143
|
diff: Optional[str]
|
|
@@ -222,7 +222,7 @@ class DiscussionComment(DiscussionEvent):
|
|
|
222
222
|
return self._event["data"]["latest"].get("author", {}).get("name", "deleted")
|
|
223
223
|
|
|
224
224
|
@property
|
|
225
|
-
def edit_history(self) ->
|
|
225
|
+
def edit_history(self) -> list[dict]:
|
|
226
226
|
"""The edit history of the comment"""
|
|
227
227
|
return self._event["data"]["history"]
|
|
228
228
|
|
huggingface_hub/constants.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
import typing
|
|
4
|
-
from typing import Literal, Optional
|
|
4
|
+
from typing import Literal, Optional
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# Possible values for env variables
|
|
@@ -118,9 +118,9 @@ REPO_TYPES_MAPPING = {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
DiscussionTypeFilter = Literal["all", "discussion", "pull_request"]
|
|
121
|
-
DISCUSSION_TYPES:
|
|
121
|
+
DISCUSSION_TYPES: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionTypeFilter)
|
|
122
122
|
DiscussionStatusFilter = Literal["all", "open", "closed"]
|
|
123
|
-
DISCUSSION_STATUS:
|
|
123
|
+
DISCUSSION_STATUS: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter)
|
|
124
124
|
|
|
125
125
|
# Webhook subscription types
|
|
126
126
|
WEBHOOK_DOMAIN_T = Literal["repo", "discussions"]
|
|
@@ -135,7 +135,6 @@ HF_HOME = os.path.expandvars(
|
|
|
135
135
|
)
|
|
136
136
|
)
|
|
137
137
|
)
|
|
138
|
-
hf_cache_home = HF_HOME # for backward compatibility. TODO: remove this in 1.0.0
|
|
139
138
|
|
|
140
139
|
default_cache_path = os.path.join(HF_HOME, "hub")
|
|
141
140
|
default_assets_cache_path = os.path.join(HF_HOME, "assets")
|
|
@@ -234,43 +233,6 @@ HF_HUB_DOWNLOAD_TIMEOUT: int = _as_int(os.environ.get("HF_HUB_DOWNLOAD_TIMEOUT")
|
|
|
234
233
|
# Allows to add information about the requester in the user-agent (eg. partner name)
|
|
235
234
|
HF_HUB_USER_AGENT_ORIGIN: Optional[str] = os.environ.get("HF_HUB_USER_AGENT_ORIGIN")
|
|
236
235
|
|
|
237
|
-
# List frameworks that are handled by the InferenceAPI service. Useful to scan endpoints and check which models are
|
|
238
|
-
# deployed and running. Since 95% of the models are using the top 4 frameworks listed below, we scan only those by
|
|
239
|
-
# default. We still keep the full list of supported frameworks in case we want to scan all of them.
|
|
240
|
-
MAIN_INFERENCE_API_FRAMEWORKS = [
|
|
241
|
-
"diffusers",
|
|
242
|
-
"sentence-transformers",
|
|
243
|
-
"text-generation-inference",
|
|
244
|
-
"transformers",
|
|
245
|
-
]
|
|
246
|
-
|
|
247
|
-
ALL_INFERENCE_API_FRAMEWORKS = MAIN_INFERENCE_API_FRAMEWORKS + [
|
|
248
|
-
"adapter-transformers",
|
|
249
|
-
"allennlp",
|
|
250
|
-
"asteroid",
|
|
251
|
-
"bertopic",
|
|
252
|
-
"doctr",
|
|
253
|
-
"espnet",
|
|
254
|
-
"fairseq",
|
|
255
|
-
"fastai",
|
|
256
|
-
"fasttext",
|
|
257
|
-
"flair",
|
|
258
|
-
"k2",
|
|
259
|
-
"keras",
|
|
260
|
-
"mindspore",
|
|
261
|
-
"nemo",
|
|
262
|
-
"open_clip",
|
|
263
|
-
"paddlenlp",
|
|
264
|
-
"peft",
|
|
265
|
-
"pyannote-audio",
|
|
266
|
-
"sklearn",
|
|
267
|
-
"spacy",
|
|
268
|
-
"span-marker",
|
|
269
|
-
"speechbrain",
|
|
270
|
-
"stanza",
|
|
271
|
-
"timm",
|
|
272
|
-
]
|
|
273
|
-
|
|
274
236
|
# If OAuth didn't work after 2 redirects, there's likely a third-party cookie issue in the Space iframe view.
|
|
275
237
|
# In this case, we redirect the user to the non-iframe view.
|
|
276
238
|
OAUTH_MAX_REDIRECTS = 2
|