huggingface-hub 0.29.0rc2__py3-none-any.whl → 1.1.3__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.
- huggingface_hub/__init__.py +160 -46
- huggingface_hub/_commit_api.py +277 -71
- huggingface_hub/_commit_scheduler.py +15 -15
- huggingface_hub/_inference_endpoints.py +33 -22
- huggingface_hub/_jobs_api.py +301 -0
- huggingface_hub/_local_folder.py +18 -3
- huggingface_hub/_login.py +31 -63
- huggingface_hub/_oauth.py +460 -0
- huggingface_hub/_snapshot_download.py +241 -81
- huggingface_hub/_space_api.py +18 -10
- huggingface_hub/_tensorboard_logger.py +15 -19
- huggingface_hub/_upload_large_folder.py +196 -76
- huggingface_hub/_webhooks_payload.py +3 -3
- huggingface_hub/_webhooks_server.py +15 -25
- huggingface_hub/{commands → cli}/__init__.py +1 -15
- huggingface_hub/cli/_cli_utils.py +173 -0
- huggingface_hub/cli/auth.py +147 -0
- huggingface_hub/cli/cache.py +841 -0
- huggingface_hub/cli/download.py +189 -0
- huggingface_hub/cli/hf.py +60 -0
- huggingface_hub/cli/inference_endpoints.py +377 -0
- huggingface_hub/cli/jobs.py +772 -0
- huggingface_hub/cli/lfs.py +175 -0
- huggingface_hub/cli/repo.py +315 -0
- huggingface_hub/cli/repo_files.py +94 -0
- huggingface_hub/{commands/env.py → cli/system.py} +10 -13
- huggingface_hub/cli/upload.py +294 -0
- huggingface_hub/cli/upload_large_folder.py +117 -0
- huggingface_hub/community.py +20 -12
- huggingface_hub/constants.py +83 -59
- huggingface_hub/dataclasses.py +609 -0
- huggingface_hub/errors.py +99 -30
- huggingface_hub/fastai_utils.py +30 -41
- huggingface_hub/file_download.py +606 -346
- huggingface_hub/hf_api.py +2445 -1132
- huggingface_hub/hf_file_system.py +269 -152
- huggingface_hub/hub_mixin.py +61 -66
- huggingface_hub/inference/_client.py +501 -630
- huggingface_hub/inference/_common.py +133 -121
- huggingface_hub/inference/_generated/_async_client.py +536 -722
- huggingface_hub/inference/_generated/types/__init__.py +6 -1
- huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +5 -6
- huggingface_hub/inference/_generated/types/base.py +10 -7
- huggingface_hub/inference/_generated/types/chat_completion.py +77 -31
- huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
- huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
- huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
- huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
- huggingface_hub/inference/_generated/types/image_to_image.py +8 -2
- huggingface_hub/inference/_generated/types/image_to_text.py +2 -3
- huggingface_hub/inference/_generated/types/image_to_video.py +60 -0
- huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
- huggingface_hub/inference/_generated/types/summarization.py +2 -2
- huggingface_hub/inference/_generated/types/table_question_answering.py +5 -5
- huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
- huggingface_hub/inference/_generated/types/text_generation.py +11 -11
- huggingface_hub/inference/_generated/types/text_to_audio.py +1 -2
- huggingface_hub/inference/_generated/types/text_to_speech.py +1 -2
- huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
- huggingface_hub/inference/_generated/types/token_classification.py +2 -2
- huggingface_hub/inference/_generated/types/translation.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
- huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
- huggingface_hub/inference/_mcp/__init__.py +0 -0
- huggingface_hub/inference/_mcp/_cli_hacks.py +88 -0
- huggingface_hub/inference/_mcp/agent.py +100 -0
- huggingface_hub/inference/_mcp/cli.py +247 -0
- huggingface_hub/inference/_mcp/constants.py +81 -0
- huggingface_hub/inference/_mcp/mcp_client.py +395 -0
- huggingface_hub/inference/_mcp/types.py +45 -0
- huggingface_hub/inference/_mcp/utils.py +128 -0
- huggingface_hub/inference/_providers/__init__.py +149 -20
- huggingface_hub/inference/_providers/_common.py +160 -37
- huggingface_hub/inference/_providers/black_forest_labs.py +12 -9
- huggingface_hub/inference/_providers/cerebras.py +6 -0
- huggingface_hub/inference/_providers/clarifai.py +13 -0
- huggingface_hub/inference/_providers/cohere.py +32 -0
- huggingface_hub/inference/_providers/fal_ai.py +231 -22
- huggingface_hub/inference/_providers/featherless_ai.py +38 -0
- huggingface_hub/inference/_providers/fireworks_ai.py +22 -1
- huggingface_hub/inference/_providers/groq.py +9 -0
- huggingface_hub/inference/_providers/hf_inference.py +143 -33
- huggingface_hub/inference/_providers/hyperbolic.py +9 -5
- huggingface_hub/inference/_providers/nebius.py +47 -5
- huggingface_hub/inference/_providers/novita.py +48 -5
- huggingface_hub/inference/_providers/nscale.py +44 -0
- huggingface_hub/inference/_providers/openai.py +25 -0
- huggingface_hub/inference/_providers/publicai.py +6 -0
- huggingface_hub/inference/_providers/replicate.py +46 -9
- huggingface_hub/inference/_providers/sambanova.py +37 -1
- huggingface_hub/inference/_providers/scaleway.py +28 -0
- huggingface_hub/inference/_providers/together.py +34 -5
- huggingface_hub/inference/_providers/wavespeed.py +138 -0
- huggingface_hub/inference/_providers/zai_org.py +17 -0
- huggingface_hub/lfs.py +33 -100
- huggingface_hub/repocard.py +34 -38
- huggingface_hub/repocard_data.py +79 -59
- huggingface_hub/serialization/__init__.py +0 -1
- huggingface_hub/serialization/_base.py +12 -15
- huggingface_hub/serialization/_dduf.py +8 -8
- huggingface_hub/serialization/_torch.py +69 -69
- huggingface_hub/utils/__init__.py +27 -8
- huggingface_hub/utils/_auth.py +7 -7
- huggingface_hub/utils/_cache_manager.py +92 -147
- huggingface_hub/utils/_chunk_utils.py +2 -3
- huggingface_hub/utils/_deprecation.py +1 -1
- huggingface_hub/utils/_dotenv.py +55 -0
- huggingface_hub/utils/_experimental.py +7 -5
- huggingface_hub/utils/_fixes.py +0 -10
- huggingface_hub/utils/_git_credential.py +5 -5
- huggingface_hub/utils/_headers.py +8 -30
- huggingface_hub/utils/_http.py +399 -237
- huggingface_hub/utils/_pagination.py +6 -6
- huggingface_hub/utils/_parsing.py +98 -0
- huggingface_hub/utils/_paths.py +5 -5
- huggingface_hub/utils/_runtime.py +74 -22
- huggingface_hub/utils/_safetensors.py +21 -21
- huggingface_hub/utils/_subprocess.py +13 -11
- huggingface_hub/utils/_telemetry.py +4 -4
- huggingface_hub/{commands/_cli_utils.py → utils/_terminal.py} +4 -4
- huggingface_hub/utils/_typing.py +25 -5
- huggingface_hub/utils/_validators.py +55 -74
- huggingface_hub/utils/_verification.py +167 -0
- huggingface_hub/utils/_xet.py +235 -0
- huggingface_hub/utils/_xet_progress_reporting.py +162 -0
- huggingface_hub/utils/insecure_hashlib.py +3 -5
- huggingface_hub/utils/logging.py +8 -11
- huggingface_hub/utils/tqdm.py +33 -4
- {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/METADATA +94 -82
- huggingface_hub-1.1.3.dist-info/RECORD +155 -0
- {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/WHEEL +1 -1
- huggingface_hub-1.1.3.dist-info/entry_points.txt +6 -0
- huggingface_hub/commands/delete_cache.py +0 -428
- huggingface_hub/commands/download.py +0 -200
- huggingface_hub/commands/huggingface_cli.py +0 -61
- huggingface_hub/commands/lfs.py +0 -200
- huggingface_hub/commands/repo_files.py +0 -128
- huggingface_hub/commands/scan_cache.py +0 -181
- huggingface_hub/commands/tag.py +0 -159
- huggingface_hub/commands/upload.py +0 -299
- huggingface_hub/commands/upload_large_folder.py +0 -129
- huggingface_hub/commands/user.py +0 -304
- huggingface_hub/commands/version.py +0 -37
- huggingface_hub/inference_api.py +0 -217
- huggingface_hub/keras_mixin.py +0 -500
- huggingface_hub/repository.py +0 -1477
- huggingface_hub/serialization/_tensorflow.py +0 -95
- huggingface_hub/utils/_hf_folder.py +0 -68
- huggingface_hub-0.29.0rc2.dist-info/RECORD +0 -131
- huggingface_hub-0.29.0rc2.dist-info/entry_points.txt +0 -6
- {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info/licenses}/LICENSE +0 -0
- {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/top_level.txt +0 -0
huggingface_hub/constants.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
import typing
|
|
4
|
-
from typing import Literal, Optional
|
|
4
|
+
from typing import Literal, Optional
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# Possible values for env variables
|
|
@@ -35,7 +35,7 @@ DEFAULT_ETAG_TIMEOUT = 10
|
|
|
35
35
|
DEFAULT_DOWNLOAD_TIMEOUT = 10
|
|
36
36
|
DEFAULT_REQUEST_TIMEOUT = 10
|
|
37
37
|
DOWNLOAD_CHUNK_SIZE = 10 * 1024 * 1024
|
|
38
|
-
|
|
38
|
+
MAX_HTTP_DOWNLOAD_SIZE = 50 * 1000 * 1000 * 1000 # 50 GB
|
|
39
39
|
|
|
40
40
|
# Constants for serialization
|
|
41
41
|
|
|
@@ -73,11 +73,24 @@ if _staging_mode:
|
|
|
73
73
|
HUGGINGFACE_HEADER_X_REPO_COMMIT = "X-Repo-Commit"
|
|
74
74
|
HUGGINGFACE_HEADER_X_LINKED_ETAG = "X-Linked-Etag"
|
|
75
75
|
HUGGINGFACE_HEADER_X_LINKED_SIZE = "X-Linked-Size"
|
|
76
|
+
HUGGINGFACE_HEADER_X_BILL_TO = "X-HF-Bill-To"
|
|
76
77
|
|
|
77
78
|
INFERENCE_ENDPOINT = os.environ.get("HF_INFERENCE_ENDPOINT", "https://api-inference.huggingface.co")
|
|
78
79
|
|
|
79
80
|
# See https://huggingface.co/docs/inference-endpoints/index
|
|
80
81
|
INFERENCE_ENDPOINTS_ENDPOINT = "https://api.endpoints.huggingface.cloud/v2"
|
|
82
|
+
INFERENCE_CATALOG_ENDPOINT = "https://endpoints.huggingface.co/api/catalog"
|
|
83
|
+
|
|
84
|
+
# See https://api.endpoints.huggingface.cloud/#post-/v2/endpoint/-namespace-
|
|
85
|
+
INFERENCE_ENDPOINT_IMAGE_KEYS = [
|
|
86
|
+
"custom",
|
|
87
|
+
"huggingface",
|
|
88
|
+
"huggingfaceNeuron",
|
|
89
|
+
"llamacpp",
|
|
90
|
+
"tei",
|
|
91
|
+
"tgi",
|
|
92
|
+
"tgiNeuron",
|
|
93
|
+
]
|
|
81
94
|
|
|
82
95
|
# Proxy for third-party providers
|
|
83
96
|
INFERENCE_PROXY_TEMPLATE = "https://router.huggingface.co/{provider}"
|
|
@@ -104,22 +117,23 @@ REPO_TYPES_MAPPING = {
|
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
DiscussionTypeFilter = Literal["all", "discussion", "pull_request"]
|
|
107
|
-
DISCUSSION_TYPES:
|
|
120
|
+
DISCUSSION_TYPES: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionTypeFilter)
|
|
108
121
|
DiscussionStatusFilter = Literal["all", "open", "closed"]
|
|
109
|
-
DISCUSSION_STATUS:
|
|
122
|
+
DISCUSSION_STATUS: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter)
|
|
110
123
|
|
|
111
124
|
# Webhook subscription types
|
|
112
125
|
WEBHOOK_DOMAIN_T = Literal["repo", "discussions"]
|
|
113
126
|
|
|
114
127
|
# default cache
|
|
115
128
|
default_home = os.path.join(os.path.expanduser("~"), ".cache")
|
|
116
|
-
HF_HOME = os.path.
|
|
117
|
-
os.
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
HF_HOME = os.path.expandvars(
|
|
130
|
+
os.path.expanduser(
|
|
131
|
+
os.getenv(
|
|
132
|
+
"HF_HOME",
|
|
133
|
+
os.path.join(os.getenv("XDG_CACHE_HOME", default_home), "huggingface"),
|
|
134
|
+
)
|
|
120
135
|
)
|
|
121
136
|
)
|
|
122
|
-
hf_cache_home = HF_HOME # for backward compatibility. TODO: remove this in 1.0.0
|
|
123
137
|
|
|
124
138
|
default_cache_path = os.path.join(HF_HOME, "hub")
|
|
125
139
|
default_assets_cache_path = os.path.join(HF_HOME, "assets")
|
|
@@ -129,11 +143,29 @@ HUGGINGFACE_HUB_CACHE = os.getenv("HUGGINGFACE_HUB_CACHE", default_cache_path)
|
|
|
129
143
|
HUGGINGFACE_ASSETS_CACHE = os.getenv("HUGGINGFACE_ASSETS_CACHE", default_assets_cache_path)
|
|
130
144
|
|
|
131
145
|
# New env variables
|
|
132
|
-
HF_HUB_CACHE = os.
|
|
133
|
-
|
|
146
|
+
HF_HUB_CACHE = os.path.expandvars(
|
|
147
|
+
os.path.expanduser(
|
|
148
|
+
os.getenv(
|
|
149
|
+
"HF_HUB_CACHE",
|
|
150
|
+
HUGGINGFACE_HUB_CACHE,
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
HF_ASSETS_CACHE = os.path.expandvars(
|
|
155
|
+
os.path.expanduser(
|
|
156
|
+
os.getenv(
|
|
157
|
+
"HF_ASSETS_CACHE",
|
|
158
|
+
HUGGINGFACE_ASSETS_CACHE,
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
)
|
|
134
162
|
|
|
135
163
|
HF_HUB_OFFLINE = _is_true(os.environ.get("HF_HUB_OFFLINE") or os.environ.get("TRANSFORMERS_OFFLINE"))
|
|
136
164
|
|
|
165
|
+
# File created to mark that the version check has been done.
|
|
166
|
+
# Check is performed once per 24 hours at most.
|
|
167
|
+
CHECK_FOR_UPDATE_DONE_PATH = os.path.join(HF_HOME, ".check_for_update_done")
|
|
168
|
+
|
|
137
169
|
# If set, log level will be set to DEBUG and all requests made to the Hub will be logged
|
|
138
170
|
# as curl commands for reproducibility.
|
|
139
171
|
HF_DEBUG = _is_true(os.environ.get("HF_DEBUG"))
|
|
@@ -145,7 +177,14 @@ HF_HUB_DISABLE_TELEMETRY = (
|
|
|
145
177
|
or _is_true(os.environ.get("DO_NOT_TRACK")) # https://consoledonottrack.com/
|
|
146
178
|
)
|
|
147
179
|
|
|
148
|
-
HF_TOKEN_PATH = os.
|
|
180
|
+
HF_TOKEN_PATH = os.path.expandvars(
|
|
181
|
+
os.path.expanduser(
|
|
182
|
+
os.getenv(
|
|
183
|
+
"HF_TOKEN_PATH",
|
|
184
|
+
os.path.join(HF_HOME, "token"),
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
)
|
|
149
188
|
HF_STORED_TOKENS_PATH = os.path.join(os.path.dirname(HF_TOKEN_PATH), "stored_tokens")
|
|
150
189
|
|
|
151
190
|
if _staging_mode:
|
|
@@ -175,18 +214,18 @@ HF_HUB_DISABLE_EXPERIMENTAL_WARNING: bool = _is_true(os.environ.get("HF_HUB_DISA
|
|
|
175
214
|
# Disable sending the cached token by default is all HTTP requests to the Hub
|
|
176
215
|
HF_HUB_DISABLE_IMPLICIT_TOKEN: bool = _is_true(os.environ.get("HF_HUB_DISABLE_IMPLICIT_TOKEN"))
|
|
177
216
|
|
|
178
|
-
|
|
179
|
-
# See:
|
|
180
|
-
# - https://pypi.org/project/hf-transfer/
|
|
181
|
-
# - https://github.com/huggingface/hf_transfer (private)
|
|
182
|
-
HF_HUB_ENABLE_HF_TRANSFER: bool = _is_true(os.environ.get("HF_HUB_ENABLE_HF_TRANSFER"))
|
|
217
|
+
HF_XET_HIGH_PERFORMANCE: bool = _is_true(os.environ.get("HF_XET_HIGH_PERFORMANCE"))
|
|
183
218
|
|
|
219
|
+
# hf_transfer is not used anymore. Let's warn user is case they set the env variable
|
|
220
|
+
if _is_true(os.environ.get("HF_HUB_ENABLE_HF_TRANSFER")) and not HF_XET_HIGH_PERFORMANCE:
|
|
221
|
+
import warnings
|
|
184
222
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
223
|
+
warnings.warn(
|
|
224
|
+
"The `HF_HUB_ENABLE_HF_TRANSFER` environment variable is deprecated as 'hf_transfer' is not used anymore. "
|
|
225
|
+
"Please use `HF_XET_HIGH_PERFORMANCE` instead to enable high performance transfer with Xet. "
|
|
226
|
+
"Visit https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfxethighperformance for more details.",
|
|
227
|
+
DeprecationWarning,
|
|
228
|
+
)
|
|
190
229
|
|
|
191
230
|
# Used to override the etag timeout on a system level
|
|
192
231
|
HF_HUB_ETAG_TIMEOUT: int = _as_int(os.environ.get("HF_HUB_ETAG_TIMEOUT")) or DEFAULT_ETAG_TIMEOUT
|
|
@@ -194,42 +233,27 @@ HF_HUB_ETAG_TIMEOUT: int = _as_int(os.environ.get("HF_HUB_ETAG_TIMEOUT")) or DEF
|
|
|
194
233
|
# Used to override the get request timeout on a system level
|
|
195
234
|
HF_HUB_DOWNLOAD_TIMEOUT: int = _as_int(os.environ.get("HF_HUB_DOWNLOAD_TIMEOUT")) or DEFAULT_DOWNLOAD_TIMEOUT
|
|
196
235
|
|
|
197
|
-
# Allows to add information about the requester in the user-agent (
|
|
236
|
+
# Allows to add information about the requester in the user-agent (e.g. partner name)
|
|
198
237
|
HF_HUB_USER_AGENT_ORIGIN: Optional[str] = os.environ.get("HF_HUB_USER_AGENT_ORIGIN")
|
|
199
238
|
|
|
200
|
-
#
|
|
201
|
-
#
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
"k2",
|
|
222
|
-
"keras",
|
|
223
|
-
"mindspore",
|
|
224
|
-
"nemo",
|
|
225
|
-
"open_clip",
|
|
226
|
-
"paddlenlp",
|
|
227
|
-
"peft",
|
|
228
|
-
"pyannote-audio",
|
|
229
|
-
"sklearn",
|
|
230
|
-
"spacy",
|
|
231
|
-
"span-marker",
|
|
232
|
-
"speechbrain",
|
|
233
|
-
"stanza",
|
|
234
|
-
"timm",
|
|
235
|
-
]
|
|
239
|
+
# If OAuth didn't work after 2 redirects, there's likely a third-party cookie issue in the Space iframe view.
|
|
240
|
+
# In this case, we redirect the user to the non-iframe view.
|
|
241
|
+
OAUTH_MAX_REDIRECTS = 2
|
|
242
|
+
|
|
243
|
+
# OAuth-related environment variables injected by the Space
|
|
244
|
+
OAUTH_CLIENT_ID = os.environ.get("OAUTH_CLIENT_ID")
|
|
245
|
+
OAUTH_CLIENT_SECRET = os.environ.get("OAUTH_CLIENT_SECRET")
|
|
246
|
+
OAUTH_SCOPES = os.environ.get("OAUTH_SCOPES")
|
|
247
|
+
OPENID_PROVIDER_URL = os.environ.get("OPENID_PROVIDER_URL")
|
|
248
|
+
|
|
249
|
+
# Xet constants
|
|
250
|
+
HUGGINGFACE_HEADER_X_XET_ENDPOINT = "X-Xet-Cas-Url"
|
|
251
|
+
HUGGINGFACE_HEADER_X_XET_ACCESS_TOKEN = "X-Xet-Access-Token"
|
|
252
|
+
HUGGINGFACE_HEADER_X_XET_EXPIRATION = "X-Xet-Token-Expiration"
|
|
253
|
+
HUGGINGFACE_HEADER_X_XET_HASH = "X-Xet-Hash"
|
|
254
|
+
HUGGINGFACE_HEADER_X_XET_REFRESH_ROUTE = "X-Xet-Refresh-Route"
|
|
255
|
+
HUGGINGFACE_HEADER_LINK_XET_AUTH_KEY = "xet-auth"
|
|
256
|
+
|
|
257
|
+
default_xet_cache_path = os.path.join(HF_HOME, "xet")
|
|
258
|
+
HF_XET_CACHE = os.getenv("HF_XET_CACHE", default_xet_cache_path)
|
|
259
|
+
HF_HUB_DISABLE_XET: bool = _is_true(os.environ.get("HF_HUB_DISABLE_XET"))
|