huggingface-hub 1.0.0rc2__tar.gz → 1.0.0rc4__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 (172) hide show
  1. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/PKG-INFO +1 -1
  2. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/setup.py +0 -1
  3. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/__init__.py +4 -7
  4. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_login.py +2 -2
  5. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_snapshot_download.py +119 -21
  6. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_upload_large_folder.py +1 -2
  7. huggingface_hub-1.0.0rc4/src/huggingface_hub/cli/_cli_utils.py +170 -0
  8. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/auth.py +2 -2
  9. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/cache.py +2 -2
  10. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/download.py +31 -6
  11. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/hf.py +2 -1
  12. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/repo.py +1 -2
  13. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/upload_large_folder.py +2 -2
  14. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/constants.py +4 -0
  15. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/dataclasses.py +132 -3
  16. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/errors.py +4 -0
  17. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/file_download.py +216 -17
  18. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/hf_api.py +127 -14
  19. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/hf_file_system.py +38 -21
  20. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_client.py +3 -2
  21. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/_async_client.py +3 -2
  22. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/image_to_image.py +6 -2
  23. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/mcp_client.py +4 -3
  24. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/__init__.py +5 -0
  25. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/_common.py +1 -0
  26. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/fal_ai.py +2 -0
  27. huggingface_hub-1.0.0rc4/src/huggingface_hub/inference/_providers/zai_org.py +17 -0
  28. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/__init__.py +3 -2
  29. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_cache_manager.py +1 -1
  30. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_http.py +12 -40
  31. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_runtime.py +48 -1
  32. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/_cli_utils.py → huggingface_hub-1.0.0rc4/src/huggingface_hub/utils/_terminal.py +2 -7
  33. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_validators.py +2 -2
  34. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
  35. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub.egg-info/SOURCES.txt +2 -15
  36. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub.egg-info/entry_points.txt +0 -1
  37. huggingface_hub-1.0.0rc2/src/huggingface_hub/cli/_cli_utils.py +0 -146
  38. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/__init__.py +0 -27
  39. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/delete_cache.py +0 -476
  40. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/download.py +0 -195
  41. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/env.py +0 -39
  42. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/huggingface_cli.py +0 -65
  43. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/lfs.py +0 -200
  44. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/repo.py +0 -151
  45. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/repo_files.py +0 -132
  46. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/scan_cache.py +0 -183
  47. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/tag.py +0 -159
  48. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/upload.py +0 -318
  49. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/upload_large_folder.py +0 -131
  50. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/user.py +0 -207
  51. huggingface_hub-1.0.0rc2/src/huggingface_hub/commands/version.py +0 -40
  52. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/LICENSE +0 -0
  53. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/MANIFEST.in +0 -0
  54. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/README.md +0 -0
  55. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/pyproject.toml +0 -0
  56. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/setup.cfg +0 -0
  57. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_commit_api.py +0 -0
  58. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_commit_scheduler.py +0 -0
  59. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_inference_endpoints.py +0 -0
  60. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_jobs_api.py +0 -0
  61. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_local_folder.py +0 -0
  62. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_oauth.py +0 -0
  63. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_space_api.py +0 -0
  64. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_tensorboard_logger.py +0 -0
  65. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_webhooks_payload.py +0 -0
  66. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/_webhooks_server.py +0 -0
  67. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/__init__.py +0 -0
  68. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/jobs.py +0 -0
  69. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/lfs.py +0 -0
  70. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/repo_files.py +0 -0
  71. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/system.py +0 -0
  72. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/cli/upload.py +0 -0
  73. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/community.py +0 -0
  74. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/fastai_utils.py +0 -0
  75. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/hub_mixin.py +0 -0
  76. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/__init__.py +0 -0
  77. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_common.py +0 -0
  78. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
  79. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
  80. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
  81. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
  82. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
  83. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
  84. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
  85. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
  86. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
  87. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
  88. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
  89. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
  90. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
  91. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
  92. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/image_to_video.py +0 -0
  93. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
  94. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
  95. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
  96. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
  97. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
  98. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
  99. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
  100. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
  101. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
  102. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
  103. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_to_speech.py +0 -0
  104. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/text_to_video.py +0 -0
  105. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
  106. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
  107. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
  108. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
  109. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
  110. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
  111. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
  112. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/__init__.py +0 -0
  113. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/_cli_hacks.py +0 -0
  114. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/agent.py +0 -0
  115. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/cli.py +0 -0
  116. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/constants.py +0 -0
  117. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/types.py +0 -0
  118. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_mcp/utils.py +0 -0
  119. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/black_forest_labs.py +0 -0
  120. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/cerebras.py +0 -0
  121. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/cohere.py +0 -0
  122. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/featherless_ai.py +0 -0
  123. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/fireworks_ai.py +0 -0
  124. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/groq.py +0 -0
  125. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/hf_inference.py +0 -0
  126. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/hyperbolic.py +0 -0
  127. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/nebius.py +0 -0
  128. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/novita.py +0 -0
  129. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/nscale.py +0 -0
  130. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/openai.py +0 -0
  131. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/publicai.py +0 -0
  132. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/replicate.py +0 -0
  133. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/sambanova.py +0 -0
  134. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/scaleway.py +0 -0
  135. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/inference/_providers/together.py +0 -0
  136. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/lfs.py +0 -0
  137. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/py.typed +0 -0
  138. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/repocard.py +0 -0
  139. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/repocard_data.py +0 -0
  140. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/serialization/__init__.py +0 -0
  141. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/serialization/_base.py +0 -0
  142. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/serialization/_dduf.py +0 -0
  143. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/serialization/_torch.py +0 -0
  144. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
  145. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/templates/modelcard_template.md +0 -0
  146. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_auth.py +0 -0
  147. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_cache_assets.py +0 -0
  148. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
  149. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_datetime.py +0 -0
  150. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_deprecation.py +0 -0
  151. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_dotenv.py +0 -0
  152. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_experimental.py +0 -0
  153. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_fixes.py +0 -0
  154. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_git_credential.py +0 -0
  155. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_headers.py +0 -0
  156. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_lfs.py +0 -0
  157. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_pagination.py +0 -0
  158. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_paths.py +0 -0
  159. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_safetensors.py +0 -0
  160. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_subprocess.py +0 -0
  161. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_telemetry.py +0 -0
  162. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_typing.py +0 -0
  163. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_xet.py +0 -0
  164. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/_xet_progress_reporting.py +0 -0
  165. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
  166. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
  167. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/logging.py +0 -0
  168. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/sha.py +0 -0
  169. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub/utils/tqdm.py +0 -0
  170. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
  171. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/src/huggingface_hub.egg-info/requires.txt +0 -0
  172. {huggingface_hub-1.0.0rc2 → huggingface_hub-1.0.0rc4}/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: 1.0.0rc2
3
+ Version: 1.0.0rc4
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.
@@ -131,7 +131,6 @@ setup(
131
131
  extras_require=extras,
132
132
  entry_points={
133
133
  "console_scripts": [
134
- "huggingface-cli=huggingface_hub.commands.huggingface_cli:main",
135
134
  "hf=huggingface_hub.cli.hf:main",
136
135
  "tiny-agents=huggingface_hub.inference._mcp.cli:app",
137
136
  ],
@@ -46,7 +46,7 @@ import sys
46
46
  from typing import TYPE_CHECKING
47
47
 
48
48
 
49
- __version__ = "1.0.0.rc2"
49
+ __version__ = "1.0.0.rc4"
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
@@ -138,6 +138,7 @@ _SUBMOD_ATTRS = {
138
138
  "push_to_hub_fastai",
139
139
  ],
140
140
  "file_download": [
141
+ "DryRunFileInfo",
141
142
  "HfFileMetadata",
142
143
  "_CACHED_NO_EXIST",
143
144
  "get_hf_file_metadata",
@@ -513,8 +514,6 @@ _SUBMOD_ATTRS = {
513
514
  "CorruptedCacheException",
514
515
  "DeleteCacheStrategy",
515
516
  "HFCacheInfo",
516
- "HfHubAsyncTransport",
517
- "HfHubTransport",
518
517
  "cached_assets_path",
519
518
  "close_session",
520
519
  "dump_environment_info",
@@ -625,6 +624,7 @@ __all__ = [
625
624
  "DocumentQuestionAnsweringInputData",
626
625
  "DocumentQuestionAnsweringOutputElement",
627
626
  "DocumentQuestionAnsweringParameters",
627
+ "DryRunFileInfo",
628
628
  "EvalResult",
629
629
  "FLAX_WEIGHTS_NAME",
630
630
  "FeatureExtractionInput",
@@ -645,8 +645,6 @@ __all__ = [
645
645
  "HfFileSystemFile",
646
646
  "HfFileSystemResolvedPath",
647
647
  "HfFileSystemStreamFile",
648
- "HfHubAsyncTransport",
649
- "HfHubTransport",
650
648
  "ImageClassificationInput",
651
649
  "ImageClassificationOutputElement",
652
650
  "ImageClassificationOutputTransform",
@@ -1147,6 +1145,7 @@ if TYPE_CHECKING: # pragma: no cover
1147
1145
  )
1148
1146
  from .file_download import (
1149
1147
  _CACHED_NO_EXIST, # noqa: F401
1148
+ DryRunFileInfo, # noqa: F401
1150
1149
  HfFileMetadata, # noqa: F401
1151
1150
  get_hf_file_metadata, # noqa: F401
1152
1151
  hf_hub_download, # noqa: F401
@@ -1515,8 +1514,6 @@ if TYPE_CHECKING: # pragma: no cover
1515
1514
  CorruptedCacheException, # noqa: F401
1516
1515
  DeleteCacheStrategy, # noqa: F401
1517
1516
  HFCacheInfo, # noqa: F401
1518
- HfHubAsyncTransport, # noqa: F401
1519
- HfHubTransport, # noqa: F401
1520
1517
  cached_assets_path, # noqa: F401
1521
1518
  close_session, # noqa: F401
1522
1519
  dump_environment_info, # noqa: F401
@@ -20,8 +20,8 @@ from pathlib import Path
20
20
  from typing import Optional
21
21
 
22
22
  from . import constants
23
- from .commands._cli_utils import ANSI
24
23
  from .utils import (
24
+ ANSI,
25
25
  capture_output,
26
26
  get_token,
27
27
  is_google_colab,
@@ -244,7 +244,7 @@ def interpreter_login(*, skip_if_logged_in: bool = False) -> None:
244
244
  logger.info("User is already logged in.")
245
245
  return
246
246
 
247
- from .commands.delete_cache import _ask_for_confirmation_no_tui
247
+ from .cli.cache import _ask_for_confirmation_no_tui
248
248
 
249
249
  print(_HF_LOGO_ASCII)
250
250
  if get_token() is not None:
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from pathlib import Path
3
- from typing import Iterable, Optional, Union
3
+ from typing import Iterable, List, Literal, Optional, Union, overload
4
4
 
5
5
  import httpx
6
6
  from tqdm.auto import tqdm as base_tqdm
@@ -8,13 +8,14 @@ from tqdm.contrib.concurrent import thread_map
8
8
 
9
9
  from . import constants
10
10
  from .errors import (
11
+ DryRunError,
11
12
  GatedRepoError,
12
13
  HfHubHTTPError,
13
14
  LocalEntryNotFoundError,
14
15
  RepositoryNotFoundError,
15
16
  RevisionNotFoundError,
16
17
  )
17
- from .file_download import REGEX_COMMIT_HASH, hf_hub_download, repo_folder_name
18
+ from .file_download import REGEX_COMMIT_HASH, DryRunFileInfo, hf_hub_download, repo_folder_name
18
19
  from .hf_api import DatasetInfo, HfApi, ModelInfo, RepoFile, SpaceInfo
19
20
  from .utils import OfflineModeIsEnabled, filter_repo_objects, logging, validate_hf_hub_args
20
21
  from .utils import tqdm as hf_tqdm
@@ -25,6 +26,81 @@ logger = logging.get_logger(__name__)
25
26
  VERY_LARGE_REPO_THRESHOLD = 50000 # After this limit, we don't consider `repo_info.siblings` to be reliable enough
26
27
 
27
28
 
29
+ @overload
30
+ def snapshot_download(
31
+ repo_id: str,
32
+ *,
33
+ repo_type: Optional[str] = None,
34
+ revision: Optional[str] = None,
35
+ cache_dir: Union[str, Path, None] = None,
36
+ local_dir: Union[str, Path, None] = None,
37
+ library_name: Optional[str] = None,
38
+ library_version: Optional[str] = None,
39
+ user_agent: Optional[Union[dict, str]] = None,
40
+ etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
41
+ force_download: bool = False,
42
+ token: Optional[Union[bool, str]] = None,
43
+ local_files_only: bool = False,
44
+ allow_patterns: Optional[Union[list[str], str]] = None,
45
+ ignore_patterns: Optional[Union[list[str], str]] = None,
46
+ max_workers: int = 8,
47
+ tqdm_class: Optional[type[base_tqdm]] = None,
48
+ headers: Optional[dict[str, str]] = None,
49
+ endpoint: Optional[str] = None,
50
+ dry_run: Literal[False] = False,
51
+ ) -> str: ...
52
+
53
+
54
+ @overload
55
+ def snapshot_download(
56
+ repo_id: str,
57
+ *,
58
+ repo_type: Optional[str] = None,
59
+ revision: Optional[str] = None,
60
+ cache_dir: Union[str, Path, None] = None,
61
+ local_dir: Union[str, Path, None] = None,
62
+ library_name: Optional[str] = None,
63
+ library_version: Optional[str] = None,
64
+ user_agent: Optional[Union[dict, str]] = None,
65
+ etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
66
+ force_download: bool = False,
67
+ token: Optional[Union[bool, str]] = None,
68
+ local_files_only: bool = False,
69
+ allow_patterns: Optional[Union[list[str], str]] = None,
70
+ ignore_patterns: Optional[Union[list[str], str]] = None,
71
+ max_workers: int = 8,
72
+ tqdm_class: Optional[type[base_tqdm]] = None,
73
+ headers: Optional[dict[str, str]] = None,
74
+ endpoint: Optional[str] = None,
75
+ dry_run: Literal[True] = True,
76
+ ) -> list[DryRunFileInfo]: ...
77
+
78
+
79
+ @overload
80
+ def snapshot_download(
81
+ repo_id: str,
82
+ *,
83
+ repo_type: Optional[str] = None,
84
+ revision: Optional[str] = None,
85
+ cache_dir: Union[str, Path, None] = None,
86
+ local_dir: Union[str, Path, None] = None,
87
+ library_name: Optional[str] = None,
88
+ library_version: Optional[str] = None,
89
+ user_agent: Optional[Union[dict, str]] = None,
90
+ etag_timeout: float = constants.DEFAULT_ETAG_TIMEOUT,
91
+ force_download: bool = False,
92
+ token: Optional[Union[bool, str]] = None,
93
+ local_files_only: bool = False,
94
+ allow_patterns: Optional[Union[list[str], str]] = None,
95
+ ignore_patterns: Optional[Union[list[str], str]] = None,
96
+ max_workers: int = 8,
97
+ tqdm_class: Optional[type[base_tqdm]] = None,
98
+ headers: Optional[dict[str, str]] = None,
99
+ endpoint: Optional[str] = None,
100
+ dry_run: bool = False,
101
+ ) -> Union[str, list[DryRunFileInfo]]: ...
102
+
103
+
28
104
  @validate_hf_hub_args
29
105
  def snapshot_download(
30
106
  repo_id: str,
@@ -46,7 +122,8 @@ def snapshot_download(
46
122
  tqdm_class: Optional[type[base_tqdm]] = None,
47
123
  headers: Optional[dict[str, str]] = None,
48
124
  endpoint: Optional[str] = None,
49
- ) -> str:
125
+ dry_run: bool = False,
126
+ ) -> Union[str, list[DryRunFileInfo]]:
50
127
  """Download repo files.
51
128
 
52
129
  Download a whole snapshot of a repo's files at the specified revision. This is useful when you want all files from
@@ -109,9 +186,14 @@ def snapshot_download(
109
186
  Note that the `tqdm_class` is not passed to each individual download.
110
187
  Defaults to the custom HF progress bar that can be disabled by setting
111
188
  `HF_HUB_DISABLE_PROGRESS_BARS` environment variable.
189
+ dry_run (`bool`, *optional*, defaults to `False`):
190
+ If `True`, perform a dry run without actually downloading the files. Returns a list of
191
+ [`DryRunFileInfo`] objects containing information about what would be downloaded.
112
192
 
113
193
  Returns:
114
- `str`: folder path of the repo snapshot.
194
+ `str` or list of [`DryRunFileInfo`]:
195
+ - If `dry_run=False`: Local snapshot path.
196
+ - If `dry_run=True`: A list of [`DryRunFileInfo`] objects containing download information.
115
197
 
116
198
  Raises:
117
199
  [`~utils.RepositoryNotFoundError`]
@@ -187,6 +269,11 @@ def snapshot_download(
187
269
  # - f the specified revision is a branch or tag, look inside "refs".
188
270
  # => if local_dir is not None, we will return the path to the local folder if it exists.
189
271
  if repo_info is None:
272
+ if dry_run:
273
+ raise DryRunError(
274
+ "Dry run cannot be performed as the repository cannot be accessed. Please check your internet connection or authentication token."
275
+ ) from api_call_error
276
+
190
277
  # Try to get which commit hash corresponds to the specified revision
191
278
  commit_hash = None
192
279
  if REGEX_COMMIT_HASH.match(revision):
@@ -273,6 +360,8 @@ def snapshot_download(
273
360
  tqdm_desc = f"Fetching {len(filtered_repo_files)} files"
274
361
  else:
275
362
  tqdm_desc = "Fetching ... files"
363
+ if dry_run:
364
+ tqdm_desc = "[dry-run] " + tqdm_desc
276
365
 
277
366
  commit_hash = repo_info.sha
278
367
  snapshot_folder = os.path.join(storage_folder, "snapshots", commit_hash)
@@ -288,28 +377,33 @@ def snapshot_download(
288
377
  except OSError as e:
289
378
  logger.warning(f"Ignored error while writing commit hash to {ref_path}: {e}.")
290
379
 
380
+ results: List[Union[str, DryRunFileInfo]] = []
381
+
291
382
  # we pass the commit_hash to hf_hub_download
292
383
  # so no network call happens if we already
293
384
  # have the file locally.
294
- def _inner_hf_hub_download(repo_file: str):
295
- return hf_hub_download(
296
- repo_id,
297
- filename=repo_file,
298
- repo_type=repo_type,
299
- revision=commit_hash,
300
- endpoint=endpoint,
301
- cache_dir=cache_dir,
302
- local_dir=local_dir,
303
- library_name=library_name,
304
- library_version=library_version,
305
- user_agent=user_agent,
306
- etag_timeout=etag_timeout,
307
- force_download=force_download,
308
- token=token,
309
- headers=headers,
385
+ def _inner_hf_hub_download(repo_file: str) -> None:
386
+ results.append(
387
+ hf_hub_download( # type: ignore[no-matching-overload] # ty not happy, don't know why :/
388
+ repo_id,
389
+ filename=repo_file,
390
+ repo_type=repo_type,
391
+ revision=commit_hash,
392
+ endpoint=endpoint,
393
+ cache_dir=cache_dir,
394
+ local_dir=local_dir,
395
+ library_name=library_name,
396
+ library_version=library_version,
397
+ user_agent=user_agent,
398
+ etag_timeout=etag_timeout,
399
+ force_download=force_download,
400
+ token=token,
401
+ headers=headers,
402
+ dry_run=dry_run,
403
+ )
310
404
  )
311
405
 
312
- if constants.HF_HUB_ENABLE_HF_TRANSFER:
406
+ if constants.HF_HUB_ENABLE_HF_TRANSFER and not dry_run:
313
407
  # when using hf_transfer we don't want extra parallelism
314
408
  # from the one hf_transfer provides
315
409
  for file in filtered_repo_files:
@@ -324,6 +418,10 @@ def snapshot_download(
324
418
  tqdm_class=tqdm_class or hf_tqdm,
325
419
  )
326
420
 
421
+ if dry_run:
422
+ assert all(isinstance(r, DryRunFileInfo) for r in results)
423
+ return results # type: ignore
424
+
327
425
  if local_dir is not None:
328
426
  return str(os.path.realpath(local_dir))
329
427
  return snapshot_folder
@@ -31,8 +31,7 @@ from . import constants
31
31
  from ._commit_api import CommitOperationAdd, UploadInfo, _fetch_upload_modes
32
32
  from ._local_folder import LocalUploadFileMetadata, LocalUploadFilePaths, get_local_upload_paths, read_upload_metadata
33
33
  from .constants import DEFAULT_REVISION, REPO_TYPES
34
- from .utils import DEFAULT_IGNORE_PATTERNS, filter_repo_objects, tqdm
35
- from .utils._cache_manager import _format_size
34
+ from .utils import DEFAULT_IGNORE_PATTERNS, _format_size, filter_repo_objects, tqdm
36
35
  from .utils._runtime import is_xet_available
37
36
  from .utils.sha import sha_fileobj
38
37
 
@@ -0,0 +1,170 @@
1
+ # Copyright 2022 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Contains CLI utilities (styling, helpers)."""
15
+
16
+ import importlib.metadata
17
+ import os
18
+ import time
19
+ from enum import Enum
20
+ from pathlib import Path
21
+ from typing import TYPE_CHECKING, Annotated, Optional
22
+
23
+ import click
24
+ import typer
25
+
26
+ from huggingface_hub import __version__, constants
27
+ from huggingface_hub.utils import ANSI, get_session, hf_raise_for_status, installation_method, logging
28
+
29
+
30
+ logger = logging.get_logger()
31
+
32
+
33
+ if TYPE_CHECKING:
34
+ from huggingface_hub.hf_api import HfApi
35
+
36
+
37
+ def get_hf_api(token: Optional[str] = None) -> "HfApi":
38
+ # Import here to avoid circular import
39
+ from huggingface_hub.hf_api import HfApi
40
+
41
+ return HfApi(token=token, library_name="hf", library_version=__version__)
42
+
43
+
44
+ #### TYPER UTILS
45
+
46
+
47
+ class AlphabeticalMixedGroup(typer.core.TyperGroup):
48
+ """
49
+ Typer Group that lists commands and sub-apps mixed and alphabetically.
50
+ """
51
+
52
+ def list_commands(self, ctx: click.Context) -> list[str]: # type: ignore[name-defined]
53
+ # click.Group stores both commands and sub-groups in `self.commands`
54
+ return sorted(self.commands.keys())
55
+
56
+
57
+ def typer_factory(help: str) -> typer.Typer:
58
+ return typer.Typer(
59
+ help=help,
60
+ add_completion=True,
61
+ rich_markup_mode=None,
62
+ no_args_is_help=True,
63
+ cls=AlphabeticalMixedGroup,
64
+ )
65
+
66
+
67
+ class RepoType(str, Enum):
68
+ model = "model"
69
+ dataset = "dataset"
70
+ space = "space"
71
+
72
+
73
+ RepoIdArg = Annotated[
74
+ str,
75
+ typer.Argument(
76
+ help="The ID of the repo (e.g. `username/repo-name`).",
77
+ ),
78
+ ]
79
+
80
+
81
+ RepoTypeOpt = Annotated[
82
+ RepoType,
83
+ typer.Option(
84
+ help="The type of repository (model, dataset, or space).",
85
+ ),
86
+ ]
87
+
88
+ TokenOpt = Annotated[
89
+ Optional[str],
90
+ typer.Option(
91
+ help="A User Access Token generated from https://huggingface.co/settings/tokens.",
92
+ ),
93
+ ]
94
+
95
+ PrivateOpt = Annotated[
96
+ bool,
97
+ typer.Option(
98
+ help="Whether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already exists.",
99
+ ),
100
+ ]
101
+
102
+ RevisionOpt = Annotated[
103
+ Optional[str],
104
+ typer.Option(
105
+ help="Git revision id which can be a branch name, a tag, or a commit hash.",
106
+ ),
107
+ ]
108
+
109
+
110
+ ### PyPI VERSION CHECKER
111
+
112
+
113
+ def check_cli_update() -> None:
114
+ """
115
+ Check whether a newer version of `huggingface_hub` is available on PyPI.
116
+
117
+ If a newer version is found, notify the user and suggest updating.
118
+ If current version is a pre-release (e.g. `1.0.0.rc1`), or a dev version (e.g. `1.0.0.dev1`), no check is performed.
119
+
120
+ This function is called at the entry point of the CLI. It only performs the check once every 24 hours, and any error
121
+ during the check is caught and logged, to avoid breaking the CLI.
122
+ """
123
+ try:
124
+ _check_cli_update()
125
+ except Exception:
126
+ # We don't want the CLI to fail on version checks, no matter the reason.
127
+ logger.debug("Error while checking for CLI update.", exc_info=True)
128
+
129
+
130
+ def _check_cli_update() -> None:
131
+ current_version = importlib.metadata.version("huggingface_hub")
132
+
133
+ # Skip if current version is a pre-release or dev version
134
+ if any(tag in current_version for tag in ["rc", "dev"]):
135
+ return
136
+
137
+ # Skip if already checked in the last 24 hours
138
+ if os.path.exists(constants.CHECK_FOR_UPDATE_DONE_PATH):
139
+ mtime = os.path.getmtime(constants.CHECK_FOR_UPDATE_DONE_PATH)
140
+ if (time.time() - mtime) < 24 * 3600:
141
+ return
142
+
143
+ # Touch the file to mark that we did the check now
144
+ Path(constants.CHECK_FOR_UPDATE_DONE_PATH).touch()
145
+
146
+ # Check latest version from PyPI
147
+ response = get_session().get("https://pypi.org/pypi/huggingface_hub/json", timeout=2)
148
+ hf_raise_for_status(response)
149
+ data = response.json()
150
+ latest_version = data["info"]["version"]
151
+
152
+ # If latest version is different from current, notify user
153
+ if current_version != latest_version:
154
+ method = installation_method()
155
+ if method == "brew":
156
+ update_command = "brew upgrade huggingface-cli"
157
+ elif method == "hf_installer" and os.name == "nt":
158
+ update_command = 'powershell -NoProfile -Command "iwr -useb https://hf.co/cli/install.ps1 | iex"'
159
+ elif method == "hf_installer":
160
+ update_command = "curl -LsSf https://hf.co/cli/install.sh | sh -"
161
+ else: # unknown => likely pip
162
+ update_command = "pip install -U huggingface_hub"
163
+
164
+ click.echo(
165
+ ANSI.yellow(
166
+ f"A new version of huggingface_hub ({latest_version}) is available! "
167
+ f"You are using version {current_version}.\n"
168
+ f"To update, run: {ANSI.bold(update_command)}\n",
169
+ )
170
+ )
@@ -39,8 +39,8 @@ from huggingface_hub.errors import HfHubHTTPError
39
39
  from huggingface_hub.hf_api import whoami
40
40
 
41
41
  from .._login import auth_list, auth_switch, login, logout
42
- from ..utils import get_stored_tokens, get_token, logging
43
- from ._cli_utils import ANSI, TokenOpt, typer_factory
42
+ from ..utils import ANSI, get_stored_tokens, get_token, logging
43
+ from ._cli_utils import TokenOpt, typer_factory
44
44
 
45
45
 
46
46
  logger = logging.get_logger(__name__)
@@ -23,8 +23,8 @@ from typing import Annotated, Any, Callable, Iterable, Optional, Union
23
23
 
24
24
  import typer
25
25
 
26
- from ..utils import CachedRepoInfo, CachedRevisionInfo, CacheNotFound, HFCacheInfo, scan_cache_dir
27
- from ._cli_utils import ANSI, tabulate, typer_factory
26
+ from ..utils import ANSI, CachedRepoInfo, CachedRevisionInfo, CacheNotFound, HFCacheInfo, scan_cache_dir, tabulate
27
+ from ._cli_utils import typer_factory
28
28
 
29
29
 
30
30
  # --- DELETE helpers (from delete_cache.py) ---
@@ -37,14 +37,14 @@ Usage:
37
37
  """
38
38
 
39
39
  import warnings
40
- from typing import Annotated, Optional
40
+ from typing import Annotated, Optional, Union
41
41
 
42
42
  import typer
43
43
 
44
44
  from huggingface_hub import logging
45
45
  from huggingface_hub._snapshot_download import snapshot_download
46
- from huggingface_hub.file_download import hf_hub_download
47
- from huggingface_hub.utils import disable_progress_bars, enable_progress_bars
46
+ from huggingface_hub.file_download import DryRunFileInfo, hf_hub_download
47
+ from huggingface_hub.utils import _format_size, disable_progress_bars, enable_progress_bars, tabulate
48
48
 
49
49
  from ._cli_utils import RepoIdArg, RepoTypeOpt, RevisionOpt, TokenOpt
50
50
 
@@ -92,6 +92,12 @@ def download(
92
92
  help="If True, the files will be downloaded even if they are already cached.",
93
93
  ),
94
94
  ] = False,
95
+ dry_run: Annotated[
96
+ bool,
97
+ typer.Option(
98
+ help="If True, perform a dry run without actually downloading the file.",
99
+ ),
100
+ ] = False,
95
101
  token: TokenOpt = None,
96
102
  quiet: Annotated[
97
103
  bool,
@@ -108,7 +114,7 @@ def download(
108
114
  ) -> None:
109
115
  """Download files from the Hub."""
110
116
 
111
- def run_download() -> str:
117
+ def run_download() -> Union[str, DryRunFileInfo, list[DryRunFileInfo]]:
112
118
  filenames_list = filenames if filenames is not None else []
113
119
  # Warn user if patterns are ignored
114
120
  if len(filenames_list) > 0:
@@ -129,6 +135,7 @@ def download(
129
135
  token=token,
130
136
  local_dir=local_dir,
131
137
  library_name="hf",
138
+ dry_run=dry_run,
132
139
  )
133
140
 
134
141
  # Otherwise: use `snapshot_download` to ensure all files comes from same revision
@@ -151,14 +158,32 @@ def download(
151
158
  local_dir=local_dir,
152
159
  library_name="hf",
153
160
  max_workers=max_workers,
161
+ dry_run=dry_run,
162
+ )
163
+
164
+ def _print_result(result: Union[str, DryRunFileInfo, list[DryRunFileInfo]]) -> None:
165
+ if isinstance(result, str):
166
+ print(result)
167
+ return
168
+
169
+ # Print dry run info
170
+ if isinstance(result, DryRunFileInfo):
171
+ result = [result]
172
+ print(
173
+ f"[dry-run] Will download {len([r for r in result if r.will_download])} files (out of {len(result)}) totalling {_format_size(sum(r.file_size for r in result if r.will_download))}."
154
174
  )
175
+ columns = ["File", "Bytes to download"]
176
+ items: list[list[Union[str, int]]] = []
177
+ for info in sorted(result, key=lambda x: x.filename):
178
+ items.append([info.filename, _format_size(info.file_size) if info.will_download else "-"])
179
+ print(tabulate(items, headers=columns))
155
180
 
156
181
  if quiet:
157
182
  disable_progress_bars()
158
183
  with warnings.catch_warnings():
159
184
  warnings.simplefilter("ignore")
160
- print(run_download())
185
+ _print_result(run_download())
161
186
  enable_progress_bars()
162
187
  else:
163
- print(run_download())
188
+ _print_result(run_download())
164
189
  logging.set_verbosity_warning()
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- from huggingface_hub.cli._cli_utils import typer_factory
16
+ from huggingface_hub.cli._cli_utils import check_cli_update, typer_factory
17
17
  from huggingface_hub.cli.auth import auth_cli
18
18
  from huggingface_hub.cli.cache import cache_cli
19
19
  from huggingface_hub.cli.download import download
@@ -52,6 +52,7 @@ app.add_typer(jobs_cli, name="jobs")
52
52
 
53
53
  def main():
54
54
  logging.set_verbosity_info()
55
+ check_cli_update()
55
56
  app()
56
57
 
57
58
 
@@ -27,10 +27,9 @@ from typing import Annotated, Optional
27
27
  import typer
28
28
 
29
29
  from huggingface_hub.errors import HfHubHTTPError, RepositoryNotFoundError, RevisionNotFoundError
30
- from huggingface_hub.utils import logging
30
+ from huggingface_hub.utils import ANSI, logging
31
31
 
32
32
  from ._cli_utils import (
33
- ANSI,
34
33
  PrivateOpt,
35
34
  RepoIdArg,
36
35
  RepoType,
@@ -20,9 +20,9 @@ from typing import Annotated, Optional
20
20
  import typer
21
21
 
22
22
  from huggingface_hub import logging
23
- from huggingface_hub.utils import disable_progress_bars
23
+ from huggingface_hub.utils import ANSI, disable_progress_bars
24
24
 
25
- from ._cli_utils import ANSI, PrivateOpt, RepoIdArg, RepoType, RepoTypeOpt, RevisionOpt, TokenOpt, get_hf_api
25
+ from ._cli_utils import PrivateOpt, RepoIdArg, RepoType, RepoTypeOpt, RevisionOpt, TokenOpt, get_hf_api
26
26
 
27
27
 
28
28
  logger = logging.get_logger(__name__)
@@ -163,6 +163,10 @@ HF_ASSETS_CACHE = os.path.expandvars(
163
163
 
164
164
  HF_HUB_OFFLINE = _is_true(os.environ.get("HF_HUB_OFFLINE") or os.environ.get("TRANSFORMERS_OFFLINE"))
165
165
 
166
+ # File created to mark that the version check has been done.
167
+ # Check is performed once per 24 hours at most.
168
+ CHECK_FOR_UPDATE_DONE_PATH = os.path.join(HF_HOME, ".check_for_update_done")
169
+
166
170
  # If set, log level will be set to DEBUG and all requests made to the Hub will be logged
167
171
  # as curl commands for reproducibility.
168
172
  HF_DEBUG = _is_true(os.environ.get("HF_DEBUG"))