huggingface-hub 0.22.1__tar.gz → 0.22.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 (120) hide show
  1. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/PKG-INFO +1 -1
  2. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/__init__.py +1 -1
  3. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_commit_api.py +1 -1
  4. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/hf_api.py +2 -7
  5. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/lfs.py +7 -3
  6. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/__init__.py +8 -1
  7. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_http.py +14 -1
  8. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
  9. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/LICENSE +0 -0
  10. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/MANIFEST.in +0 -0
  11. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/README.md +0 -0
  12. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/pyproject.toml +0 -0
  13. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/setup.cfg +0 -0
  14. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/setup.py +0 -0
  15. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_commit_scheduler.py +0 -0
  16. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_inference_endpoints.py +0 -0
  17. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_login.py +0 -0
  18. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_multi_commits.py +0 -0
  19. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_snapshot_download.py +0 -0
  20. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_space_api.py +0 -0
  21. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_tensorboard_logger.py +0 -0
  22. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_webhooks_payload.py +0 -0
  23. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/_webhooks_server.py +0 -0
  24. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/__init__.py +0 -0
  25. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/_cli_utils.py +0 -0
  26. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/delete_cache.py +0 -0
  27. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/download.py +0 -0
  28. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/env.py +0 -0
  29. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
  30. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/lfs.py +0 -0
  31. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/scan_cache.py +0 -0
  32. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/upload.py +0 -0
  33. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/commands/user.py +0 -0
  34. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/community.py +0 -0
  35. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/constants.py +0 -0
  36. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/errors.py +0 -0
  37. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/fastai_utils.py +0 -0
  38. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/file_download.py +0 -0
  39. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/hf_file_system.py +0 -0
  40. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/hub_mixin.py +0 -0
  41. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/__init__.py +0 -0
  42. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_client.py +0 -0
  43. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_common.py +0 -0
  44. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
  45. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/_async_client.py +0 -0
  46. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
  47. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
  48. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
  49. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
  50. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
  51. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
  52. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
  53. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
  54. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
  55. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
  56. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
  57. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
  58. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/image_to_image.py +0 -0
  59. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
  60. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
  61. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
  62. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
  63. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
  64. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
  65. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
  66. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
  67. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
  68. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
  69. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
  70. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
  71. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
  72. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
  73. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
  74. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
  75. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
  76. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
  77. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_templating.py +0 -0
  78. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference/_types.py +0 -0
  79. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/inference_api.py +0 -0
  80. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/keras_mixin.py +0 -0
  81. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/repocard.py +0 -0
  82. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/repocard_data.py +0 -0
  83. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/repository.py +0 -0
  84. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/serialization/__init__.py +0 -0
  85. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/serialization/_base.py +0 -0
  86. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/serialization/_numpy.py +0 -0
  87. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/serialization/_tensorflow.py +0 -0
  88. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/serialization/_torch.py +0 -0
  89. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
  90. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/templates/modelcard_template.md +0 -0
  91. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_cache_assets.py +0 -0
  92. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_cache_manager.py +0 -0
  93. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
  94. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_datetime.py +0 -0
  95. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_deprecation.py +0 -0
  96. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_errors.py +0 -0
  97. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_experimental.py +0 -0
  98. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_fixes.py +0 -0
  99. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_git_credential.py +0 -0
  100. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_headers.py +0 -0
  101. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_hf_folder.py +0 -0
  102. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_pagination.py +0 -0
  103. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_paths.py +0 -0
  104. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_runtime.py +0 -0
  105. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_safetensors.py +0 -0
  106. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_subprocess.py +0 -0
  107. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_telemetry.py +0 -0
  108. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_token.py +0 -0
  109. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_typing.py +0 -0
  110. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/_validators.py +0 -0
  111. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
  112. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
  113. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/logging.py +0 -0
  114. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/sha.py +0 -0
  115. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub/utils/tqdm.py +0 -0
  116. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub.egg-info/SOURCES.txt +0 -0
  117. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
  118. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
  119. {huggingface_hub-0.22.1 → huggingface_hub-0.22.2}/src/huggingface_hub.egg-info/requires.txt +0 -0
  120. {huggingface_hub-0.22.1 → huggingface_hub-0.22.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.22.1
3
+ Version: 0.22.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.22.1"
49
+ __version__ = "0.22.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
@@ -399,7 +399,7 @@ def _upload_lfs_files(
399
399
  def _wrapped_lfs_upload(batch_action) -> None:
400
400
  try:
401
401
  operation = oid2addop[batch_action["oid"]]
402
- lfs_upload(operation=operation, lfs_batch_action=batch_action, headers=headers)
402
+ lfs_upload(operation=operation, lfs_batch_action=batch_action, headers=headers, endpoint=endpoint)
403
403
  except Exception as exc:
404
404
  raise RuntimeError(f"Error while uploading '{operation.path_in_repo}' to the Hub.") from exc
405
405
 
@@ -82,8 +82,6 @@ from .community import (
82
82
  deserialize_event,
83
83
  )
84
84
  from .constants import (
85
- _HF_DEFAULT_ENDPOINT,
86
- _HF_DEFAULT_STAGING_ENDPOINT,
87
85
  DEFAULT_ETAG_TIMEOUT,
88
86
  DEFAULT_REQUEST_TIMEOUT,
89
87
  DEFAULT_REVISION,
@@ -123,6 +121,7 @@ from .utils import ( # noqa: F401 # imported for backward compatibility
123
121
  build_hf_headers,
124
122
  experimental,
125
123
  filter_repo_objects,
124
+ fix_hf_endpoint_in_url,
126
125
  get_session,
127
126
  hf_raise_for_status,
128
127
  logging,
@@ -185,11 +184,6 @@ def repo_type_and_id_from_hf_id(hf_id: str, hub_url: Optional[str] = None) -> Tu
185
184
  """
186
185
  input_hf_id = hf_id
187
186
 
188
- # check if a proxy has been set => if yes, update the returned URL to use the proxy
189
- if ENDPOINT not in (_HF_DEFAULT_ENDPOINT, _HF_DEFAULT_STAGING_ENDPOINT):
190
- hf_id = hf_id.replace(_HF_DEFAULT_ENDPOINT, ENDPOINT)
191
- hf_id = hf_id.replace(_HF_DEFAULT_STAGING_ENDPOINT, ENDPOINT)
192
-
193
187
  hub_url = re.sub(r"https?://", "", hub_url if hub_url is not None else ENDPOINT)
194
188
  is_hf_url = hub_url in hf_id and "@" not in hf_id
195
189
 
@@ -436,6 +430,7 @@ class RepoUrl(str):
436
430
  """
437
431
 
438
432
  def __new__(cls, url: Any, endpoint: Optional[str] = None):
433
+ url = fix_hf_endpoint_in_url(url, endpoint=endpoint)
439
434
  return super(RepoUrl, cls).__new__(cls, url)
440
435
 
441
436
  def __init__(self, url: Any, endpoint: Optional[str] = None) -> None:
@@ -31,6 +31,7 @@ from huggingface_hub.constants import ENDPOINT, HF_HUB_ENABLE_HF_TRANSFER, REPO_
31
31
 
32
32
  from .utils import (
33
33
  build_hf_headers,
34
+ fix_hf_endpoint_in_url,
34
35
  get_session,
35
36
  hf_raise_for_status,
36
37
  http_backoff,
@@ -193,6 +194,7 @@ def lfs_upload(
193
194
  lfs_batch_action: Dict,
194
195
  token: Optional[str] = None,
195
196
  headers: Optional[Dict[str, str]] = None,
197
+ endpoint: Optional[str] = None,
196
198
  ) -> None:
197
199
  """
198
200
  Handles uploading a given object to the Hub with the LFS protocol.
@@ -230,6 +232,7 @@ def lfs_upload(
230
232
  # 2. Upload file (either single part or multi-part)
231
233
  header = upload_action.get("header", {})
232
234
  chunk_size = header.get("chunk_size")
235
+ upload_url = fix_hf_endpoint_in_url(upload_action["href"], endpoint=endpoint)
233
236
  if chunk_size is not None:
234
237
  try:
235
238
  chunk_size = int(chunk_size)
@@ -237,15 +240,16 @@ def lfs_upload(
237
240
  raise ValueError(
238
241
  f"Malformed response from LFS batch endpoint: `chunk_size` should be an integer. Got '{chunk_size}'."
239
242
  )
240
- _upload_multi_part(operation=operation, header=header, chunk_size=chunk_size, upload_url=upload_action["href"])
243
+ _upload_multi_part(operation=operation, header=header, chunk_size=chunk_size, upload_url=upload_url)
241
244
  else:
242
- _upload_single_part(operation=operation, upload_url=upload_action["href"])
245
+ _upload_single_part(operation=operation, upload_url=upload_url)
243
246
 
244
247
  # 3. Verify upload went well
245
248
  if verify_action is not None:
246
249
  _validate_lfs_action(verify_action)
250
+ verify_url = fix_hf_endpoint_in_url(verify_action["href"], endpoint)
247
251
  verify_resp = get_session().post(
248
- verify_action["href"],
252
+ verify_url,
249
253
  headers=build_hf_headers(token=token, headers=headers),
250
254
  json={"oid": operation.upload_info.sha256.hex(), "size": operation.upload_info.size},
251
255
  )
@@ -47,7 +47,14 @@ from ._fixes import SoftTemporaryDirectory, WeakFileLock, yaml_dump
47
47
  from ._git_credential import list_credential_helpers, set_git_credential, unset_git_credential
48
48
  from ._headers import LocalTokenNotFoundError, build_hf_headers, get_token_to_send
49
49
  from ._hf_folder import HfFolder
50
- from ._http import OfflineModeIsEnabled, configure_http_backend, get_session, http_backoff, reset_sessions
50
+ from ._http import (
51
+ OfflineModeIsEnabled,
52
+ configure_http_backend,
53
+ fix_hf_endpoint_in_url,
54
+ get_session,
55
+ http_backoff,
56
+ reset_sessions,
57
+ )
51
58
  from ._pagination import paginate
52
59
  from ._paths import IGNORE_GIT_FOLDER_PATTERNS, filter_repo_objects
53
60
  from ._runtime import (
@@ -21,7 +21,7 @@ import time
21
21
  import uuid
22
22
  from functools import lru_cache
23
23
  from http import HTTPStatus
24
- from typing import Callable, Tuple, Type, Union
24
+ from typing import Callable, Optional, Tuple, Type, Union
25
25
 
26
26
  import requests
27
27
  from requests import Response
@@ -306,3 +306,16 @@ def http_backoff(
306
306
 
307
307
  # Update sleep time for next retry
308
308
  sleep_time = min(max_wait_time, sleep_time * 2) # Exponential backoff
309
+
310
+
311
+ def fix_hf_endpoint_in_url(url: str, endpoint: Optional[str]) -> str:
312
+ """Replace the default endpoint in a URL by a custom one.
313
+
314
+ This is useful when using a proxy and the Hugging Face Hub returns a URL with the default endpoint.
315
+ """
316
+ endpoint = endpoint or constants.ENDPOINT
317
+ # check if a proxy has been set => if yes, update the returned URL to use the proxy
318
+ if endpoint not in (None, constants._HF_DEFAULT_ENDPOINT, constants._HF_DEFAULT_STAGING_ENDPOINT):
319
+ url = url.replace(constants._HF_DEFAULT_ENDPOINT, endpoint)
320
+ url = url.replace(constants._HF_DEFAULT_STAGING_ENDPOINT, endpoint)
321
+ return url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: huggingface-hub
3
- Version: 0.22.1
3
+ Version: 0.22.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.