huggingface-hub 0.23.4__py3-none-any.whl → 0.24.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- huggingface_hub/__init__.py +47 -15
- huggingface_hub/_commit_api.py +38 -8
- huggingface_hub/_inference_endpoints.py +11 -4
- huggingface_hub/_local_folder.py +22 -13
- huggingface_hub/_snapshot_download.py +12 -7
- huggingface_hub/_webhooks_server.py +3 -1
- huggingface_hub/commands/huggingface_cli.py +4 -3
- huggingface_hub/commands/repo_files.py +128 -0
- huggingface_hub/constants.py +12 -0
- huggingface_hub/file_download.py +127 -91
- huggingface_hub/hf_api.py +976 -341
- huggingface_hub/hf_file_system.py +30 -3
- huggingface_hub/hub_mixin.py +17 -6
- huggingface_hub/inference/_client.py +379 -43
- huggingface_hub/inference/_common.py +0 -2
- huggingface_hub/inference/_generated/_async_client.py +396 -49
- huggingface_hub/inference/_generated/types/__init__.py +4 -1
- huggingface_hub/inference/_generated/types/chat_completion.py +41 -21
- huggingface_hub/inference/_generated/types/feature_extraction.py +23 -5
- huggingface_hub/inference/_generated/types/text_generation.py +29 -0
- huggingface_hub/lfs.py +11 -6
- huggingface_hub/repocard_data.py +3 -3
- huggingface_hub/repository.py +6 -6
- huggingface_hub/serialization/__init__.py +8 -3
- huggingface_hub/serialization/_base.py +13 -16
- huggingface_hub/serialization/_tensorflow.py +4 -3
- huggingface_hub/serialization/_torch.py +399 -22
- huggingface_hub/utils/__init__.py +0 -1
- huggingface_hub/utils/_errors.py +1 -1
- huggingface_hub/utils/_fixes.py +14 -3
- huggingface_hub/utils/_paths.py +17 -6
- huggingface_hub/utils/_subprocess.py +0 -1
- huggingface_hub/utils/_telemetry.py +9 -1
- huggingface_hub/utils/endpoint_helpers.py +2 -186
- huggingface_hub/utils/sha.py +36 -1
- huggingface_hub/utils/tqdm.py +0 -1
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/METADATA +12 -9
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/RECORD +42 -42
- huggingface_hub/serialization/_numpy.py +0 -68
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.23.4.dist-info → huggingface_hub-0.24.0.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
import os
|
|
2
3
|
import re
|
|
3
4
|
import tempfile
|
|
@@ -74,8 +75,11 @@ class HfFileSystem(fsspec.AbstractFileSystem):
|
|
|
74
75
|
Access a remote Hugging Face Hub repository as if were a local file system.
|
|
75
76
|
|
|
76
77
|
Args:
|
|
77
|
-
token (`str`, *optional*):
|
|
78
|
-
|
|
78
|
+
token (`str` or `bool`, *optional*):
|
|
79
|
+
A valid user access token (string). Defaults to the locally saved
|
|
80
|
+
token, which is the recommended method for authentication (see
|
|
81
|
+
https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
|
|
82
|
+
To disable authentication, pass `False`.
|
|
79
83
|
|
|
80
84
|
Usage:
|
|
81
85
|
|
|
@@ -105,7 +109,7 @@ class HfFileSystem(fsspec.AbstractFileSystem):
|
|
|
105
109
|
self,
|
|
106
110
|
*args,
|
|
107
111
|
endpoint: Optional[str] = None,
|
|
108
|
-
token:
|
|
112
|
+
token: Union[bool, str, None] = None,
|
|
109
113
|
**storage_options,
|
|
110
114
|
):
|
|
111
115
|
super().__init__(*args, **storage_options)
|
|
@@ -400,6 +404,12 @@ class HfFileSystem(fsspec.AbstractFileSystem):
|
|
|
400
404
|
out.append(cache_path_info)
|
|
401
405
|
return out
|
|
402
406
|
|
|
407
|
+
def walk(self, path, *args, **kwargs):
|
|
408
|
+
# Set expand_info=False by default to get a x10 speed boost
|
|
409
|
+
kwargs = {"expand_info": kwargs.get("detail", False), **kwargs}
|
|
410
|
+
path = self.resolve_path(path, revision=kwargs.get("revision")).unresolve()
|
|
411
|
+
yield from super().walk(path, *args, **kwargs)
|
|
412
|
+
|
|
403
413
|
def glob(self, path, **kwargs):
|
|
404
414
|
# Set expand_info=False by default to get a x10 speed boost
|
|
405
415
|
kwargs = {"expand_info": kwargs.get("detail", False), **kwargs}
|
|
@@ -880,3 +890,20 @@ def _raise_file_not_found(path: str, err: Optional[Exception]) -> NoReturn:
|
|
|
880
890
|
|
|
881
891
|
def reopen(fs: HfFileSystem, path: str, mode: str, block_size: int, cache_type: str):
|
|
882
892
|
return fs.open(path, mode=mode, block_size=block_size, cache_type=cache_type)
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
# Add docstrings to the methods of HfFileSystem from fsspec.AbstractFileSystem
|
|
896
|
+
for name, function in inspect.getmembers(HfFileSystem, predicate=inspect.isfunction):
|
|
897
|
+
parent = getattr(fsspec.AbstractFileSystem, name, None)
|
|
898
|
+
if parent is not None and parent.__doc__ is not None:
|
|
899
|
+
parent_doc = parent.__doc__
|
|
900
|
+
parent_doc = parent_doc.replace("Parameters\n ----------\n", "Args:\n")
|
|
901
|
+
parent_doc = parent_doc.replace("Returns\n -------\n", "Return:\n")
|
|
902
|
+
function.__doc__ = (
|
|
903
|
+
(
|
|
904
|
+
"\n_Docstring taken from "
|
|
905
|
+
f"[fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.{name})._"
|
|
906
|
+
)
|
|
907
|
+
+ "\n\n"
|
|
908
|
+
+ parent_doc
|
|
909
|
+
)
|
huggingface_hub/hub_mixin.py
CHANGED
|
@@ -230,12 +230,21 @@ class ModelHubMixin:
|
|
|
230
230
|
tags.append("model_hub_mixin")
|
|
231
231
|
|
|
232
232
|
# Initialize MixinInfo if not existent
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
info = MixinInfo(model_card_template=model_card_template, model_card_data=ModelCardData())
|
|
234
|
+
|
|
235
|
+
# If parent class has a MixinInfo, inherit from it as a copy
|
|
236
|
+
if hasattr(cls, "_hub_mixin_info"):
|
|
237
|
+
# Inherit model card template from parent class if not explicitly set
|
|
238
|
+
if model_card_template == DEFAULT_MODEL_CARD:
|
|
239
|
+
info.model_card_template = cls._hub_mixin_info.model_card_template
|
|
240
|
+
|
|
241
|
+
# Inherit from parent model card data
|
|
242
|
+
info.model_card_data = ModelCardData(**cls._hub_mixin_info.model_card_data.to_dict())
|
|
243
|
+
|
|
244
|
+
# Inherit other info
|
|
245
|
+
info.docs_url = cls._hub_mixin_info.docs_url
|
|
246
|
+
info.repo_url = cls._hub_mixin_info.repo_url
|
|
247
|
+
cls._hub_mixin_info = info
|
|
239
248
|
|
|
240
249
|
if languages is not None:
|
|
241
250
|
warnings.warn(
|
|
@@ -269,6 +278,8 @@ class ModelHubMixin:
|
|
|
269
278
|
else:
|
|
270
279
|
info.model_card_data.tags = tags
|
|
271
280
|
|
|
281
|
+
info.model_card_data.tags = sorted(set(info.model_card_data.tags))
|
|
282
|
+
|
|
272
283
|
# Handle encoders/decoders for args
|
|
273
284
|
cls._hub_mixin_coders = coders or {}
|
|
274
285
|
cls._hub_mixin_jsonable_custom_types = tuple(cls._hub_mixin_coders.keys())
|