huggingface-hub 0.23.5__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/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.5.dist-info → huggingface_hub-0.24.0.dist-info}/METADATA +12 -9
- {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.0.dist-info}/RECORD +41 -41
- huggingface_hub/serialization/_numpy.py +0 -68
- {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.0.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.0.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.0.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.23.5.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
|
+
)
|