huggingface-hub 1.0.0rc0__py3-none-any.whl → 1.0.0rc2__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 +4 -4
- huggingface_hub/_commit_api.py +126 -66
- huggingface_hub/_commit_scheduler.py +4 -7
- huggingface_hub/_login.py +9 -15
- huggingface_hub/_tensorboard_logger.py +2 -5
- huggingface_hub/_webhooks_server.py +8 -20
- huggingface_hub/cli/__init__.py +0 -14
- huggingface_hub/cli/_cli_utils.py +79 -2
- huggingface_hub/cli/auth.py +104 -149
- huggingface_hub/cli/cache.py +97 -121
- huggingface_hub/cli/download.py +93 -110
- huggingface_hub/cli/hf.py +37 -41
- huggingface_hub/cli/jobs.py +687 -1014
- huggingface_hub/cli/lfs.py +116 -139
- huggingface_hub/cli/repo.py +290 -214
- 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/dataclasses.py +3 -12
- huggingface_hub/errors.py +1 -1
- huggingface_hub/fastai_utils.py +22 -32
- huggingface_hub/file_download.py +18 -21
- huggingface_hub/hf_api.py +258 -410
- huggingface_hub/hf_file_system.py +17 -44
- huggingface_hub/inference/_client.py +25 -47
- huggingface_hub/inference/_generated/_async_client.py +25 -47
- huggingface_hub/inference/_mcp/agent.py +2 -5
- huggingface_hub/inference/_mcp/mcp_client.py +2 -5
- huggingface_hub/inference/_providers/__init__.py +11 -0
- huggingface_hub/inference/_providers/_common.py +1 -0
- huggingface_hub/inference/_providers/publicai.py +6 -0
- huggingface_hub/inference/_providers/scaleway.py +28 -0
- huggingface_hub/lfs.py +14 -8
- huggingface_hub/repocard.py +12 -16
- huggingface_hub/serialization/_base.py +3 -6
- huggingface_hub/serialization/_torch.py +16 -34
- huggingface_hub/utils/__init__.py +1 -1
- huggingface_hub/utils/_cache_manager.py +41 -71
- huggingface_hub/utils/_chunk_utils.py +2 -3
- huggingface_hub/utils/_http.py +32 -35
- huggingface_hub/utils/logging.py +8 -11
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/METADATA +7 -2
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/RECORD +48 -46
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/LICENSE +0 -0
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/WHEEL +0 -0
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-1.0.0rc0.dist-info → huggingface_hub-1.0.0rc2.dist-info}/top_level.txt +0 -0
huggingface_hub/cli/download.py
CHANGED
|
@@ -37,145 +37,128 @@ Usage:
|
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
import warnings
|
|
40
|
-
from
|
|
41
|
-
|
|
40
|
+
from typing import Annotated, Optional
|
|
41
|
+
|
|
42
|
+
import typer
|
|
42
43
|
|
|
43
44
|
from huggingface_hub import logging
|
|
44
45
|
from huggingface_hub._snapshot_download import snapshot_download
|
|
45
|
-
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
|
46
46
|
from huggingface_hub.file_download import hf_hub_download
|
|
47
47
|
from huggingface_hub.utils import disable_progress_bars, enable_progress_bars
|
|
48
48
|
|
|
49
|
+
from ._cli_utils import RepoIdArg, RepoTypeOpt, RevisionOpt, TokenOpt
|
|
50
|
+
|
|
49
51
|
|
|
50
52
|
logger = logging.get_logger(__name__)
|
|
51
53
|
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
help="
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
),
|
|
91
|
-
)
|
|
92
|
-
download_parser.add_argument(
|
|
93
|
-
"--force-download",
|
|
94
|
-
action="store_true",
|
|
55
|
+
def download(
|
|
56
|
+
repo_id: RepoIdArg,
|
|
57
|
+
filenames: Annotated[
|
|
58
|
+
Optional[list[str]],
|
|
59
|
+
typer.Argument(
|
|
60
|
+
help="Files to download (e.g. `config.json`, `data/metadata.jsonl`).",
|
|
61
|
+
),
|
|
62
|
+
] = None,
|
|
63
|
+
repo_type: RepoTypeOpt = RepoTypeOpt.model,
|
|
64
|
+
revision: RevisionOpt = None,
|
|
65
|
+
include: Annotated[
|
|
66
|
+
Optional[list[str]],
|
|
67
|
+
typer.Option(
|
|
68
|
+
help="Glob patterns to include from files to download. eg: *.json",
|
|
69
|
+
),
|
|
70
|
+
] = None,
|
|
71
|
+
exclude: Annotated[
|
|
72
|
+
Optional[list[str]],
|
|
73
|
+
typer.Option(
|
|
74
|
+
help="Glob patterns to exclude from files to download.",
|
|
75
|
+
),
|
|
76
|
+
] = None,
|
|
77
|
+
cache_dir: Annotated[
|
|
78
|
+
Optional[str],
|
|
79
|
+
typer.Option(
|
|
80
|
+
help="Directory where to save files.",
|
|
81
|
+
),
|
|
82
|
+
] = None,
|
|
83
|
+
local_dir: Annotated[
|
|
84
|
+
Optional[str],
|
|
85
|
+
typer.Option(
|
|
86
|
+
help="If set, the downloaded file will be placed under this directory. Check out https://huggingface.co/docs/huggingface_hub/guides/download#download-files-to-local-folder for more details.",
|
|
87
|
+
),
|
|
88
|
+
] = None,
|
|
89
|
+
force_download: Annotated[
|
|
90
|
+
bool,
|
|
91
|
+
typer.Option(
|
|
95
92
|
help="If True, the files will be downloaded even if they are already cached.",
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
action="store_true",
|
|
93
|
+
),
|
|
94
|
+
] = False,
|
|
95
|
+
token: TokenOpt = None,
|
|
96
|
+
quiet: Annotated[
|
|
97
|
+
bool,
|
|
98
|
+
typer.Option(
|
|
103
99
|
help="If True, progress bars are disabled and only the path to the download files is printed.",
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
),
|
|
101
|
+
] = False,
|
|
102
|
+
max_workers: Annotated[
|
|
103
|
+
int,
|
|
104
|
+
typer.Option(
|
|
109
105
|
help="Maximum number of workers to use for downloading files. Default is 8.",
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
self.token = args.token
|
|
115
|
-
self.repo_id: str = args.repo_id
|
|
116
|
-
self.filenames: list[str] = args.filenames
|
|
117
|
-
self.repo_type: str = args.repo_type
|
|
118
|
-
self.revision: Optional[str] = args.revision
|
|
119
|
-
self.include: Optional[list[str]] = args.include
|
|
120
|
-
self.exclude: Optional[list[str]] = args.exclude
|
|
121
|
-
self.cache_dir: Optional[str] = args.cache_dir
|
|
122
|
-
self.local_dir: Optional[str] = args.local_dir
|
|
123
|
-
self.force_download: bool = args.force_download
|
|
124
|
-
self.quiet: bool = args.quiet
|
|
125
|
-
self.max_workers: int = args.max_workers
|
|
126
|
-
|
|
127
|
-
def run(self) -> None:
|
|
128
|
-
if self.quiet:
|
|
129
|
-
disable_progress_bars()
|
|
130
|
-
with warnings.catch_warnings():
|
|
131
|
-
warnings.simplefilter("ignore")
|
|
132
|
-
print(self._download()) # Print path to downloaded files
|
|
133
|
-
enable_progress_bars()
|
|
134
|
-
else:
|
|
135
|
-
logging.set_verbosity_info()
|
|
136
|
-
print(self._download()) # Print path to downloaded files
|
|
137
|
-
logging.set_verbosity_warning()
|
|
106
|
+
),
|
|
107
|
+
] = 8,
|
|
108
|
+
) -> None:
|
|
109
|
+
"""Download files from the Hub."""
|
|
138
110
|
|
|
139
|
-
def
|
|
111
|
+
def run_download() -> str:
|
|
112
|
+
filenames_list = filenames if filenames is not None else []
|
|
140
113
|
# Warn user if patterns are ignored
|
|
141
|
-
if len(
|
|
142
|
-
if
|
|
114
|
+
if len(filenames_list) > 0:
|
|
115
|
+
if include is not None and len(include) > 0:
|
|
143
116
|
warnings.warn("Ignoring `--include` since filenames have being explicitly set.")
|
|
144
|
-
if
|
|
117
|
+
if exclude is not None and len(exclude) > 0:
|
|
145
118
|
warnings.warn("Ignoring `--exclude` since filenames have being explicitly set.")
|
|
146
119
|
|
|
147
120
|
# Single file to download: use `hf_hub_download`
|
|
148
|
-
if len(
|
|
121
|
+
if len(filenames_list) == 1:
|
|
149
122
|
return hf_hub_download(
|
|
150
|
-
repo_id=
|
|
151
|
-
repo_type=
|
|
152
|
-
revision=
|
|
153
|
-
filename=
|
|
154
|
-
cache_dir=
|
|
155
|
-
force_download=
|
|
156
|
-
token=
|
|
157
|
-
local_dir=
|
|
123
|
+
repo_id=repo_id,
|
|
124
|
+
repo_type=repo_type.value,
|
|
125
|
+
revision=revision,
|
|
126
|
+
filename=filenames_list[0],
|
|
127
|
+
cache_dir=cache_dir,
|
|
128
|
+
force_download=force_download,
|
|
129
|
+
token=token,
|
|
130
|
+
local_dir=local_dir,
|
|
158
131
|
library_name="hf",
|
|
159
132
|
)
|
|
160
133
|
|
|
161
134
|
# Otherwise: use `snapshot_download` to ensure all files comes from same revision
|
|
162
|
-
|
|
163
|
-
allow_patterns =
|
|
164
|
-
ignore_patterns =
|
|
135
|
+
if len(filenames_list) == 0:
|
|
136
|
+
allow_patterns = include
|
|
137
|
+
ignore_patterns = exclude
|
|
165
138
|
else:
|
|
166
|
-
allow_patterns =
|
|
139
|
+
allow_patterns = filenames_list
|
|
167
140
|
ignore_patterns = None
|
|
168
141
|
|
|
169
142
|
return snapshot_download(
|
|
170
|
-
repo_id=
|
|
171
|
-
repo_type=
|
|
172
|
-
revision=
|
|
143
|
+
repo_id=repo_id,
|
|
144
|
+
repo_type=repo_type.value,
|
|
145
|
+
revision=revision,
|
|
173
146
|
allow_patterns=allow_patterns,
|
|
174
147
|
ignore_patterns=ignore_patterns,
|
|
175
|
-
force_download=
|
|
176
|
-
cache_dir=
|
|
177
|
-
token=
|
|
178
|
-
local_dir=
|
|
148
|
+
force_download=force_download,
|
|
149
|
+
cache_dir=cache_dir,
|
|
150
|
+
token=token,
|
|
151
|
+
local_dir=local_dir,
|
|
179
152
|
library_name="hf",
|
|
180
|
-
max_workers=
|
|
153
|
+
max_workers=max_workers,
|
|
181
154
|
)
|
|
155
|
+
|
|
156
|
+
if quiet:
|
|
157
|
+
disable_progress_bars()
|
|
158
|
+
with warnings.catch_warnings():
|
|
159
|
+
warnings.simplefilter("ignore")
|
|
160
|
+
print(run_download())
|
|
161
|
+
enable_progress_bars()
|
|
162
|
+
else:
|
|
163
|
+
print(run_download())
|
|
164
|
+
logging.set_verbosity_warning()
|
huggingface_hub/cli/hf.py
CHANGED
|
@@ -12,51 +12,47 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from argparse import ArgumentParser
|
|
16
15
|
|
|
17
|
-
from huggingface_hub.cli.
|
|
18
|
-
from huggingface_hub.cli.
|
|
19
|
-
from huggingface_hub.cli.
|
|
20
|
-
from huggingface_hub.cli.
|
|
21
|
-
from huggingface_hub.cli.
|
|
22
|
-
from huggingface_hub.cli.
|
|
23
|
-
from huggingface_hub.cli.
|
|
24
|
-
from huggingface_hub.cli.
|
|
25
|
-
from huggingface_hub.cli.
|
|
26
|
-
|
|
16
|
+
from huggingface_hub.cli._cli_utils import typer_factory
|
|
17
|
+
from huggingface_hub.cli.auth import auth_cli
|
|
18
|
+
from huggingface_hub.cli.cache import cache_cli
|
|
19
|
+
from huggingface_hub.cli.download import download
|
|
20
|
+
from huggingface_hub.cli.jobs import jobs_cli
|
|
21
|
+
from huggingface_hub.cli.lfs import lfs_enable_largefiles, lfs_multipart_upload
|
|
22
|
+
from huggingface_hub.cli.repo import repo_cli
|
|
23
|
+
from huggingface_hub.cli.repo_files import repo_files_cli
|
|
24
|
+
from huggingface_hub.cli.system import env, version
|
|
25
|
+
|
|
26
|
+
# from huggingface_hub.cli.jobs import jobs_app
|
|
27
|
+
from huggingface_hub.cli.upload import upload
|
|
28
|
+
from huggingface_hub.cli.upload_large_folder import upload_large_folder
|
|
29
|
+
from huggingface_hub.utils import logging
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
app = typer_factory(help="Hugging Face Hub CLI")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# top level single commands (defined in their respective files)
|
|
36
|
+
app.command(help="Download files from the Hub.")(download)
|
|
37
|
+
app.command(help="Upload a file or a folder to the Hub.")(upload)
|
|
38
|
+
app.command(help="Upload a large folder to the Hub. Recommended for resumable uploads.")(upload_large_folder)
|
|
39
|
+
app.command(name="env", help="Print information about the environment.")(env)
|
|
40
|
+
app.command(help="Print information about the hf version.")(version)
|
|
41
|
+
app.command(help="Configure your repository to enable upload of files > 5GB.", hidden=True)(lfs_enable_largefiles)
|
|
42
|
+
app.command(help="Upload large files to the Hub.", hidden=True)(lfs_multipart_upload)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# command groups
|
|
46
|
+
app.add_typer(auth_cli, name="auth")
|
|
47
|
+
app.add_typer(cache_cli, name="cache")
|
|
48
|
+
app.add_typer(repo_cli, name="repo")
|
|
49
|
+
app.add_typer(repo_files_cli, name="repo-files")
|
|
50
|
+
app.add_typer(jobs_cli, name="jobs")
|
|
27
51
|
|
|
28
52
|
|
|
29
53
|
def main():
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# Register commands
|
|
34
|
-
AuthCommands.register_subcommand(commands_parser)
|
|
35
|
-
CacheCommand.register_subcommand(commands_parser)
|
|
36
|
-
DownloadCommand.register_subcommand(commands_parser)
|
|
37
|
-
JobsCommands.register_subcommand(commands_parser)
|
|
38
|
-
RepoCommands.register_subcommand(commands_parser)
|
|
39
|
-
RepoFilesCommand.register_subcommand(commands_parser)
|
|
40
|
-
UploadCommand.register_subcommand(commands_parser)
|
|
41
|
-
UploadLargeFolderCommand.register_subcommand(commands_parser)
|
|
42
|
-
|
|
43
|
-
# System commands
|
|
44
|
-
EnvironmentCommand.register_subcommand(commands_parser)
|
|
45
|
-
VersionCommand.register_subcommand(commands_parser)
|
|
46
|
-
|
|
47
|
-
# LFS commands (hidden in --help)
|
|
48
|
-
LfsCommands.register_subcommand(commands_parser)
|
|
49
|
-
|
|
50
|
-
# Let's go
|
|
51
|
-
args = parser.parse_args()
|
|
52
|
-
if not hasattr(args, "func"):
|
|
53
|
-
parser.print_help()
|
|
54
|
-
exit(1)
|
|
55
|
-
|
|
56
|
-
# Run
|
|
57
|
-
service = args.func(args)
|
|
58
|
-
if service is not None:
|
|
59
|
-
service.run()
|
|
54
|
+
logging.set_verbosity_info()
|
|
55
|
+
app()
|
|
60
56
|
|
|
61
57
|
|
|
62
58
|
if __name__ == "__main__":
|