huggingface-hub 0.24.6__tar.gz → 0.25.0__tar.gz
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-0.24.6 → huggingface_hub-0.25.0}/PKG-INFO +2 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/README.md +1 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/__init__.py +21 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_commit_api.py +4 -4
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_inference_endpoints.py +13 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_local_folder.py +191 -4
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_login.py +6 -6
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_snapshot_download.py +8 -17
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_space_api.py +5 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_tensorboard_logger.py +29 -13
- huggingface_hub-0.25.0/src/huggingface_hub/_upload_large_folder.py +621 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_webhooks_server.py +1 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/_cli_utils.py +5 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/download.py +8 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/huggingface_cli.py +6 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/lfs.py +2 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/repo_files.py +2 -2
- huggingface_hub-0.25.0/src/huggingface_hub/commands/scan_cache.py +181 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/tag.py +1 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/upload.py +2 -1
- huggingface_hub-0.25.0/src/huggingface_hub/commands/upload_large_folder.py +129 -0
- huggingface_hub-0.25.0/src/huggingface_hub/commands/version.py +37 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/community.py +2 -2
- huggingface_hub-0.25.0/src/huggingface_hub/errors.py +313 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/fastai_utils.py +2 -3
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/file_download.py +63 -63
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/hf_api.py +783 -314
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/hf_file_system.py +15 -23
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/hub_mixin.py +27 -25
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_client.py +78 -127
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/_async_client.py +169 -144
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/base.py +0 -9
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_templating.py +2 -3
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference_api.py +2 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/keras_mixin.py +2 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/lfs.py +7 -98
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/repocard.py +6 -5
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/repository.py +5 -5
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/serialization/_torch.py +64 -11
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/__init__.py +13 -14
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_cache_manager.py +97 -14
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_fixes.py +18 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_http.py +228 -2
- huggingface_hub-0.25.0/src/huggingface_hub/utils/_lfs.py +110 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_runtime.py +7 -1
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_token.py +3 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/PKG-INFO +2 -2
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/SOURCES.txt +4 -2
- huggingface_hub-0.24.6/src/huggingface_hub/commands/scan_cache.py +0 -139
- huggingface_hub-0.24.6/src/huggingface_hub/errors.py +0 -96
- huggingface_hub-0.24.6/src/huggingface_hub/inference/_types.py +0 -52
- huggingface_hub-0.24.6/src/huggingface_hub/utils/_errors.py +0 -397
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/LICENSE +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/MANIFEST.in +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/pyproject.toml +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/setup.cfg +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/setup.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_commit_scheduler.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_multi_commits.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_webhooks_payload.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/__init__.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/delete_cache.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/env.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/commands/user.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/constants.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/__init__.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_common.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/image_to_image.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/repocard_data.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/serialization/__init__.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/serialization/_base.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/serialization/_tensorflow.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/templates/modelcard_template.md +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_cache_assets.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_datetime.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_deprecation.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_experimental.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_git_credential.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_headers.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_hf_folder.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_pagination.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_paths.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_safetensors.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_subprocess.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_telemetry.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_typing.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/_validators.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/logging.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/sha.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/utils/tqdm.py +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/requires.txt +0 -0
- {huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface_hub
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.25.0
|
|
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.
|
|
@@ -128,7 +128,7 @@ Files will be downloaded in a local cache folder. More details in [this guide](h
|
|
|
128
128
|
|
|
129
129
|
### Login
|
|
130
130
|
|
|
131
|
-
The Hugging Face Hub uses tokens to authenticate applications (see [docs](https://huggingface.co/docs/hub/security-tokens)). To
|
|
131
|
+
The Hugging Face Hub uses tokens to authenticate applications (see [docs](https://huggingface.co/docs/hub/security-tokens)). To log in your machine, run the following CLI:
|
|
132
132
|
|
|
133
133
|
```bash
|
|
134
134
|
huggingface-cli login
|
|
@@ -90,7 +90,7 @@ Files will be downloaded in a local cache folder. More details in [this guide](h
|
|
|
90
90
|
|
|
91
91
|
### Login
|
|
92
92
|
|
|
93
|
-
The Hugging Face Hub uses tokens to authenticate applications (see [docs](https://huggingface.co/docs/hub/security-tokens)). To
|
|
93
|
+
The Hugging Face Hub uses tokens to authenticate applications (see [docs](https://huggingface.co/docs/hub/security-tokens)). To log in your machine, run the following CLI:
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
96
|
huggingface-cli login
|
|
@@ -46,7 +46,7 @@ import sys
|
|
|
46
46
|
from typing import TYPE_CHECKING
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
__version__ = "0.
|
|
49
|
+
__version__ = "0.25.0"
|
|
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
|
|
@@ -143,11 +143,14 @@ _SUBMOD_ATTRS = {
|
|
|
143
143
|
"CommitOperationAdd",
|
|
144
144
|
"CommitOperationCopy",
|
|
145
145
|
"CommitOperationDelete",
|
|
146
|
+
"DatasetInfo",
|
|
146
147
|
"GitCommitInfo",
|
|
147
148
|
"GitRefInfo",
|
|
148
149
|
"GitRefs",
|
|
149
150
|
"HfApi",
|
|
151
|
+
"ModelInfo",
|
|
150
152
|
"RepoUrl",
|
|
153
|
+
"SpaceInfo",
|
|
151
154
|
"User",
|
|
152
155
|
"UserLikes",
|
|
153
156
|
"WebhookInfo",
|
|
@@ -156,6 +159,7 @@ _SUBMOD_ATTRS = {
|
|
|
156
159
|
"add_collection_item",
|
|
157
160
|
"add_space_secret",
|
|
158
161
|
"add_space_variable",
|
|
162
|
+
"auth_check",
|
|
159
163
|
"cancel_access_request",
|
|
160
164
|
"change_discussion_status",
|
|
161
165
|
"comment_discussion",
|
|
@@ -199,6 +203,7 @@ _SUBMOD_ATTRS = {
|
|
|
199
203
|
"get_space_runtime",
|
|
200
204
|
"get_space_variables",
|
|
201
205
|
"get_token_permission",
|
|
206
|
+
"get_user_overview",
|
|
202
207
|
"get_webhook",
|
|
203
208
|
"grant_access",
|
|
204
209
|
"like",
|
|
@@ -209,6 +214,7 @@ _SUBMOD_ATTRS = {
|
|
|
209
214
|
"list_liked_repos",
|
|
210
215
|
"list_metrics",
|
|
211
216
|
"list_models",
|
|
217
|
+
"list_organization_members",
|
|
212
218
|
"list_pending_access_requests",
|
|
213
219
|
"list_rejected_access_requests",
|
|
214
220
|
"list_repo_commits",
|
|
@@ -217,6 +223,8 @@ _SUBMOD_ATTRS = {
|
|
|
217
223
|
"list_repo_refs",
|
|
218
224
|
"list_repo_tree",
|
|
219
225
|
"list_spaces",
|
|
226
|
+
"list_user_followers",
|
|
227
|
+
"list_user_following",
|
|
220
228
|
"list_webhooks",
|
|
221
229
|
"merge_pull_request",
|
|
222
230
|
"model_info",
|
|
@@ -244,10 +252,12 @@ _SUBMOD_ATTRS = {
|
|
|
244
252
|
"update_collection_item",
|
|
245
253
|
"update_collection_metadata",
|
|
246
254
|
"update_inference_endpoint",
|
|
255
|
+
"update_repo_settings",
|
|
247
256
|
"update_repo_visibility",
|
|
248
257
|
"update_webhook",
|
|
249
258
|
"upload_file",
|
|
250
259
|
"upload_folder",
|
|
260
|
+
"upload_large_folder",
|
|
251
261
|
"whoami",
|
|
252
262
|
],
|
|
253
263
|
"hf_file_system": [
|
|
@@ -643,11 +653,14 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
643
653
|
CommitOperationAdd, # noqa: F401
|
|
644
654
|
CommitOperationCopy, # noqa: F401
|
|
645
655
|
CommitOperationDelete, # noqa: F401
|
|
656
|
+
DatasetInfo, # noqa: F401
|
|
646
657
|
GitCommitInfo, # noqa: F401
|
|
647
658
|
GitRefInfo, # noqa: F401
|
|
648
659
|
GitRefs, # noqa: F401
|
|
649
660
|
HfApi, # noqa: F401
|
|
661
|
+
ModelInfo, # noqa: F401
|
|
650
662
|
RepoUrl, # noqa: F401
|
|
663
|
+
SpaceInfo, # noqa: F401
|
|
651
664
|
User, # noqa: F401
|
|
652
665
|
UserLikes, # noqa: F401
|
|
653
666
|
WebhookInfo, # noqa: F401
|
|
@@ -656,6 +669,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
656
669
|
add_collection_item, # noqa: F401
|
|
657
670
|
add_space_secret, # noqa: F401
|
|
658
671
|
add_space_variable, # noqa: F401
|
|
672
|
+
auth_check, # noqa: F401
|
|
659
673
|
cancel_access_request, # noqa: F401
|
|
660
674
|
change_discussion_status, # noqa: F401
|
|
661
675
|
comment_discussion, # noqa: F401
|
|
@@ -699,6 +713,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
699
713
|
get_space_runtime, # noqa: F401
|
|
700
714
|
get_space_variables, # noqa: F401
|
|
701
715
|
get_token_permission, # noqa: F401
|
|
716
|
+
get_user_overview, # noqa: F401
|
|
702
717
|
get_webhook, # noqa: F401
|
|
703
718
|
grant_access, # noqa: F401
|
|
704
719
|
like, # noqa: F401
|
|
@@ -709,6 +724,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
709
724
|
list_liked_repos, # noqa: F401
|
|
710
725
|
list_metrics, # noqa: F401
|
|
711
726
|
list_models, # noqa: F401
|
|
727
|
+
list_organization_members, # noqa: F401
|
|
712
728
|
list_pending_access_requests, # noqa: F401
|
|
713
729
|
list_rejected_access_requests, # noqa: F401
|
|
714
730
|
list_repo_commits, # noqa: F401
|
|
@@ -717,6 +733,8 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
717
733
|
list_repo_refs, # noqa: F401
|
|
718
734
|
list_repo_tree, # noqa: F401
|
|
719
735
|
list_spaces, # noqa: F401
|
|
736
|
+
list_user_followers, # noqa: F401
|
|
737
|
+
list_user_following, # noqa: F401
|
|
720
738
|
list_webhooks, # noqa: F401
|
|
721
739
|
merge_pull_request, # noqa: F401
|
|
722
740
|
model_info, # noqa: F401
|
|
@@ -744,10 +762,12 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
744
762
|
update_collection_item, # noqa: F401
|
|
745
763
|
update_collection_metadata, # noqa: F401
|
|
746
764
|
update_inference_endpoint, # noqa: F401
|
|
765
|
+
update_repo_settings, # noqa: F401
|
|
747
766
|
update_repo_visibility, # noqa: F401
|
|
748
767
|
update_webhook, # noqa: F401
|
|
749
768
|
upload_file, # noqa: F401
|
|
750
769
|
upload_folder, # noqa: F401
|
|
770
|
+
upload_large_folder, # noqa: F401
|
|
751
771
|
whoami, # noqa: F401
|
|
752
772
|
)
|
|
753
773
|
from .hf_file_system import (
|
|
@@ -15,12 +15,12 @@ from typing import TYPE_CHECKING, Any, BinaryIO, Dict, Iterable, Iterator, List,
|
|
|
15
15
|
|
|
16
16
|
from tqdm.contrib.concurrent import thread_map
|
|
17
17
|
|
|
18
|
-
from .
|
|
18
|
+
from . import constants
|
|
19
|
+
from .errors import EntryNotFoundError
|
|
19
20
|
from .file_download import hf_hub_url
|
|
20
21
|
from .lfs import UploadInfo, lfs_upload, post_lfs_batch_info
|
|
21
22
|
from .utils import (
|
|
22
23
|
FORBIDDEN_FOLDERS,
|
|
23
|
-
EntryNotFoundError,
|
|
24
24
|
chunk_iterable,
|
|
25
25
|
get_session,
|
|
26
26
|
hf_raise_for_status,
|
|
@@ -432,7 +432,7 @@ def _upload_lfs_files(
|
|
|
432
432
|
except Exception as exc:
|
|
433
433
|
raise RuntimeError(f"Error while uploading '{operation.path_in_repo}' to the Hub.") from exc
|
|
434
434
|
|
|
435
|
-
if HF_HUB_ENABLE_HF_TRANSFER:
|
|
435
|
+
if constants.HF_HUB_ENABLE_HF_TRANSFER:
|
|
436
436
|
logger.debug(f"Uploading {len(filtered_actions)} LFS files to the Hub using `hf_transfer`.")
|
|
437
437
|
for action in hf_tqdm(filtered_actions, name="huggingface_hub.lfs_upload"):
|
|
438
438
|
_wrapped_lfs_upload(action)
|
|
@@ -506,7 +506,7 @@ def _fetch_upload_modes(
|
|
|
506
506
|
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
507
507
|
If the Hub API response is improperly formatted.
|
|
508
508
|
"""
|
|
509
|
-
endpoint = endpoint if endpoint is not None else ENDPOINT
|
|
509
|
+
endpoint = endpoint if endpoint is not None else constants.ENDPOINT
|
|
510
510
|
|
|
511
511
|
# Fetch upload mode (LFS or regular) chunk by chunk.
|
|
512
512
|
upload_modes: Dict[str, UploadMode] = {}
|
{huggingface_hub-0.24.6 → huggingface_hub-0.25.0}/src/huggingface_hub/_inference_endpoints.py
RENAMED
|
@@ -238,11 +238,14 @@ class InferenceEndpoint:
|
|
|
238
238
|
instance_type: Optional[str] = None,
|
|
239
239
|
min_replica: Optional[int] = None,
|
|
240
240
|
max_replica: Optional[int] = None,
|
|
241
|
+
scale_to_zero_timeout: Optional[int] = None,
|
|
241
242
|
# Model update
|
|
242
243
|
repository: Optional[str] = None,
|
|
243
244
|
framework: Optional[str] = None,
|
|
244
245
|
revision: Optional[str] = None,
|
|
245
246
|
task: Optional[str] = None,
|
|
247
|
+
custom_image: Optional[Dict] = None,
|
|
248
|
+
secrets: Optional[Dict[str, str]] = None,
|
|
246
249
|
) -> "InferenceEndpoint":
|
|
247
250
|
"""Update the Inference Endpoint.
|
|
248
251
|
|
|
@@ -263,6 +266,8 @@ class InferenceEndpoint:
|
|
|
263
266
|
The minimum number of replicas (instances) to keep running for the Inference Endpoint.
|
|
264
267
|
max_replica (`int`, *optional*):
|
|
265
268
|
The maximum number of replicas (instances) to scale to for the Inference Endpoint.
|
|
269
|
+
scale_to_zero_timeout (`int`, *optional*):
|
|
270
|
+
The duration in minutes before an inactive endpoint is scaled to zero.
|
|
266
271
|
|
|
267
272
|
repository (`str`, *optional*):
|
|
268
273
|
The name of the model repository associated with the Inference Endpoint (e.g. `"gpt2"`).
|
|
@@ -272,7 +277,11 @@ class InferenceEndpoint:
|
|
|
272
277
|
The specific model revision to deploy on the Inference Endpoint (e.g. `"6c0e6080953db56375760c0471a8c5f2929baf11"`).
|
|
273
278
|
task (`str`, *optional*):
|
|
274
279
|
The task on which to deploy the model (e.g. `"text-classification"`).
|
|
275
|
-
|
|
280
|
+
custom_image (`Dict`, *optional*):
|
|
281
|
+
A custom Docker image to use for the Inference Endpoint. This is useful if you want to deploy an
|
|
282
|
+
Inference Endpoint running on the `text-generation-inference` (TGI) framework (see examples).
|
|
283
|
+
secrets (`Dict[str, str]`, *optional*):
|
|
284
|
+
Secret values to inject in the container environment.
|
|
276
285
|
Returns:
|
|
277
286
|
[`InferenceEndpoint`]: the same Inference Endpoint, mutated in place with the latest data.
|
|
278
287
|
"""
|
|
@@ -285,10 +294,13 @@ class InferenceEndpoint:
|
|
|
285
294
|
instance_type=instance_type,
|
|
286
295
|
min_replica=min_replica,
|
|
287
296
|
max_replica=max_replica,
|
|
297
|
+
scale_to_zero_timeout=scale_to_zero_timeout,
|
|
288
298
|
repository=repository,
|
|
289
299
|
framework=framework,
|
|
290
300
|
revision=revision,
|
|
291
301
|
task=task,
|
|
302
|
+
custom_image=custom_image,
|
|
303
|
+
secrets=secrets,
|
|
292
304
|
token=self._token, # type: ignore [arg-type]
|
|
293
305
|
)
|
|
294
306
|
|
|
@@ -34,7 +34,7 @@ using the cache).
|
|
|
34
34
|
└── [ 16] file.parquet
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Download metadata file structure:
|
|
38
38
|
```
|
|
39
39
|
# file.txt.metadata
|
|
40
40
|
11c5a3d5811f50298f278a704980280950aedb10
|
|
@@ -68,7 +68,7 @@ class LocalDownloadFilePaths:
|
|
|
68
68
|
"""
|
|
69
69
|
Paths to the files related to a download process in a local dir.
|
|
70
70
|
|
|
71
|
-
Returned by `get_local_download_paths
|
|
71
|
+
Returned by [`get_local_download_paths`].
|
|
72
72
|
|
|
73
73
|
Attributes:
|
|
74
74
|
file_path (`Path`):
|
|
@@ -88,6 +88,30 @@ class LocalDownloadFilePaths:
|
|
|
88
88
|
return self.metadata_path.with_suffix(f".{etag}.incomplete")
|
|
89
89
|
|
|
90
90
|
|
|
91
|
+
@dataclass(frozen=True)
|
|
92
|
+
class LocalUploadFilePaths:
|
|
93
|
+
"""
|
|
94
|
+
Paths to the files related to an upload process in a local dir.
|
|
95
|
+
|
|
96
|
+
Returned by [`get_local_upload_paths`].
|
|
97
|
+
|
|
98
|
+
Attributes:
|
|
99
|
+
path_in_repo (`str`):
|
|
100
|
+
Path of the file in the repo.
|
|
101
|
+
file_path (`Path`):
|
|
102
|
+
Path where the file will be saved.
|
|
103
|
+
lock_path (`Path`):
|
|
104
|
+
Path to the lock file used to ensure atomicity when reading/writing metadata.
|
|
105
|
+
metadata_path (`Path`):
|
|
106
|
+
Path to the metadata file.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
path_in_repo: str
|
|
110
|
+
file_path: Path
|
|
111
|
+
lock_path: Path
|
|
112
|
+
metadata_path: Path
|
|
113
|
+
|
|
114
|
+
|
|
91
115
|
@dataclass
|
|
92
116
|
class LocalDownloadFileMetadata:
|
|
93
117
|
"""
|
|
@@ -111,6 +135,50 @@ class LocalDownloadFileMetadata:
|
|
|
111
135
|
timestamp: float
|
|
112
136
|
|
|
113
137
|
|
|
138
|
+
@dataclass
|
|
139
|
+
class LocalUploadFileMetadata:
|
|
140
|
+
"""
|
|
141
|
+
Metadata about a file in the local directory related to an upload process.
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
size: int
|
|
145
|
+
|
|
146
|
+
# Default values correspond to "we don't know yet"
|
|
147
|
+
timestamp: Optional[float] = None
|
|
148
|
+
should_ignore: Optional[bool] = None
|
|
149
|
+
sha256: Optional[str] = None
|
|
150
|
+
upload_mode: Optional[str] = None
|
|
151
|
+
is_uploaded: bool = False
|
|
152
|
+
is_committed: bool = False
|
|
153
|
+
|
|
154
|
+
def save(self, paths: LocalUploadFilePaths) -> None:
|
|
155
|
+
"""Save the metadata to disk."""
|
|
156
|
+
with WeakFileLock(paths.lock_path):
|
|
157
|
+
with paths.metadata_path.open("w") as f:
|
|
158
|
+
new_timestamp = time.time()
|
|
159
|
+
f.write(str(new_timestamp) + "\n")
|
|
160
|
+
|
|
161
|
+
f.write(str(self.size)) # never None
|
|
162
|
+
f.write("\n")
|
|
163
|
+
|
|
164
|
+
if self.should_ignore is not None:
|
|
165
|
+
f.write(str(int(self.should_ignore)))
|
|
166
|
+
f.write("\n")
|
|
167
|
+
|
|
168
|
+
if self.sha256 is not None:
|
|
169
|
+
f.write(self.sha256)
|
|
170
|
+
f.write("\n")
|
|
171
|
+
|
|
172
|
+
if self.upload_mode is not None:
|
|
173
|
+
f.write(self.upload_mode)
|
|
174
|
+
f.write("\n")
|
|
175
|
+
|
|
176
|
+
f.write(str(int(self.is_uploaded)) + "\n")
|
|
177
|
+
f.write(str(int(self.is_committed)) + "\n")
|
|
178
|
+
|
|
179
|
+
self.timestamp = new_timestamp
|
|
180
|
+
|
|
181
|
+
|
|
114
182
|
@lru_cache(maxsize=128) # ensure singleton
|
|
115
183
|
def get_local_download_paths(local_dir: Path, filename: str) -> LocalDownloadFilePaths:
|
|
116
184
|
"""Compute paths to the files related to a download process.
|
|
@@ -152,6 +220,49 @@ def get_local_download_paths(local_dir: Path, filename: str) -> LocalDownloadFil
|
|
|
152
220
|
return LocalDownloadFilePaths(file_path=file_path, lock_path=lock_path, metadata_path=metadata_path)
|
|
153
221
|
|
|
154
222
|
|
|
223
|
+
@lru_cache(maxsize=128) # ensure singleton
|
|
224
|
+
def get_local_upload_paths(local_dir: Path, filename: str) -> LocalUploadFilePaths:
|
|
225
|
+
"""Compute paths to the files related to an upload process.
|
|
226
|
+
|
|
227
|
+
Folders containing the paths are all guaranteed to exist.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
local_dir (`Path`):
|
|
231
|
+
Path to the local directory that is uploaded.
|
|
232
|
+
filename (`str`):
|
|
233
|
+
Path of the file in the repo.
|
|
234
|
+
|
|
235
|
+
Return:
|
|
236
|
+
[`LocalUploadFilePaths`]: the paths to the files (file_path, lock_path, metadata_path).
|
|
237
|
+
"""
|
|
238
|
+
# filename is the path in the Hub repository (separated by '/')
|
|
239
|
+
# make sure to have a cross platform transcription
|
|
240
|
+
sanitized_filename = os.path.join(*filename.split("/"))
|
|
241
|
+
if os.name == "nt":
|
|
242
|
+
if sanitized_filename.startswith("..\\") or "\\..\\" in sanitized_filename:
|
|
243
|
+
raise ValueError(
|
|
244
|
+
f"Invalid filename: cannot handle filename '{sanitized_filename}' on Windows. Please ask the repository"
|
|
245
|
+
" owner to rename this file."
|
|
246
|
+
)
|
|
247
|
+
file_path = local_dir / sanitized_filename
|
|
248
|
+
metadata_path = _huggingface_dir(local_dir) / "upload" / f"{sanitized_filename}.metadata"
|
|
249
|
+
lock_path = metadata_path.with_suffix(".lock")
|
|
250
|
+
|
|
251
|
+
# Some Windows versions do not allow for paths longer than 255 characters.
|
|
252
|
+
# In this case, we must specify it as an extended path by using the "\\?\" prefix
|
|
253
|
+
if os.name == "nt":
|
|
254
|
+
if not str(local_dir).startswith("\\\\?\\") and len(os.path.abspath(lock_path)) > 255:
|
|
255
|
+
file_path = Path("\\\\?\\" + os.path.abspath(file_path))
|
|
256
|
+
lock_path = Path("\\\\?\\" + os.path.abspath(lock_path))
|
|
257
|
+
metadata_path = Path("\\\\?\\" + os.path.abspath(metadata_path))
|
|
258
|
+
|
|
259
|
+
file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
260
|
+
metadata_path.parent.mkdir(parents=True, exist_ok=True)
|
|
261
|
+
return LocalUploadFilePaths(
|
|
262
|
+
path_in_repo=filename, file_path=file_path, lock_path=lock_path, metadata_path=metadata_path
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
|
|
155
266
|
def read_download_metadata(local_dir: Path, filename: str) -> Optional[LocalDownloadFileMetadata]:
|
|
156
267
|
"""Read metadata about a file in the local directory related to a download process.
|
|
157
268
|
|
|
@@ -165,8 +276,6 @@ def read_download_metadata(local_dir: Path, filename: str) -> Optional[LocalDown
|
|
|
165
276
|
`[LocalDownloadFileMetadata]` or `None`: the metadata if it exists, `None` otherwise.
|
|
166
277
|
"""
|
|
167
278
|
paths = get_local_download_paths(local_dir, filename)
|
|
168
|
-
# file_path = local_file_path(local_dir, filename)
|
|
169
|
-
# lock_path, metadata_path = _download_metadata_file_path(local_dir, filename)
|
|
170
279
|
with WeakFileLock(paths.lock_path):
|
|
171
280
|
if paths.metadata_path.exists():
|
|
172
281
|
try:
|
|
@@ -204,6 +313,84 @@ def read_download_metadata(local_dir: Path, filename: str) -> Optional[LocalDown
|
|
|
204
313
|
return None
|
|
205
314
|
|
|
206
315
|
|
|
316
|
+
def read_upload_metadata(local_dir: Path, filename: str) -> LocalUploadFileMetadata:
|
|
317
|
+
"""Read metadata about a file in the local directory related to an upload process.
|
|
318
|
+
|
|
319
|
+
TODO: factorize logic with `read_download_metadata`.
|
|
320
|
+
|
|
321
|
+
Args:
|
|
322
|
+
local_dir (`Path`):
|
|
323
|
+
Path to the local directory in which files are downloaded.
|
|
324
|
+
filename (`str`):
|
|
325
|
+
Path of the file in the repo.
|
|
326
|
+
|
|
327
|
+
Return:
|
|
328
|
+
`[LocalUploadFileMetadata]` or `None`: the metadata if it exists, `None` otherwise.
|
|
329
|
+
"""
|
|
330
|
+
paths = get_local_upload_paths(local_dir, filename)
|
|
331
|
+
with WeakFileLock(paths.lock_path):
|
|
332
|
+
if paths.metadata_path.exists():
|
|
333
|
+
try:
|
|
334
|
+
with paths.metadata_path.open() as f:
|
|
335
|
+
timestamp = float(f.readline().strip())
|
|
336
|
+
|
|
337
|
+
size = int(f.readline().strip()) # never None
|
|
338
|
+
|
|
339
|
+
_should_ignore = f.readline().strip()
|
|
340
|
+
should_ignore = None if _should_ignore == "" else bool(int(_should_ignore))
|
|
341
|
+
|
|
342
|
+
_sha256 = f.readline().strip()
|
|
343
|
+
sha256 = None if _sha256 == "" else _sha256
|
|
344
|
+
|
|
345
|
+
_upload_mode = f.readline().strip()
|
|
346
|
+
upload_mode = None if _upload_mode == "" else _upload_mode
|
|
347
|
+
if upload_mode not in (None, "regular", "lfs"):
|
|
348
|
+
raise ValueError(f"Invalid upload mode in metadata {paths.path_in_repo}: {upload_mode}")
|
|
349
|
+
|
|
350
|
+
is_uploaded = bool(int(f.readline().strip()))
|
|
351
|
+
is_committed = bool(int(f.readline().strip()))
|
|
352
|
+
|
|
353
|
+
metadata = LocalUploadFileMetadata(
|
|
354
|
+
timestamp=timestamp,
|
|
355
|
+
size=size,
|
|
356
|
+
should_ignore=should_ignore,
|
|
357
|
+
sha256=sha256,
|
|
358
|
+
upload_mode=upload_mode,
|
|
359
|
+
is_uploaded=is_uploaded,
|
|
360
|
+
is_committed=is_committed,
|
|
361
|
+
)
|
|
362
|
+
except Exception as e:
|
|
363
|
+
# remove the metadata file if it is corrupted / not the right format
|
|
364
|
+
logger.warning(
|
|
365
|
+
f"Invalid metadata file {paths.metadata_path}: {e}. Removing it from disk and continue."
|
|
366
|
+
)
|
|
367
|
+
try:
|
|
368
|
+
paths.metadata_path.unlink()
|
|
369
|
+
except Exception as e:
|
|
370
|
+
logger.warning(f"Could not remove corrupted metadata file {paths.metadata_path}: {e}")
|
|
371
|
+
|
|
372
|
+
# TODO: can we do better?
|
|
373
|
+
if (
|
|
374
|
+
metadata.timestamp is not None
|
|
375
|
+
and metadata.is_uploaded # file was uploaded
|
|
376
|
+
and not metadata.is_committed # but not committed
|
|
377
|
+
and time.time() - metadata.timestamp > 20 * 3600 # and it's been more than 20 hours
|
|
378
|
+
): # => we consider it as garbage-collected by S3
|
|
379
|
+
metadata.is_uploaded = False
|
|
380
|
+
|
|
381
|
+
# check if the file exists and hasn't been modified since the metadata was saved
|
|
382
|
+
try:
|
|
383
|
+
if metadata.timestamp is not None and paths.file_path.stat().st_mtime <= metadata.timestamp:
|
|
384
|
+
return metadata
|
|
385
|
+
logger.info(f"Ignored metadata for '{filename}' (outdated). Will re-compute hash.")
|
|
386
|
+
except FileNotFoundError:
|
|
387
|
+
# file does not exist => metadata is outdated
|
|
388
|
+
pass
|
|
389
|
+
|
|
390
|
+
# empty metadata => we don't know anything expect its size
|
|
391
|
+
return LocalUploadFileMetadata(size=paths.file_path.stat().st_size)
|
|
392
|
+
|
|
393
|
+
|
|
207
394
|
def write_download_metadata(local_dir: Path, filename: str, commit_hash: str, etag: str) -> None:
|
|
208
395
|
"""Write metadata about a file in the local directory related to a download process.
|
|
209
396
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
"""Contains methods to
|
|
14
|
+
"""Contains methods to log in to the Hub."""
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
17
|
import subprocess
|
|
@@ -60,7 +60,7 @@ def login(
|
|
|
60
60
|
components. If `token` is not provided, it will be prompted to the user either with
|
|
61
61
|
a widget (in a notebook) or via the terminal.
|
|
62
62
|
|
|
63
|
-
To
|
|
63
|
+
To log in from outside of a script, one can also use `huggingface-cli login` which is
|
|
64
64
|
a cli command that wraps [`login`].
|
|
65
65
|
|
|
66
66
|
<Tip>
|
|
@@ -94,7 +94,7 @@ def login(
|
|
|
94
94
|
Raises:
|
|
95
95
|
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
96
96
|
If an organization token is passed. Only personal account tokens are valid
|
|
97
|
-
to
|
|
97
|
+
to log in.
|
|
98
98
|
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
99
99
|
If token is invalid.
|
|
100
100
|
[`ImportError`](https://docs.python.org/3/library/exceptions.html#ImportError)
|
|
@@ -155,7 +155,7 @@ def logout() -> None:
|
|
|
155
155
|
|
|
156
156
|
def interpreter_login(new_session: bool = True, write_permission: bool = False) -> None:
|
|
157
157
|
"""
|
|
158
|
-
Displays a prompt to
|
|
158
|
+
Displays a prompt to log in to the HF website and store the token.
|
|
159
159
|
|
|
160
160
|
This is equivalent to [`login`] without passing a token when not run in a notebook.
|
|
161
161
|
[`interpreter_login`] is useful if you want to force the use of the terminal prompt
|
|
@@ -185,7 +185,7 @@ def interpreter_login(new_session: bool = True, write_permission: bool = False)
|
|
|
185
185
|
)
|
|
186
186
|
print(" Setting a new token will erase the existing one.")
|
|
187
187
|
|
|
188
|
-
print(" To
|
|
188
|
+
print(" To log in, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .")
|
|
189
189
|
if os.name == "nt":
|
|
190
190
|
print("Token can be pasted using 'Right-Click'.")
|
|
191
191
|
token = getpass("Enter your token (input will not be visible): ")
|
|
@@ -220,7 +220,7 @@ notebooks. </center>"""
|
|
|
220
220
|
|
|
221
221
|
def notebook_login(new_session: bool = True, write_permission: bool = False) -> None:
|
|
222
222
|
"""
|
|
223
|
-
Displays a widget to
|
|
223
|
+
Displays a widget to log in to the HF website and store the token.
|
|
224
224
|
|
|
225
225
|
This is equivalent to [`login`] without passing a token when run in a notebook.
|
|
226
226
|
[`notebook_login`] is useful if you want to force the use of the notebook widget
|
|
@@ -6,21 +6,12 @@ import requests
|
|
|
6
6
|
from tqdm.auto import tqdm as base_tqdm
|
|
7
7
|
from tqdm.contrib.concurrent import thread_map
|
|
8
8
|
|
|
9
|
-
from .
|
|
10
|
-
|
|
11
|
-
DEFAULT_REVISION,
|
|
12
|
-
HF_HUB_CACHE,
|
|
13
|
-
HF_HUB_ENABLE_HF_TRANSFER,
|
|
14
|
-
REPO_TYPES,
|
|
15
|
-
)
|
|
9
|
+
from . import constants
|
|
10
|
+
from .errors import GatedRepoError, LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
|
|
16
11
|
from .file_download import REGEX_COMMIT_HASH, hf_hub_download, repo_folder_name
|
|
17
12
|
from .hf_api import DatasetInfo, HfApi, ModelInfo, SpaceInfo
|
|
18
13
|
from .utils import (
|
|
19
|
-
GatedRepoError,
|
|
20
|
-
LocalEntryNotFoundError,
|
|
21
14
|
OfflineModeIsEnabled,
|
|
22
|
-
RepositoryNotFoundError,
|
|
23
|
-
RevisionNotFoundError,
|
|
24
15
|
filter_repo_objects,
|
|
25
16
|
logging,
|
|
26
17
|
validate_hf_hub_args,
|
|
@@ -43,7 +34,7 @@ def snapshot_download(
|
|
|
43
34
|
library_version: Optional[str] = None,
|
|
44
35
|
user_agent: Optional[Union[Dict, str]] = None,
|
|
45
36
|
proxies: Optional[Dict] = None,
|
|
46
|
-
etag_timeout: float = DEFAULT_ETAG_TIMEOUT,
|
|
37
|
+
etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
|
|
47
38
|
force_download: bool = False,
|
|
48
39
|
token: Optional[Union[bool, str]] = None,
|
|
49
40
|
local_files_only: bool = False,
|
|
@@ -140,16 +131,16 @@ def snapshot_download(
|
|
|
140
131
|
if some parameter value is invalid.
|
|
141
132
|
"""
|
|
142
133
|
if cache_dir is None:
|
|
143
|
-
cache_dir = HF_HUB_CACHE
|
|
134
|
+
cache_dir = constants.HF_HUB_CACHE
|
|
144
135
|
if revision is None:
|
|
145
|
-
revision = DEFAULT_REVISION
|
|
136
|
+
revision = constants.DEFAULT_REVISION
|
|
146
137
|
if isinstance(cache_dir, Path):
|
|
147
138
|
cache_dir = str(cache_dir)
|
|
148
139
|
|
|
149
140
|
if repo_type is None:
|
|
150
141
|
repo_type = "model"
|
|
151
|
-
if repo_type not in REPO_TYPES:
|
|
152
|
-
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(REPO_TYPES)}")
|
|
142
|
+
if repo_type not in constants.REPO_TYPES:
|
|
143
|
+
raise ValueError(f"Invalid repo type: {repo_type}. Accepted repo types are: {str(constants.REPO_TYPES)}")
|
|
153
144
|
|
|
154
145
|
storage_folder = os.path.join(cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type))
|
|
155
146
|
|
|
@@ -290,7 +281,7 @@ def snapshot_download(
|
|
|
290
281
|
headers=headers,
|
|
291
282
|
)
|
|
292
283
|
|
|
293
|
-
if HF_HUB_ENABLE_HF_TRANSFER:
|
|
284
|
+
if constants.HF_HUB_ENABLE_HF_TRANSFER:
|
|
294
285
|
# when using hf_transfer we don't want extra parallelism
|
|
295
286
|
# from the one hf_transfer provides
|
|
296
287
|
for file in filtered_repo_files:
|
|
@@ -61,12 +61,17 @@ class SpaceHardware(str, Enum):
|
|
|
61
61
|
CPU_UPGRADE = "cpu-upgrade"
|
|
62
62
|
T4_SMALL = "t4-small"
|
|
63
63
|
T4_MEDIUM = "t4-medium"
|
|
64
|
+
L4X1 = "l4x1"
|
|
65
|
+
L4X4 = "l4x4"
|
|
64
66
|
ZERO_A10G = "zero-a10g"
|
|
65
67
|
A10G_SMALL = "a10g-small"
|
|
66
68
|
A10G_LARGE = "a10g-large"
|
|
67
69
|
A10G_LARGEX2 = "a10g-largex2"
|
|
68
70
|
A10G_LARGEX4 = "a10g-largex4"
|
|
69
71
|
A100_LARGE = "a100-large"
|
|
72
|
+
V5E_1X1 = "v5e-1x1"
|
|
73
|
+
V5E_2X2 = "v5e-2x2"
|
|
74
|
+
V5E_2X4 = "v5e-2x4"
|
|
70
75
|
|
|
71
76
|
|
|
72
77
|
class SpaceStorage(str, Enum):
|