huggingface-hub 0.26.5__tar.gz → 0.27.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.26.5 → huggingface_hub-0.27.0}/PKG-INFO +8 -3
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/README.md +6 -2
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/setup.py +1 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/__init__.py +49 -23
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_commit_scheduler.py +30 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_local_folder.py +0 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_login.py +38 -54
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_snapshot_download.py +6 -3
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_tensorboard_logger.py +2 -3
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_upload_large_folder.py +1 -1
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/errors.py +19 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/fastai_utils.py +3 -2
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/file_download.py +10 -12
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/hf_api.py +102 -498
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/hf_file_system.py +274 -35
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/hub_mixin.py +5 -25
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_client.py +185 -136
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_common.py +2 -2
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/_async_client.py +186 -137
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/__init__.py +31 -10
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/audio_classification.py +3 -5
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +6 -9
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/chat_completion.py +8 -5
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +1 -1
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +2 -6
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +1 -1
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/fill_mask.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/image_classification.py +3 -5
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/image_to_image.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/image_to_text.py +6 -9
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/object_detection.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/question_answering.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +1 -1
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/summarization.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +21 -3
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text_classification.py +4 -10
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +7 -10
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text_to_image.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text_to_speech.py +7 -10
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/token_classification.py +11 -12
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/translation.py +2 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/video_classification.py +3 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +2 -5
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +8 -18
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +9 -19
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +7 -9
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/keras_mixin.py +3 -2
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/lfs.py +2 -5
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/repocard_data.py +4 -4
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/serialization/__init__.py +2 -0
- huggingface_hub-0.27.0/src/huggingface_hub/serialization/_dduf.py +387 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/serialization/_torch.py +372 -14
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_cache_manager.py +1 -1
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_headers.py +9 -25
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/tqdm.py +15 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub.egg-info/PKG-INFO +8 -3
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub.egg-info/SOURCES.txt +1 -1
- huggingface_hub-0.26.5/src/huggingface_hub/_multi_commits.py +0 -306
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/LICENSE +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/MANIFEST.in +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/pyproject.toml +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/setup.cfg +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_commit_api.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_inference_endpoints.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_space_api.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_webhooks_payload.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/_webhooks_server.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/__init__.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/_cli_utils.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/delete_cache.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/download.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/env.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/lfs.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/repo_files.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/scan_cache.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/tag.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/upload.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/upload_large_folder.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/user.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/commands/version.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/community.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/constants.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/__init__.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/inference_api.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/repocard.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/repository.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/serialization/_base.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/serialization/_tensorflow.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/templates/modelcard_template.md +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/__init__.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_auth.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_cache_assets.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_datetime.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_deprecation.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_experimental.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_fixes.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_git_credential.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_hf_folder.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_http.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_lfs.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_pagination.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_paths.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_runtime.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_safetensors.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_subprocess.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_telemetry.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_typing.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/_validators.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/logging.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub/utils/sha.py +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.0}/src/huggingface_hub.egg-info/requires.txt +0 -0
- {huggingface_hub-0.26.5 → huggingface_hub-0.27.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.27.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.
|
|
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
24
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
25
|
Requires-Python: >=3.8.0
|
|
25
26
|
Description-Content-Type: text/markdown
|
|
@@ -38,10 +39,14 @@ Provides-Extra: dev
|
|
|
38
39
|
License-File: LICENSE
|
|
39
40
|
|
|
40
41
|
<p align="center">
|
|
42
|
+
<picture>
|
|
43
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub-dark.svg">
|
|
44
|
+
<source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg">
|
|
45
|
+
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="352" height="59" style="max-width: 100%;">
|
|
46
|
+
</picture>
|
|
41
47
|
<br/>
|
|
42
|
-
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="376" height="59" style="max-width: 100%;">
|
|
43
48
|
<br/>
|
|
44
|
-
</p>
|
|
49
|
+
</p>
|
|
45
50
|
|
|
46
51
|
<p align="center">
|
|
47
52
|
<i>The official Python client for the Huggingface Hub.</i>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub-dark.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg">
|
|
5
|
+
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="352" height="59" style="max-width: 100%;">
|
|
6
|
+
</picture>
|
|
2
7
|
<br/>
|
|
3
|
-
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="376" height="59" style="max-width: 100%;">
|
|
4
8
|
<br/>
|
|
5
|
-
</p>
|
|
9
|
+
</p>
|
|
6
10
|
|
|
7
11
|
<p align="center">
|
|
8
12
|
<i>The official Python client for the Huggingface Hub.</i>
|
|
@@ -134,6 +134,7 @@ setup(
|
|
|
134
134
|
"Programming Language :: Python :: 3.10",
|
|
135
135
|
"Programming Language :: Python :: 3.11",
|
|
136
136
|
"Programming Language :: Python :: 3.12",
|
|
137
|
+
"Programming Language :: Python :: 3.13",
|
|
137
138
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
138
139
|
],
|
|
139
140
|
include_package_data=True,
|
|
@@ -46,7 +46,7 @@ import sys
|
|
|
46
46
|
from typing import TYPE_CHECKING
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
__version__ = "0.
|
|
49
|
+
__version__ = "0.27.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
|
|
@@ -70,10 +70,6 @@ _SUBMOD_ATTRS = {
|
|
|
70
70
|
"logout",
|
|
71
71
|
"notebook_login",
|
|
72
72
|
],
|
|
73
|
-
"_multi_commits": [
|
|
74
|
-
"MultiCommitException",
|
|
75
|
-
"plan_multi_commits",
|
|
76
|
-
],
|
|
77
73
|
"_snapshot_download": [
|
|
78
74
|
"snapshot_download",
|
|
79
75
|
],
|
|
@@ -167,7 +163,6 @@ _SUBMOD_ATTRS = {
|
|
|
167
163
|
"create_branch",
|
|
168
164
|
"create_collection",
|
|
169
165
|
"create_commit",
|
|
170
|
-
"create_commits_on_pr",
|
|
171
166
|
"create_discussion",
|
|
172
167
|
"create_inference_endpoint",
|
|
173
168
|
"create_pull_request",
|
|
@@ -213,7 +208,6 @@ _SUBMOD_ATTRS = {
|
|
|
213
208
|
"list_datasets",
|
|
214
209
|
"list_inference_endpoints",
|
|
215
210
|
"list_liked_repos",
|
|
216
|
-
"list_metrics",
|
|
217
211
|
"list_models",
|
|
218
212
|
"list_organization_members",
|
|
219
213
|
"list_papers",
|
|
@@ -297,10 +291,14 @@ _SUBMOD_ATTRS = {
|
|
|
297
291
|
"ChatCompletionInputFunctionDefinition",
|
|
298
292
|
"ChatCompletionInputFunctionName",
|
|
299
293
|
"ChatCompletionInputGrammarType",
|
|
294
|
+
"ChatCompletionInputGrammarTypeType",
|
|
300
295
|
"ChatCompletionInputMessage",
|
|
301
296
|
"ChatCompletionInputMessageChunk",
|
|
297
|
+
"ChatCompletionInputMessageChunkType",
|
|
302
298
|
"ChatCompletionInputStreamOptions",
|
|
303
|
-
"
|
|
299
|
+
"ChatCompletionInputTool",
|
|
300
|
+
"ChatCompletionInputToolChoiceClass",
|
|
301
|
+
"ChatCompletionInputToolChoiceEnum",
|
|
304
302
|
"ChatCompletionInputURL",
|
|
305
303
|
"ChatCompletionOutput",
|
|
306
304
|
"ChatCompletionOutputComplete",
|
|
@@ -327,6 +325,7 @@ _SUBMOD_ATTRS = {
|
|
|
327
325
|
"DocumentQuestionAnsweringOutputElement",
|
|
328
326
|
"DocumentQuestionAnsweringParameters",
|
|
329
327
|
"FeatureExtractionInput",
|
|
328
|
+
"FeatureExtractionInputTruncationDirection",
|
|
330
329
|
"FillMaskInput",
|
|
331
330
|
"FillMaskOutputElement",
|
|
332
331
|
"FillMaskParameters",
|
|
@@ -337,6 +336,7 @@ _SUBMOD_ATTRS = {
|
|
|
337
336
|
"ImageSegmentationInput",
|
|
338
337
|
"ImageSegmentationOutputElement",
|
|
339
338
|
"ImageSegmentationParameters",
|
|
339
|
+
"ImageSegmentationSubtask",
|
|
340
340
|
"ImageToImageInput",
|
|
341
341
|
"ImageToImageOutput",
|
|
342
342
|
"ImageToImageParameters",
|
|
@@ -350,6 +350,7 @@ _SUBMOD_ATTRS = {
|
|
|
350
350
|
"ObjectDetectionInput",
|
|
351
351
|
"ObjectDetectionOutputElement",
|
|
352
352
|
"ObjectDetectionParameters",
|
|
353
|
+
"Padding",
|
|
353
354
|
"QuestionAnsweringInput",
|
|
354
355
|
"QuestionAnsweringInputData",
|
|
355
356
|
"QuestionAnsweringOutputElement",
|
|
@@ -359,12 +360,15 @@ _SUBMOD_ATTRS = {
|
|
|
359
360
|
"SummarizationInput",
|
|
360
361
|
"SummarizationOutput",
|
|
361
362
|
"SummarizationParameters",
|
|
363
|
+
"SummarizationTruncationStrategy",
|
|
362
364
|
"TableQuestionAnsweringInput",
|
|
363
365
|
"TableQuestionAnsweringInputData",
|
|
364
366
|
"TableQuestionAnsweringOutputElement",
|
|
367
|
+
"TableQuestionAnsweringParameters",
|
|
365
368
|
"Text2TextGenerationInput",
|
|
366
369
|
"Text2TextGenerationOutput",
|
|
367
370
|
"Text2TextGenerationParameters",
|
|
371
|
+
"Text2TextGenerationTruncationStrategy",
|
|
368
372
|
"TextClassificationInput",
|
|
369
373
|
"TextClassificationOutputElement",
|
|
370
374
|
"TextClassificationOutputTransform",
|
|
@@ -375,6 +379,7 @@ _SUBMOD_ATTRS = {
|
|
|
375
379
|
"TextGenerationOutput",
|
|
376
380
|
"TextGenerationOutputBestOfSequence",
|
|
377
381
|
"TextGenerationOutputDetails",
|
|
382
|
+
"TextGenerationOutputFinishReason",
|
|
378
383
|
"TextGenerationOutputPrefillToken",
|
|
379
384
|
"TextGenerationOutputToken",
|
|
380
385
|
"TextGenerationStreamOutput",
|
|
@@ -394,13 +399,15 @@ _SUBMOD_ATTRS = {
|
|
|
394
399
|
"TextToSpeechInput",
|
|
395
400
|
"TextToSpeechOutput",
|
|
396
401
|
"TextToSpeechParameters",
|
|
402
|
+
"TokenClassificationAggregationStrategy",
|
|
397
403
|
"TokenClassificationInput",
|
|
398
404
|
"TokenClassificationOutputElement",
|
|
399
405
|
"TokenClassificationParameters",
|
|
400
|
-
"ToolElement",
|
|
401
406
|
"TranslationInput",
|
|
402
407
|
"TranslationOutput",
|
|
403
408
|
"TranslationParameters",
|
|
409
|
+
"TranslationTruncationStrategy",
|
|
410
|
+
"TypeEnum",
|
|
404
411
|
"VideoClassificationInput",
|
|
405
412
|
"VideoClassificationOutputElement",
|
|
406
413
|
"VideoClassificationOutputTransform",
|
|
@@ -410,17 +417,15 @@ _SUBMOD_ATTRS = {
|
|
|
410
417
|
"VisualQuestionAnsweringOutputElement",
|
|
411
418
|
"VisualQuestionAnsweringParameters",
|
|
412
419
|
"ZeroShotClassificationInput",
|
|
413
|
-
"ZeroShotClassificationInputData",
|
|
414
420
|
"ZeroShotClassificationOutputElement",
|
|
415
421
|
"ZeroShotClassificationParameters",
|
|
416
422
|
"ZeroShotImageClassificationInput",
|
|
417
|
-
"ZeroShotImageClassificationInputData",
|
|
418
423
|
"ZeroShotImageClassificationOutputElement",
|
|
419
424
|
"ZeroShotImageClassificationParameters",
|
|
420
425
|
"ZeroShotObjectDetectionBoundingBox",
|
|
421
426
|
"ZeroShotObjectDetectionInput",
|
|
422
|
-
"ZeroShotObjectDetectionInputData",
|
|
423
427
|
"ZeroShotObjectDetectionOutputElement",
|
|
428
|
+
"ZeroShotObjectDetectionParameters",
|
|
424
429
|
],
|
|
425
430
|
"inference_api": [
|
|
426
431
|
"InferenceApi",
|
|
@@ -456,12 +461,20 @@ _SUBMOD_ATTRS = {
|
|
|
456
461
|
"get_tf_storage_size",
|
|
457
462
|
"get_torch_storage_id",
|
|
458
463
|
"get_torch_storage_size",
|
|
464
|
+
"load_state_dict_from_file",
|
|
465
|
+
"load_torch_model",
|
|
459
466
|
"save_torch_model",
|
|
460
467
|
"save_torch_state_dict",
|
|
461
468
|
"split_state_dict_into_shards_factory",
|
|
462
469
|
"split_tf_state_dict_into_shards",
|
|
463
470
|
"split_torch_state_dict_into_shards",
|
|
464
471
|
],
|
|
472
|
+
"serialization._dduf": [
|
|
473
|
+
"DDUFEntry",
|
|
474
|
+
"export_entries_as_dduf",
|
|
475
|
+
"export_folder_as_dduf",
|
|
476
|
+
"read_dduf_file",
|
|
477
|
+
],
|
|
465
478
|
"utils": [
|
|
466
479
|
"CacheNotFound",
|
|
467
480
|
"CachedFileInfo",
|
|
@@ -601,10 +614,6 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
601
614
|
logout, # noqa: F401
|
|
602
615
|
notebook_login, # noqa: F401
|
|
603
616
|
)
|
|
604
|
-
from ._multi_commits import (
|
|
605
|
-
MultiCommitException, # noqa: F401
|
|
606
|
-
plan_multi_commits, # noqa: F401
|
|
607
|
-
)
|
|
608
617
|
from ._snapshot_download import snapshot_download # noqa: F401
|
|
609
618
|
from ._space_api import (
|
|
610
619
|
SpaceHardware, # noqa: F401
|
|
@@ -694,7 +703,6 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
694
703
|
create_branch, # noqa: F401
|
|
695
704
|
create_collection, # noqa: F401
|
|
696
705
|
create_commit, # noqa: F401
|
|
697
|
-
create_commits_on_pr, # noqa: F401
|
|
698
706
|
create_discussion, # noqa: F401
|
|
699
707
|
create_inference_endpoint, # noqa: F401
|
|
700
708
|
create_pull_request, # noqa: F401
|
|
@@ -740,7 +748,6 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
740
748
|
list_datasets, # noqa: F401
|
|
741
749
|
list_inference_endpoints, # noqa: F401
|
|
742
750
|
list_liked_repos, # noqa: F401
|
|
743
|
-
list_metrics, # noqa: F401
|
|
744
751
|
list_models, # noqa: F401
|
|
745
752
|
list_organization_members, # noqa: F401
|
|
746
753
|
list_papers, # noqa: F401
|
|
@@ -822,10 +829,14 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
822
829
|
ChatCompletionInputFunctionDefinition, # noqa: F401
|
|
823
830
|
ChatCompletionInputFunctionName, # noqa: F401
|
|
824
831
|
ChatCompletionInputGrammarType, # noqa: F401
|
|
832
|
+
ChatCompletionInputGrammarTypeType, # noqa: F401
|
|
825
833
|
ChatCompletionInputMessage, # noqa: F401
|
|
826
834
|
ChatCompletionInputMessageChunk, # noqa: F401
|
|
835
|
+
ChatCompletionInputMessageChunkType, # noqa: F401
|
|
827
836
|
ChatCompletionInputStreamOptions, # noqa: F401
|
|
828
|
-
|
|
837
|
+
ChatCompletionInputTool, # noqa: F401
|
|
838
|
+
ChatCompletionInputToolChoiceClass, # noqa: F401
|
|
839
|
+
ChatCompletionInputToolChoiceEnum, # noqa: F401
|
|
829
840
|
ChatCompletionInputURL, # noqa: F401
|
|
830
841
|
ChatCompletionOutput, # noqa: F401
|
|
831
842
|
ChatCompletionOutputComplete, # noqa: F401
|
|
@@ -852,6 +863,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
852
863
|
DocumentQuestionAnsweringOutputElement, # noqa: F401
|
|
853
864
|
DocumentQuestionAnsweringParameters, # noqa: F401
|
|
854
865
|
FeatureExtractionInput, # noqa: F401
|
|
866
|
+
FeatureExtractionInputTruncationDirection, # noqa: F401
|
|
855
867
|
FillMaskInput, # noqa: F401
|
|
856
868
|
FillMaskOutputElement, # noqa: F401
|
|
857
869
|
FillMaskParameters, # noqa: F401
|
|
@@ -862,6 +874,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
862
874
|
ImageSegmentationInput, # noqa: F401
|
|
863
875
|
ImageSegmentationOutputElement, # noqa: F401
|
|
864
876
|
ImageSegmentationParameters, # noqa: F401
|
|
877
|
+
ImageSegmentationSubtask, # noqa: F401
|
|
865
878
|
ImageToImageInput, # noqa: F401
|
|
866
879
|
ImageToImageOutput, # noqa: F401
|
|
867
880
|
ImageToImageParameters, # noqa: F401
|
|
@@ -875,6 +888,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
875
888
|
ObjectDetectionInput, # noqa: F401
|
|
876
889
|
ObjectDetectionOutputElement, # noqa: F401
|
|
877
890
|
ObjectDetectionParameters, # noqa: F401
|
|
891
|
+
Padding, # noqa: F401
|
|
878
892
|
QuestionAnsweringInput, # noqa: F401
|
|
879
893
|
QuestionAnsweringInputData, # noqa: F401
|
|
880
894
|
QuestionAnsweringOutputElement, # noqa: F401
|
|
@@ -884,12 +898,15 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
884
898
|
SummarizationInput, # noqa: F401
|
|
885
899
|
SummarizationOutput, # noqa: F401
|
|
886
900
|
SummarizationParameters, # noqa: F401
|
|
901
|
+
SummarizationTruncationStrategy, # noqa: F401
|
|
887
902
|
TableQuestionAnsweringInput, # noqa: F401
|
|
888
903
|
TableQuestionAnsweringInputData, # noqa: F401
|
|
889
904
|
TableQuestionAnsweringOutputElement, # noqa: F401
|
|
905
|
+
TableQuestionAnsweringParameters, # noqa: F401
|
|
890
906
|
Text2TextGenerationInput, # noqa: F401
|
|
891
907
|
Text2TextGenerationOutput, # noqa: F401
|
|
892
908
|
Text2TextGenerationParameters, # noqa: F401
|
|
909
|
+
Text2TextGenerationTruncationStrategy, # noqa: F401
|
|
893
910
|
TextClassificationInput, # noqa: F401
|
|
894
911
|
TextClassificationOutputElement, # noqa: F401
|
|
895
912
|
TextClassificationOutputTransform, # noqa: F401
|
|
@@ -900,6 +917,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
900
917
|
TextGenerationOutput, # noqa: F401
|
|
901
918
|
TextGenerationOutputBestOfSequence, # noqa: F401
|
|
902
919
|
TextGenerationOutputDetails, # noqa: F401
|
|
920
|
+
TextGenerationOutputFinishReason, # noqa: F401
|
|
903
921
|
TextGenerationOutputPrefillToken, # noqa: F401
|
|
904
922
|
TextGenerationOutputToken, # noqa: F401
|
|
905
923
|
TextGenerationStreamOutput, # noqa: F401
|
|
@@ -919,13 +937,15 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
919
937
|
TextToSpeechInput, # noqa: F401
|
|
920
938
|
TextToSpeechOutput, # noqa: F401
|
|
921
939
|
TextToSpeechParameters, # noqa: F401
|
|
940
|
+
TokenClassificationAggregationStrategy, # noqa: F401
|
|
922
941
|
TokenClassificationInput, # noqa: F401
|
|
923
942
|
TokenClassificationOutputElement, # noqa: F401
|
|
924
943
|
TokenClassificationParameters, # noqa: F401
|
|
925
|
-
ToolElement, # noqa: F401
|
|
926
944
|
TranslationInput, # noqa: F401
|
|
927
945
|
TranslationOutput, # noqa: F401
|
|
928
946
|
TranslationParameters, # noqa: F401
|
|
947
|
+
TranslationTruncationStrategy, # noqa: F401
|
|
948
|
+
TypeEnum, # noqa: F401
|
|
929
949
|
VideoClassificationInput, # noqa: F401
|
|
930
950
|
VideoClassificationOutputElement, # noqa: F401
|
|
931
951
|
VideoClassificationOutputTransform, # noqa: F401
|
|
@@ -935,17 +955,15 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
935
955
|
VisualQuestionAnsweringOutputElement, # noqa: F401
|
|
936
956
|
VisualQuestionAnsweringParameters, # noqa: F401
|
|
937
957
|
ZeroShotClassificationInput, # noqa: F401
|
|
938
|
-
ZeroShotClassificationInputData, # noqa: F401
|
|
939
958
|
ZeroShotClassificationOutputElement, # noqa: F401
|
|
940
959
|
ZeroShotClassificationParameters, # noqa: F401
|
|
941
960
|
ZeroShotImageClassificationInput, # noqa: F401
|
|
942
|
-
ZeroShotImageClassificationInputData, # noqa: F401
|
|
943
961
|
ZeroShotImageClassificationOutputElement, # noqa: F401
|
|
944
962
|
ZeroShotImageClassificationParameters, # noqa: F401
|
|
945
963
|
ZeroShotObjectDetectionBoundingBox, # noqa: F401
|
|
946
964
|
ZeroShotObjectDetectionInput, # noqa: F401
|
|
947
|
-
ZeroShotObjectDetectionInputData, # noqa: F401
|
|
948
965
|
ZeroShotObjectDetectionOutputElement, # noqa: F401
|
|
966
|
+
ZeroShotObjectDetectionParameters, # noqa: F401
|
|
949
967
|
)
|
|
950
968
|
from .inference_api import InferenceApi # noqa: F401
|
|
951
969
|
from .keras_mixin import (
|
|
@@ -977,12 +995,20 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
977
995
|
get_tf_storage_size, # noqa: F401
|
|
978
996
|
get_torch_storage_id, # noqa: F401
|
|
979
997
|
get_torch_storage_size, # noqa: F401
|
|
998
|
+
load_state_dict_from_file, # noqa: F401
|
|
999
|
+
load_torch_model, # noqa: F401
|
|
980
1000
|
save_torch_model, # noqa: F401
|
|
981
1001
|
save_torch_state_dict, # noqa: F401
|
|
982
1002
|
split_state_dict_into_shards_factory, # noqa: F401
|
|
983
1003
|
split_tf_state_dict_into_shards, # noqa: F401
|
|
984
1004
|
split_torch_state_dict_into_shards, # noqa: F401
|
|
985
1005
|
)
|
|
1006
|
+
from .serialization._dduf import (
|
|
1007
|
+
DDUFEntry, # noqa: F401
|
|
1008
|
+
export_entries_as_dduf, # noqa: F401
|
|
1009
|
+
export_folder_as_dduf, # noqa: F401
|
|
1010
|
+
read_dduf_file, # noqa: F401
|
|
1011
|
+
)
|
|
986
1012
|
from .utils import (
|
|
987
1013
|
CachedFileInfo, # noqa: F401
|
|
988
1014
|
CachedRepoInfo, # noqa: F401
|
|
@@ -30,8 +30,9 @@ class CommitScheduler:
|
|
|
30
30
|
"""
|
|
31
31
|
Scheduler to upload a local folder to the Hub at regular intervals (e.g. push to hub every 5 minutes).
|
|
32
32
|
|
|
33
|
-
The
|
|
34
|
-
triggered
|
|
33
|
+
The recommended way to use the scheduler is to use it as a context manager. This ensures that the scheduler is
|
|
34
|
+
properly stopped and the last commit is triggered when the script ends. The scheduler can also be stopped manually
|
|
35
|
+
with the `stop` method. Checkout the [upload guide](https://huggingface.co/docs/huggingface_hub/guides/upload#scheduled-uploads)
|
|
35
36
|
to learn more about how to use it.
|
|
36
37
|
|
|
37
38
|
Args:
|
|
@@ -49,7 +50,7 @@ class CommitScheduler:
|
|
|
49
50
|
revision (`str`, *optional*):
|
|
50
51
|
The revision of the repo to commit to. Defaults to `main`.
|
|
51
52
|
private (`bool`, *optional*):
|
|
52
|
-
Whether to make the repo private.
|
|
53
|
+
Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists.
|
|
53
54
|
token (`str`, *optional*):
|
|
54
55
|
The token to use to commit to the repo. Defaults to the token saved on the machine.
|
|
55
56
|
allow_patterns (`List[str]` or `str`, *optional*):
|
|
@@ -78,6 +79,22 @@ class CommitScheduler:
|
|
|
78
79
|
>>> with csv_path.open("a") as f:
|
|
79
80
|
... f.write("second line")
|
|
80
81
|
```
|
|
82
|
+
|
|
83
|
+
Example using a context manager:
|
|
84
|
+
```py
|
|
85
|
+
>>> from pathlib import Path
|
|
86
|
+
>>> from huggingface_hub import CommitScheduler
|
|
87
|
+
|
|
88
|
+
>>> with CommitScheduler(repo_id="test_scheduler", repo_type="dataset", folder_path="watched_folder", every=10) as scheduler:
|
|
89
|
+
... csv_path = Path("watched_folder/data.csv")
|
|
90
|
+
... with csv_path.open("a") as f:
|
|
91
|
+
... f.write("first line")
|
|
92
|
+
... (...)
|
|
93
|
+
... with csv_path.open("a") as f:
|
|
94
|
+
... f.write("second line")
|
|
95
|
+
|
|
96
|
+
# Scheduler is now stopped and last commit have been triggered
|
|
97
|
+
```
|
|
81
98
|
"""
|
|
82
99
|
|
|
83
100
|
def __init__(
|
|
@@ -89,7 +106,7 @@ class CommitScheduler:
|
|
|
89
106
|
path_in_repo: Optional[str] = None,
|
|
90
107
|
repo_type: Optional[str] = None,
|
|
91
108
|
revision: Optional[str] = None,
|
|
92
|
-
private: bool =
|
|
109
|
+
private: Optional[bool] = None,
|
|
93
110
|
token: Optional[str] = None,
|
|
94
111
|
allow_patterns: Optional[Union[List[str], str]] = None,
|
|
95
112
|
ignore_patterns: Optional[Union[List[str], str]] = None,
|
|
@@ -144,6 +161,15 @@ class CommitScheduler:
|
|
|
144
161
|
"""
|
|
145
162
|
self.__stopped = True
|
|
146
163
|
|
|
164
|
+
def __enter__(self) -> "CommitScheduler":
|
|
165
|
+
return self
|
|
166
|
+
|
|
167
|
+
def __exit__(self, exc_type, exc_value, traceback) -> None:
|
|
168
|
+
# Upload last changes before exiting
|
|
169
|
+
self.trigger().result()
|
|
170
|
+
self.stop()
|
|
171
|
+
return
|
|
172
|
+
|
|
147
173
|
def _run_scheduler(self) -> None:
|
|
148
174
|
"""Dumb thread waiting between each scheduled push to Hub."""
|
|
149
175
|
while True:
|
|
@@ -53,7 +53,6 @@ import logging
|
|
|
53
53
|
import os
|
|
54
54
|
import time
|
|
55
55
|
from dataclasses import dataclass
|
|
56
|
-
from functools import lru_cache
|
|
57
56
|
from pathlib import Path
|
|
58
57
|
from typing import Optional
|
|
59
58
|
|
|
@@ -179,7 +178,6 @@ class LocalUploadFileMetadata:
|
|
|
179
178
|
self.timestamp = new_timestamp
|
|
180
179
|
|
|
181
180
|
|
|
182
|
-
@lru_cache(maxsize=128) # ensure singleton
|
|
183
181
|
def get_local_download_paths(local_dir: Path, filename: str) -> LocalDownloadFilePaths:
|
|
184
182
|
"""Compute paths to the files related to a download process.
|
|
185
183
|
|
|
@@ -220,7 +218,6 @@ def get_local_download_paths(local_dir: Path, filename: str) -> LocalDownloadFil
|
|
|
220
218
|
return LocalDownloadFilePaths(file_path=file_path, lock_path=lock_path, metadata_path=metadata_path)
|
|
221
219
|
|
|
222
220
|
|
|
223
|
-
@lru_cache(maxsize=128) # ensure singleton
|
|
224
221
|
def get_local_upload_paths(local_dir: Path, filename: str) -> LocalUploadFilePaths:
|
|
225
222
|
"""Compute paths to the files related to an upload process.
|
|
226
223
|
|
|
@@ -404,7 +401,6 @@ def write_download_metadata(local_dir: Path, filename: str, commit_hash: str, et
|
|
|
404
401
|
f.write(f"{commit_hash}\n{etag}\n{time.time()}\n")
|
|
405
402
|
|
|
406
403
|
|
|
407
|
-
@lru_cache()
|
|
408
404
|
def _huggingface_dir(local_dir: Path) -> Path:
|
|
409
405
|
"""Return the path to the `.cache/huggingface` directory in a local directory."""
|
|
410
406
|
# Wrap in lru_cache to avoid overwriting the .gitignore file if called multiple times
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
17
|
import subprocess
|
|
18
|
-
from functools import partial
|
|
19
18
|
from getpass import getpass
|
|
20
19
|
from pathlib import Path
|
|
21
20
|
from typing import Optional
|
|
@@ -42,6 +41,7 @@ from .utils._auth import (
|
|
|
42
41
|
_save_token,
|
|
43
42
|
get_stored_tokens,
|
|
44
43
|
)
|
|
44
|
+
from .utils._deprecation import _deprecate_arguments, _deprecate_positional_args
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
logger = logging.get_logger(__name__)
|
|
@@ -55,8 +55,15 @@ _HF_LOGO_ASCII = """
|
|
|
55
55
|
"""
|
|
56
56
|
|
|
57
57
|
|
|
58
|
+
@_deprecate_arguments(
|
|
59
|
+
version="1.0",
|
|
60
|
+
deprecated_args="write_permission",
|
|
61
|
+
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
|
|
62
|
+
)
|
|
63
|
+
@_deprecate_positional_args(version="1.0")
|
|
58
64
|
def login(
|
|
59
65
|
token: Optional[str] = None,
|
|
66
|
+
*,
|
|
60
67
|
add_to_git_credential: bool = False,
|
|
61
68
|
new_session: bool = True,
|
|
62
69
|
write_permission: bool = False,
|
|
@@ -97,8 +104,8 @@ def login(
|
|
|
97
104
|
to the end user.
|
|
98
105
|
new_session (`bool`, defaults to `True`):
|
|
99
106
|
If `True`, will request a token even if one is already saved on the machine.
|
|
100
|
-
write_permission (`bool
|
|
101
|
-
|
|
107
|
+
write_permission (`bool`):
|
|
108
|
+
Ignored and deprecated argument.
|
|
102
109
|
Raises:
|
|
103
110
|
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
104
111
|
If an organization token is passed. Only personal account tokens are valid
|
|
@@ -116,11 +123,11 @@ def login(
|
|
|
116
123
|
"`--add-to-git-credential` if using via `huggingface-cli` if "
|
|
117
124
|
"you want to set the git credential as well."
|
|
118
125
|
)
|
|
119
|
-
_login(token, add_to_git_credential=add_to_git_credential
|
|
126
|
+
_login(token, add_to_git_credential=add_to_git_credential)
|
|
120
127
|
elif is_notebook():
|
|
121
|
-
notebook_login(new_session=new_session
|
|
128
|
+
notebook_login(new_session=new_session)
|
|
122
129
|
else:
|
|
123
|
-
interpreter_login(new_session=new_session
|
|
130
|
+
interpreter_login(new_session=new_session)
|
|
124
131
|
|
|
125
132
|
|
|
126
133
|
def logout(token_name: Optional[str] = None) -> None:
|
|
@@ -235,7 +242,13 @@ def auth_list() -> None:
|
|
|
235
242
|
###
|
|
236
243
|
|
|
237
244
|
|
|
238
|
-
|
|
245
|
+
@_deprecate_arguments(
|
|
246
|
+
version="1.0",
|
|
247
|
+
deprecated_args="write_permission",
|
|
248
|
+
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
|
|
249
|
+
)
|
|
250
|
+
@_deprecate_positional_args(version="1.0")
|
|
251
|
+
def interpreter_login(*, new_session: bool = True, write_permission: bool = False) -> None:
|
|
239
252
|
"""
|
|
240
253
|
Displays a prompt to log in to the HF website and store the token.
|
|
241
254
|
|
|
@@ -248,11 +261,10 @@ def interpreter_login(new_session: bool = True, write_permission: bool = False)
|
|
|
248
261
|
Args:
|
|
249
262
|
new_session (`bool`, defaults to `True`):
|
|
250
263
|
If `True`, will request a token even if one is already saved on the machine.
|
|
251
|
-
write_permission (`bool
|
|
252
|
-
|
|
253
|
-
|
|
264
|
+
write_permission (`bool`):
|
|
265
|
+
Ignored and deprecated argument.
|
|
254
266
|
"""
|
|
255
|
-
if not new_session and
|
|
267
|
+
if not new_session and get_token() is not None:
|
|
256
268
|
logger.info("User is already logged in.")
|
|
257
269
|
return
|
|
258
270
|
|
|
@@ -275,11 +287,7 @@ def interpreter_login(new_session: bool = True, write_permission: bool = False)
|
|
|
275
287
|
token = getpass("Enter your token (input will not be visible): ")
|
|
276
288
|
add_to_git_credential = _ask_for_confirmation_no_tui("Add token as git credential?")
|
|
277
289
|
|
|
278
|
-
_login(
|
|
279
|
-
token=token,
|
|
280
|
-
add_to_git_credential=add_to_git_credential,
|
|
281
|
-
write_permission=write_permission,
|
|
282
|
-
)
|
|
290
|
+
_login(token=token, add_to_git_credential=add_to_git_credential)
|
|
283
291
|
|
|
284
292
|
|
|
285
293
|
###
|
|
@@ -306,7 +314,13 @@ NOTEBOOK_LOGIN_TOKEN_HTML_END = """
|
|
|
306
314
|
notebooks. </center>"""
|
|
307
315
|
|
|
308
316
|
|
|
309
|
-
|
|
317
|
+
@_deprecate_arguments(
|
|
318
|
+
version="1.0",
|
|
319
|
+
deprecated_args="write_permission",
|
|
320
|
+
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
|
|
321
|
+
)
|
|
322
|
+
@_deprecate_positional_args(version="1.0")
|
|
323
|
+
def notebook_login(*, new_session: bool = True, write_permission: bool = False) -> None:
|
|
310
324
|
"""
|
|
311
325
|
Displays a widget to log in to the HF website and store the token.
|
|
312
326
|
|
|
@@ -319,8 +333,8 @@ def notebook_login(new_session: bool = True, write_permission: bool = False) ->
|
|
|
319
333
|
Args:
|
|
320
334
|
new_session (`bool`, defaults to `True`):
|
|
321
335
|
If `True`, will request a token even if one is already saved on the machine.
|
|
322
|
-
write_permission (`bool
|
|
323
|
-
|
|
336
|
+
write_permission (`bool`):
|
|
337
|
+
Ignored and deprecated argument.
|
|
324
338
|
"""
|
|
325
339
|
try:
|
|
326
340
|
import ipywidgets.widgets as widgets # type: ignore
|
|
@@ -330,7 +344,7 @@ def notebook_login(new_session: bool = True, write_permission: bool = False) ->
|
|
|
330
344
|
"The `notebook_login` function can only be used in a notebook (Jupyter or"
|
|
331
345
|
" Colab) and you need the `ipywidgets` module: `pip install ipywidgets`."
|
|
332
346
|
)
|
|
333
|
-
if not new_session and
|
|
347
|
+
if not new_session and get_token() is not None:
|
|
334
348
|
logger.info("User is already logged in.")
|
|
335
349
|
return
|
|
336
350
|
|
|
@@ -353,14 +367,8 @@ def notebook_login(new_session: bool = True, write_permission: bool = False) ->
|
|
|
353
367
|
display(login_token_widget)
|
|
354
368
|
|
|
355
369
|
# On click events
|
|
356
|
-
def login_token_event(t
|
|
357
|
-
"""
|
|
358
|
-
Event handler for the login button.
|
|
359
|
-
|
|
360
|
-
Args:
|
|
361
|
-
write_permission (`bool`, defaults to `False`):
|
|
362
|
-
If `True`, requires a token with write permission.
|
|
363
|
-
"""
|
|
370
|
+
def login_token_event(t):
|
|
371
|
+
"""Event handler for the login button."""
|
|
364
372
|
token = token_widget.value
|
|
365
373
|
add_to_git_credential = git_checkbox_widget.value
|
|
366
374
|
# Erase token and clear value to make sure it's not saved in the notebook.
|
|
@@ -369,14 +377,14 @@ def notebook_login(new_session: bool = True, write_permission: bool = False) ->
|
|
|
369
377
|
login_token_widget.children = [widgets.Label("Connecting...")]
|
|
370
378
|
try:
|
|
371
379
|
with capture_output() as captured:
|
|
372
|
-
_login(token, add_to_git_credential=add_to_git_credential
|
|
380
|
+
_login(token, add_to_git_credential=add_to_git_credential)
|
|
373
381
|
message = captured.getvalue()
|
|
374
382
|
except Exception as error:
|
|
375
383
|
message = str(error)
|
|
376
384
|
# Print result (success message or error)
|
|
377
385
|
login_token_widget.children = [widgets.Label(line) for line in message.split("\n") if line.strip()]
|
|
378
386
|
|
|
379
|
-
token_finish_button.on_click(
|
|
387
|
+
token_finish_button.on_click(login_token_event)
|
|
380
388
|
|
|
381
389
|
|
|
382
390
|
###
|
|
@@ -387,7 +395,6 @@ def notebook_login(new_session: bool = True, write_permission: bool = False) ->
|
|
|
387
395
|
def _login(
|
|
388
396
|
token: str,
|
|
389
397
|
add_to_git_credential: bool,
|
|
390
|
-
write_permission: bool = False,
|
|
391
398
|
) -> None:
|
|
392
399
|
from .hf_api import whoami # avoid circular import
|
|
393
400
|
|
|
@@ -396,11 +403,6 @@ def _login(
|
|
|
396
403
|
|
|
397
404
|
token_info = whoami(token)
|
|
398
405
|
permission = token_info["auth"]["accessToken"]["role"]
|
|
399
|
-
if write_permission and permission != "write":
|
|
400
|
-
raise ValueError(
|
|
401
|
-
"Token is valid but is 'read-only' and a 'write' token is required.\nPlease provide a new token with"
|
|
402
|
-
" correct permission."
|
|
403
|
-
)
|
|
404
406
|
logger.info(f"Token is valid (permission: {permission}).")
|
|
405
407
|
|
|
406
408
|
token_name = token_info["auth"]["accessToken"]["displayName"]
|
|
@@ -469,24 +471,6 @@ def _set_active_token(
|
|
|
469
471
|
logger.info(f"Your token has been saved to {constants.HF_TOKEN_PATH}")
|
|
470
472
|
|
|
471
473
|
|
|
472
|
-
def _current_token_okay(write_permission: bool = False):
|
|
473
|
-
"""Check if the current token is valid.
|
|
474
|
-
|
|
475
|
-
Args:
|
|
476
|
-
write_permission (`bool`, defaults to `False`):
|
|
477
|
-
If `True`, requires a token with write permission.
|
|
478
|
-
|
|
479
|
-
Returns:
|
|
480
|
-
`bool`: `True` if the current token is valid, `False` otherwise.
|
|
481
|
-
"""
|
|
482
|
-
from .hf_api import get_token_permission # avoid circular import
|
|
483
|
-
|
|
484
|
-
permission = get_token_permission()
|
|
485
|
-
if permission is None or (write_permission and permission != "write"):
|
|
486
|
-
return False
|
|
487
|
-
return True
|
|
488
|
-
|
|
489
|
-
|
|
490
474
|
def _is_git_credential_helper_configured() -> bool:
|
|
491
475
|
"""Check if a git credential helper is configured.
|
|
492
476
|
|