huggingface-hub 0.23.5__py3-none-any.whl → 0.24.1__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.

Files changed (42) hide show
  1. huggingface_hub/__init__.py +47 -15
  2. huggingface_hub/_commit_api.py +38 -8
  3. huggingface_hub/_inference_endpoints.py +11 -4
  4. huggingface_hub/_local_folder.py +22 -13
  5. huggingface_hub/_snapshot_download.py +12 -7
  6. huggingface_hub/_webhooks_server.py +3 -1
  7. huggingface_hub/commands/huggingface_cli.py +4 -3
  8. huggingface_hub/commands/repo_files.py +128 -0
  9. huggingface_hub/constants.py +12 -0
  10. huggingface_hub/file_download.py +127 -91
  11. huggingface_hub/hf_api.py +976 -341
  12. huggingface_hub/hf_file_system.py +30 -3
  13. huggingface_hub/inference/_client.py +408 -147
  14. huggingface_hub/inference/_common.py +25 -63
  15. huggingface_hub/inference/_generated/_async_client.py +425 -153
  16. huggingface_hub/inference/_generated/types/__init__.py +4 -1
  17. huggingface_hub/inference/_generated/types/chat_completion.py +41 -21
  18. huggingface_hub/inference/_generated/types/feature_extraction.py +23 -5
  19. huggingface_hub/inference/_generated/types/text_generation.py +29 -0
  20. huggingface_hub/lfs.py +11 -6
  21. huggingface_hub/repocard_data.py +3 -3
  22. huggingface_hub/repository.py +6 -6
  23. huggingface_hub/serialization/__init__.py +8 -3
  24. huggingface_hub/serialization/_base.py +13 -16
  25. huggingface_hub/serialization/_tensorflow.py +4 -3
  26. huggingface_hub/serialization/_torch.py +399 -22
  27. huggingface_hub/utils/__init__.py +0 -1
  28. huggingface_hub/utils/_errors.py +1 -1
  29. huggingface_hub/utils/_fixes.py +14 -3
  30. huggingface_hub/utils/_paths.py +17 -6
  31. huggingface_hub/utils/_subprocess.py +0 -1
  32. huggingface_hub/utils/_telemetry.py +9 -1
  33. huggingface_hub/utils/endpoint_helpers.py +2 -186
  34. huggingface_hub/utils/sha.py +36 -1
  35. huggingface_hub/utils/tqdm.py +0 -1
  36. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.dist-info}/METADATA +12 -9
  37. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.dist-info}/RECORD +41 -41
  38. huggingface_hub/serialization/_numpy.py +0 -68
  39. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.dist-info}/LICENSE +0 -0
  40. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.dist-info}/WHEEL +0 -0
  41. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.dist-info}/entry_points.txt +0 -0
  42. {huggingface_hub-0.23.5.dist-info → huggingface_hub-0.24.1.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
- Authentication token, obtained with [`HfApi.login`] method. Will default to the stored token.
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: Optional[str] = None,
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
+ )