huggingface-hub 0.13.3__tar.gz → 0.13.4__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 (63) hide show
  1. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/PKG-INFO +1 -1
  2. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/__init__.py +1 -1
  3. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/_login.py +2 -4
  4. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/file_download.py +29 -3
  5. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
  6. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/LICENSE +0 -0
  7. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/MANIFEST.in +0 -0
  8. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/README.md +0 -0
  9. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/pyproject.toml +0 -0
  10. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/setup.cfg +0 -0
  11. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/setup.py +0 -0
  12. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/_commit_api.py +0 -0
  13. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/_snapshot_download.py +0 -0
  14. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/_space_api.py +0 -0
  15. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/__init__.py +0 -0
  16. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/_cli_utils.py +0 -0
  17. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/delete_cache.py +0 -0
  18. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/env.py +0 -0
  19. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
  20. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/lfs.py +0 -0
  21. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/scan_cache.py +0 -0
  22. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/commands/user.py +0 -0
  23. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/community.py +0 -0
  24. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/constants.py +0 -0
  25. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/fastai_utils.py +0 -0
  26. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/hf_api.py +0 -0
  27. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/hub_mixin.py +0 -0
  28. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/inference_api.py +0 -0
  29. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/keras_mixin.py +0 -0
  30. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/lfs.py +0 -0
  31. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/repocard.py +0 -0
  32. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/repocard_data.py +0 -0
  33. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/repository.py +0 -0
  34. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
  35. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/templates/modelcard_template.md +0 -0
  36. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/__init__.py +0 -0
  37. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_cache_assets.py +0 -0
  38. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_cache_manager.py +0 -0
  39. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
  40. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_datetime.py +0 -0
  41. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_deprecation.py +0 -0
  42. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_errors.py +0 -0
  43. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_fixes.py +0 -0
  44. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_git_credential.py +0 -0
  45. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_headers.py +0 -0
  46. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_hf_folder.py +0 -0
  47. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_http.py +0 -0
  48. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_pagination.py +0 -0
  49. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_paths.py +0 -0
  50. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_runtime.py +0 -0
  51. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_subprocess.py +0 -0
  52. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_telemetry.py +0 -0
  53. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_typing.py +0 -0
  54. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/_validators.py +0 -0
  55. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
  56. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/logging.py +0 -0
  57. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/sha.py +0 -0
  58. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub/utils/tqdm.py +0 -0
  59. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub.egg-info/SOURCES.txt +0 -0
  60. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
  61. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
  62. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/src/huggingface_hub.egg-info/requires.txt +0 -0
  63. {huggingface_hub-0.13.3 → huggingface_hub-0.13.4}/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.13.3
3
+ Version: 0.13.4
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.13.3"
49
+ __version__ = "0.13.4"
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
@@ -121,15 +121,13 @@ def interpreter_login() -> None:
121
121
 
122
122
  For more details, see [`login`].
123
123
  """
124
- print( # docstyle-ignore
125
- """
124
+ print("""
126
125
  _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
127
126
  _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
128
127
  _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
129
128
  _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
130
129
  _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
131
- """
132
- )
130
+ """) # docstyle-ignore
133
131
  if HfFolder.get_token() is not None:
134
132
  print(
135
133
  " A token is already saved on your machine. Run `huggingface-cli"
@@ -1132,11 +1132,17 @@ def hf_hub_download(
1132
1132
 
1133
1133
  # cross platform transcription of filename, to be used as a local file path.
1134
1134
  relative_filename = os.path.join(*filename.split("/"))
1135
+ if os.name == "nt":
1136
+ if relative_filename.startswith("..\\") or "\\..\\" in relative_filename:
1137
+ raise ValueError(
1138
+ f"Invalid filename: cannot handle filename '{relative_filename}' on Windows. Please ask the repository"
1139
+ " owner to rename this file."
1140
+ )
1135
1141
 
1136
1142
  # if user provides a commit_hash and they already have the file on disk,
1137
1143
  # shortcut everything.
1138
1144
  if REGEX_COMMIT_HASH.match(revision):
1139
- pointer_path = os.path.join(storage_folder, "snapshots", revision, relative_filename)
1145
+ pointer_path = _get_pointer_path(storage_folder, revision, relative_filename)
1140
1146
  if os.path.exists(pointer_path):
1141
1147
  if local_dir is not None:
1142
1148
  return _to_local_dir(pointer_path, local_dir, relative_filename, use_symlinks=local_dir_use_symlinks)
@@ -1231,7 +1237,7 @@ def hf_hub_download(
1231
1237
 
1232
1238
  # Return pointer file if exists
1233
1239
  if commit_hash is not None:
1234
- pointer_path = os.path.join(storage_folder, "snapshots", commit_hash, relative_filename)
1240
+ pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
1235
1241
  if os.path.exists(pointer_path):
1236
1242
  if local_dir is not None:
1237
1243
  return _to_local_dir(
@@ -1260,7 +1266,7 @@ def hf_hub_download(
1260
1266
  assert etag is not None, "etag must have been retrieved from server"
1261
1267
  assert commit_hash is not None, "commit_hash must have been retrieved from server"
1262
1268
  blob_path = os.path.join(storage_folder, "blobs", etag)
1263
- pointer_path = os.path.join(storage_folder, "snapshots", commit_hash, relative_filename)
1269
+ pointer_path = _get_pointer_path(storage_folder, commit_hash, relative_filename)
1264
1270
 
1265
1271
  os.makedirs(os.path.dirname(blob_path), exist_ok=True)
1266
1272
  os.makedirs(os.path.dirname(pointer_path), exist_ok=True)
@@ -1549,6 +1555,19 @@ def _chmod_and_replace(src: str, dst: str) -> None:
1549
1555
  os.replace(src, dst)
1550
1556
 
1551
1557
 
1558
+ def _get_pointer_path(storage_folder: str, revision: str, relative_filename: str) -> str:
1559
+ # Using `os.path.abspath` instead of `Path.resolve()` to avoid resolving symlinks
1560
+ snapshot_path = os.path.join(storage_folder, "snapshots")
1561
+ pointer_path = os.path.join(snapshot_path, revision, relative_filename)
1562
+ if Path(os.path.abspath(snapshot_path)) not in Path(os.path.abspath(pointer_path)).parents:
1563
+ raise ValueError(
1564
+ "Invalid pointer path: cannot create pointer path in snapshot folder if"
1565
+ f" `storage_folder='{storage_folder}'`, `revision='{revision}'` and"
1566
+ f" `relative_filename='{relative_filename}'`."
1567
+ )
1568
+ return pointer_path
1569
+
1570
+
1552
1571
  def _to_local_dir(
1553
1572
  path: str, local_dir: str, relative_filename: str, use_symlinks: Union[bool, Literal["auto"]]
1554
1573
  ) -> str:
@@ -1556,7 +1575,14 @@ def _to_local_dir(
1556
1575
 
1557
1576
  Either symlink to blob file in cache or duplicate file depending on `use_symlinks` and file size.
1558
1577
  """
1578
+ # Using `os.path.abspath` instead of `Path.resolve()` to avoid resolving symlinks
1559
1579
  local_dir_filepath = os.path.join(local_dir, relative_filename)
1580
+ if Path(os.path.abspath(local_dir)) not in Path(os.path.abspath(local_dir_filepath)).parents:
1581
+ raise ValueError(
1582
+ f"Cannot copy file '{relative_filename}' to local dir '{local_dir}': file would not be in the local"
1583
+ " directory."
1584
+ )
1585
+
1560
1586
  os.makedirs(os.path.dirname(local_dir_filepath), exist_ok=True)
1561
1587
  real_blob_path = os.path.realpath(path)
1562
1588
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: huggingface-hub
3
- Version: 0.13.3
3
+ Version: 0.13.4
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.