huggingface-hub 0.23.0rc1__tar.gz → 0.23.2__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.

Files changed (122) hide show
  1. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/PKG-INFO +1 -1
  2. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/__init__.py +1 -1
  3. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/hf_file_system.py +6 -0
  4. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/serialization/_base.py +46 -2
  5. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/serialization/_numpy.py +2 -2
  6. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/serialization/_tensorflow.py +2 -2
  7. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/serialization/_torch.py +3 -3
  8. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
  9. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/LICENSE +0 -0
  10. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/MANIFEST.in +0 -0
  11. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/README.md +0 -0
  12. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/pyproject.toml +0 -0
  13. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/setup.cfg +0 -0
  14. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/setup.py +0 -0
  15. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_commit_api.py +0 -0
  16. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_commit_scheduler.py +0 -0
  17. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_inference_endpoints.py +0 -0
  18. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_local_folder.py +0 -0
  19. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_login.py +0 -0
  20. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_multi_commits.py +0 -0
  21. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_snapshot_download.py +0 -0
  22. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_space_api.py +0 -0
  23. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_tensorboard_logger.py +0 -0
  24. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_webhooks_payload.py +0 -0
  25. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/_webhooks_server.py +0 -0
  26. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/__init__.py +0 -0
  27. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/_cli_utils.py +0 -0
  28. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/delete_cache.py +0 -0
  29. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/download.py +0 -0
  30. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/env.py +0 -0
  31. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
  32. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/lfs.py +0 -0
  33. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/scan_cache.py +0 -0
  34. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/tag.py +0 -0
  35. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/upload.py +0 -0
  36. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/commands/user.py +0 -0
  37. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/community.py +0 -0
  38. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/constants.py +0 -0
  39. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/errors.py +0 -0
  40. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/fastai_utils.py +0 -0
  41. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/file_download.py +0 -0
  42. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/hf_api.py +0 -0
  43. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/hub_mixin.py +0 -0
  44. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/__init__.py +0 -0
  45. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_client.py +0 -0
  46. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_common.py +0 -0
  47. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
  48. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/_async_client.py +0 -0
  49. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
  50. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
  51. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
  52. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
  53. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
  54. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
  55. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
  56. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
  57. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
  58. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
  59. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
  60. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
  61. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/image_to_image.py +0 -0
  62. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
  63. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
  64. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
  65. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
  66. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
  67. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
  68. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
  69. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
  70. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
  71. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
  72. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
  73. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
  74. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
  75. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
  76. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
  77. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
  78. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
  79. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
  80. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_templating.py +0 -0
  81. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference/_types.py +0 -0
  82. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/inference_api.py +0 -0
  83. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/keras_mixin.py +0 -0
  84. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/lfs.py +0 -0
  85. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/repocard.py +0 -0
  86. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/repocard_data.py +0 -0
  87. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/repository.py +0 -0
  88. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/serialization/__init__.py +0 -0
  89. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
  90. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/templates/modelcard_template.md +0 -0
  91. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/__init__.py +0 -0
  92. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_cache_assets.py +0 -0
  93. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_cache_manager.py +0 -0
  94. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
  95. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_datetime.py +0 -0
  96. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_deprecation.py +0 -0
  97. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_errors.py +0 -0
  98. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_experimental.py +0 -0
  99. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_fixes.py +0 -0
  100. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_git_credential.py +0 -0
  101. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_headers.py +0 -0
  102. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_hf_folder.py +0 -0
  103. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_http.py +0 -0
  104. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_pagination.py +0 -0
  105. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_paths.py +0 -0
  106. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_runtime.py +0 -0
  107. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_safetensors.py +0 -0
  108. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_subprocess.py +0 -0
  109. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_telemetry.py +0 -0
  110. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_token.py +0 -0
  111. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_typing.py +0 -0
  112. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/_validators.py +0 -0
  113. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
  114. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
  115. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/logging.py +0 -0
  116. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/sha.py +0 -0
  117. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub/utils/tqdm.py +0 -0
  118. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub.egg-info/SOURCES.txt +0 -0
  119. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
  120. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
  121. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/src/huggingface_hub.egg-info/requires.txt +0 -0
  122. {huggingface_hub-0.23.0rc1 → huggingface_hub-0.23.2}/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.23.0rc1
3
+ Version: 0.23.2
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.
@@ -46,7 +46,7 @@ import sys
46
46
  from typing import TYPE_CHECKING
47
47
 
48
48
 
49
- __version__ = "0.23.0.rc1"
49
+ __version__ = "0.23.2"
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
@@ -517,6 +517,9 @@ class HfFileSystem(fsspec.AbstractFileSystem):
517
517
  else:
518
518
  out = None
519
519
  parent_path = self._parent(path)
520
+ if not expand_info and parent_path not in self.dircache:
521
+ # Fill the cache with cheap call
522
+ self.ls(parent_path, expand_info=False)
520
523
  if parent_path in self.dircache:
521
524
  # Check if the path is in the cache
522
525
  out1 = [o for o in self.dircache[parent_path] if o["name"] == path]
@@ -681,6 +684,9 @@ class HfFileSystemFile(fsspec.spec.AbstractBufferedFile):
681
684
  f"{e}.\nMake sure the repository and revision exist before writing data."
682
685
  ) from e
683
686
  raise
687
+ # avoid an unnecessary .info() call with expensive expand_info=True to instantiate .details
688
+ if kwargs.get("mode", "rb") == "rb":
689
+ self.details = fs.info(self.resolved_path.unresolve(), expand_info=False)
684
690
  super().__init__(fs, self.resolved_path.unresolve(), **kwargs)
685
691
  self.fs: HfFileSystem
686
692
 
@@ -14,7 +14,7 @@
14
14
  """Contains helpers to split tensors into shards."""
15
15
 
16
16
  from dataclasses import dataclass, field
17
- from typing import Any, Callable, Dict, List, Optional, TypeVar
17
+ from typing import Any, Callable, Dict, List, Optional, TypeVar, Union
18
18
 
19
19
  from .. import logging
20
20
 
@@ -46,7 +46,7 @@ def split_state_dict_into_shards_factory(
46
46
  get_tensor_size: TensorSizeFn_T,
47
47
  get_storage_id: StorageIDFn_T = lambda tensor: None,
48
48
  filename_pattern: str = FILENAME_PATTERN,
49
- max_shard_size: int = MAX_SHARD_SIZE,
49
+ max_shard_size: Union[int, str] = MAX_SHARD_SIZE,
50
50
  ) -> StateDictSplit:
51
51
  """
52
52
  Split a model state dictionary in shards so that each shard is smaller than a given size.
@@ -89,6 +89,9 @@ def split_state_dict_into_shards_factory(
89
89
  current_shard_size = 0
90
90
  total_size = 0
91
91
 
92
+ if isinstance(max_shard_size, str):
93
+ max_shard_size = parse_size_to_int(max_shard_size)
94
+
92
95
  for key, tensor in state_dict.items():
93
96
  # when bnb serialization is used the weights in the state dict can be strings
94
97
  # check: https://github.com/huggingface/transformers/pull/24416 for more details
@@ -167,3 +170,44 @@ def split_state_dict_into_shards_factory(
167
170
  filename_to_tensors=filename_to_tensors,
168
171
  tensor_to_filename=tensor_name_to_filename,
169
172
  )
173
+
174
+
175
+ SIZE_UNITS = {
176
+ "TB": 10**12,
177
+ "GB": 10**9,
178
+ "MB": 10**6,
179
+ "KB": 10**3,
180
+ }
181
+
182
+
183
+ def parse_size_to_int(size_as_str: str) -> int:
184
+ """
185
+ Parse a size expressed as a string with digits and unit (like `"5MB"`) to an integer (in bytes).
186
+
187
+ Supported units are "TB", "GB", "MB", "KB".
188
+
189
+ Args:
190
+ size_as_str (`str`): The size to convert. Will be directly returned if an `int`.
191
+
192
+ Example:
193
+
194
+ ```py
195
+ >>> parse_size_to_int("5MB")
196
+ 5000000
197
+ ```
198
+ """
199
+ size_as_str = size_as_str.strip()
200
+
201
+ # Parse unit
202
+ unit = size_as_str[-2:].upper()
203
+ if unit not in SIZE_UNITS:
204
+ raise ValueError(f"Unit '{unit}' not supported. Supported units are TB, GB, MB, KB. Got '{size_as_str}'.")
205
+ multiplier = SIZE_UNITS[unit]
206
+
207
+ # Parse value
208
+ try:
209
+ value = float(size_as_str[:-2].strip())
210
+ except ValueError as e:
211
+ raise ValueError(f"Could not parse the size value from '{size_as_str}': {e}") from e
212
+
213
+ return int(value * multiplier)
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  """Contains numpy-specific helpers."""
15
15
 
16
- from typing import TYPE_CHECKING, Dict
16
+ from typing import TYPE_CHECKING, Dict, Union
17
17
 
18
18
  from ._base import FILENAME_PATTERN, MAX_SHARD_SIZE, StateDictSplit, split_state_dict_into_shards_factory
19
19
 
@@ -26,7 +26,7 @@ def split_numpy_state_dict_into_shards(
26
26
  state_dict: Dict[str, "np.ndarray"],
27
27
  *,
28
28
  filename_pattern: str = FILENAME_PATTERN,
29
- max_shard_size: int = MAX_SHARD_SIZE,
29
+ max_shard_size: Union[int, str] = MAX_SHARD_SIZE,
30
30
  ) -> StateDictSplit:
31
31
  """
32
32
  Split a model state dictionary in shards so that each shard is smaller than a given size.
@@ -15,7 +15,7 @@
15
15
 
16
16
  import math
17
17
  import re
18
- from typing import TYPE_CHECKING, Dict
18
+ from typing import TYPE_CHECKING, Dict, Union
19
19
 
20
20
  from ._base import MAX_SHARD_SIZE, StateDictSplit, split_state_dict_into_shards_factory
21
21
 
@@ -28,7 +28,7 @@ def split_tf_state_dict_into_shards(
28
28
  state_dict: Dict[str, "tf.Tensor"],
29
29
  *,
30
30
  filename_pattern: str = "tf_model{suffix}.h5",
31
- max_shard_size: int = MAX_SHARD_SIZE,
31
+ max_shard_size: Union[int, str] = MAX_SHARD_SIZE,
32
32
  ) -> StateDictSplit:
33
33
  """
34
34
  Split a model state dictionary in shards so that each shard is smaller than a given size.
@@ -15,7 +15,7 @@
15
15
 
16
16
  import importlib
17
17
  from functools import lru_cache
18
- from typing import TYPE_CHECKING, Dict, Tuple
18
+ from typing import TYPE_CHECKING, Dict, Tuple, Union
19
19
 
20
20
  from ._base import FILENAME_PATTERN, MAX_SHARD_SIZE, StateDictSplit, split_state_dict_into_shards_factory
21
21
 
@@ -28,7 +28,7 @@ def split_torch_state_dict_into_shards(
28
28
  state_dict: Dict[str, "torch.Tensor"],
29
29
  *,
30
30
  filename_pattern: str = FILENAME_PATTERN,
31
- max_shard_size: int = MAX_SHARD_SIZE,
31
+ max_shard_size: Union[int, str] = MAX_SHARD_SIZE,
32
32
  ) -> StateDictSplit:
33
33
  """
34
34
  Split a model state dictionary in shards so that each shard is smaller than a given size.
@@ -67,7 +67,7 @@ def split_torch_state_dict_into_shards(
67
67
 
68
68
  >>> def save_state_dict(state_dict: Dict[str, torch.Tensor], save_directory: str):
69
69
  ... state_dict_split = split_torch_state_dict_into_shards(state_dict)
70
- ... for filename, tensors in state_dict_split.filename_to_tensors.values():
70
+ ... for filename, tensors in state_dict_split.filename_to_tensors.items():
71
71
  ... shard = {tensor: state_dict[tensor] for tensor in tensors}
72
72
  ... safe_save_file(
73
73
  ... shard,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: huggingface-hub
3
- Version: 0.23.0rc1
3
+ Version: 0.23.2
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.