huggingface-hub 0.29.0rc2__py3-none-any.whl → 1.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. huggingface_hub/__init__.py +160 -46
  2. huggingface_hub/_commit_api.py +277 -71
  3. huggingface_hub/_commit_scheduler.py +15 -15
  4. huggingface_hub/_inference_endpoints.py +33 -22
  5. huggingface_hub/_jobs_api.py +301 -0
  6. huggingface_hub/_local_folder.py +18 -3
  7. huggingface_hub/_login.py +31 -63
  8. huggingface_hub/_oauth.py +460 -0
  9. huggingface_hub/_snapshot_download.py +241 -81
  10. huggingface_hub/_space_api.py +18 -10
  11. huggingface_hub/_tensorboard_logger.py +15 -19
  12. huggingface_hub/_upload_large_folder.py +196 -76
  13. huggingface_hub/_webhooks_payload.py +3 -3
  14. huggingface_hub/_webhooks_server.py +15 -25
  15. huggingface_hub/{commands → cli}/__init__.py +1 -15
  16. huggingface_hub/cli/_cli_utils.py +173 -0
  17. huggingface_hub/cli/auth.py +147 -0
  18. huggingface_hub/cli/cache.py +841 -0
  19. huggingface_hub/cli/download.py +189 -0
  20. huggingface_hub/cli/hf.py +60 -0
  21. huggingface_hub/cli/inference_endpoints.py +377 -0
  22. huggingface_hub/cli/jobs.py +772 -0
  23. huggingface_hub/cli/lfs.py +175 -0
  24. huggingface_hub/cli/repo.py +315 -0
  25. huggingface_hub/cli/repo_files.py +94 -0
  26. huggingface_hub/{commands/env.py → cli/system.py} +10 -13
  27. huggingface_hub/cli/upload.py +294 -0
  28. huggingface_hub/cli/upload_large_folder.py +117 -0
  29. huggingface_hub/community.py +20 -12
  30. huggingface_hub/constants.py +83 -59
  31. huggingface_hub/dataclasses.py +609 -0
  32. huggingface_hub/errors.py +99 -30
  33. huggingface_hub/fastai_utils.py +30 -41
  34. huggingface_hub/file_download.py +606 -346
  35. huggingface_hub/hf_api.py +2445 -1132
  36. huggingface_hub/hf_file_system.py +269 -152
  37. huggingface_hub/hub_mixin.py +61 -66
  38. huggingface_hub/inference/_client.py +501 -630
  39. huggingface_hub/inference/_common.py +133 -121
  40. huggingface_hub/inference/_generated/_async_client.py +536 -722
  41. huggingface_hub/inference/_generated/types/__init__.py +6 -1
  42. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +5 -6
  43. huggingface_hub/inference/_generated/types/base.py +10 -7
  44. huggingface_hub/inference/_generated/types/chat_completion.py +77 -31
  45. huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
  46. huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
  47. huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
  48. huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
  49. huggingface_hub/inference/_generated/types/image_to_image.py +8 -2
  50. huggingface_hub/inference/_generated/types/image_to_text.py +2 -3
  51. huggingface_hub/inference/_generated/types/image_to_video.py +60 -0
  52. huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
  53. huggingface_hub/inference/_generated/types/summarization.py +2 -2
  54. huggingface_hub/inference/_generated/types/table_question_answering.py +5 -5
  55. huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
  56. huggingface_hub/inference/_generated/types/text_generation.py +11 -11
  57. huggingface_hub/inference/_generated/types/text_to_audio.py +1 -2
  58. huggingface_hub/inference/_generated/types/text_to_speech.py +1 -2
  59. huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
  60. huggingface_hub/inference/_generated/types/token_classification.py +2 -2
  61. huggingface_hub/inference/_generated/types/translation.py +2 -2
  62. huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
  63. huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
  64. huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
  65. huggingface_hub/inference/_mcp/__init__.py +0 -0
  66. huggingface_hub/inference/_mcp/_cli_hacks.py +88 -0
  67. huggingface_hub/inference/_mcp/agent.py +100 -0
  68. huggingface_hub/inference/_mcp/cli.py +247 -0
  69. huggingface_hub/inference/_mcp/constants.py +81 -0
  70. huggingface_hub/inference/_mcp/mcp_client.py +395 -0
  71. huggingface_hub/inference/_mcp/types.py +45 -0
  72. huggingface_hub/inference/_mcp/utils.py +128 -0
  73. huggingface_hub/inference/_providers/__init__.py +149 -20
  74. huggingface_hub/inference/_providers/_common.py +160 -37
  75. huggingface_hub/inference/_providers/black_forest_labs.py +12 -9
  76. huggingface_hub/inference/_providers/cerebras.py +6 -0
  77. huggingface_hub/inference/_providers/clarifai.py +13 -0
  78. huggingface_hub/inference/_providers/cohere.py +32 -0
  79. huggingface_hub/inference/_providers/fal_ai.py +231 -22
  80. huggingface_hub/inference/_providers/featherless_ai.py +38 -0
  81. huggingface_hub/inference/_providers/fireworks_ai.py +22 -1
  82. huggingface_hub/inference/_providers/groq.py +9 -0
  83. huggingface_hub/inference/_providers/hf_inference.py +143 -33
  84. huggingface_hub/inference/_providers/hyperbolic.py +9 -5
  85. huggingface_hub/inference/_providers/nebius.py +47 -5
  86. huggingface_hub/inference/_providers/novita.py +48 -5
  87. huggingface_hub/inference/_providers/nscale.py +44 -0
  88. huggingface_hub/inference/_providers/openai.py +25 -0
  89. huggingface_hub/inference/_providers/publicai.py +6 -0
  90. huggingface_hub/inference/_providers/replicate.py +46 -9
  91. huggingface_hub/inference/_providers/sambanova.py +37 -1
  92. huggingface_hub/inference/_providers/scaleway.py +28 -0
  93. huggingface_hub/inference/_providers/together.py +34 -5
  94. huggingface_hub/inference/_providers/wavespeed.py +138 -0
  95. huggingface_hub/inference/_providers/zai_org.py +17 -0
  96. huggingface_hub/lfs.py +33 -100
  97. huggingface_hub/repocard.py +34 -38
  98. huggingface_hub/repocard_data.py +79 -59
  99. huggingface_hub/serialization/__init__.py +0 -1
  100. huggingface_hub/serialization/_base.py +12 -15
  101. huggingface_hub/serialization/_dduf.py +8 -8
  102. huggingface_hub/serialization/_torch.py +69 -69
  103. huggingface_hub/utils/__init__.py +27 -8
  104. huggingface_hub/utils/_auth.py +7 -7
  105. huggingface_hub/utils/_cache_manager.py +92 -147
  106. huggingface_hub/utils/_chunk_utils.py +2 -3
  107. huggingface_hub/utils/_deprecation.py +1 -1
  108. huggingface_hub/utils/_dotenv.py +55 -0
  109. huggingface_hub/utils/_experimental.py +7 -5
  110. huggingface_hub/utils/_fixes.py +0 -10
  111. huggingface_hub/utils/_git_credential.py +5 -5
  112. huggingface_hub/utils/_headers.py +8 -30
  113. huggingface_hub/utils/_http.py +399 -237
  114. huggingface_hub/utils/_pagination.py +6 -6
  115. huggingface_hub/utils/_parsing.py +98 -0
  116. huggingface_hub/utils/_paths.py +5 -5
  117. huggingface_hub/utils/_runtime.py +74 -22
  118. huggingface_hub/utils/_safetensors.py +21 -21
  119. huggingface_hub/utils/_subprocess.py +13 -11
  120. huggingface_hub/utils/_telemetry.py +4 -4
  121. huggingface_hub/{commands/_cli_utils.py → utils/_terminal.py} +4 -4
  122. huggingface_hub/utils/_typing.py +25 -5
  123. huggingface_hub/utils/_validators.py +55 -74
  124. huggingface_hub/utils/_verification.py +167 -0
  125. huggingface_hub/utils/_xet.py +235 -0
  126. huggingface_hub/utils/_xet_progress_reporting.py +162 -0
  127. huggingface_hub/utils/insecure_hashlib.py +3 -5
  128. huggingface_hub/utils/logging.py +8 -11
  129. huggingface_hub/utils/tqdm.py +33 -4
  130. {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/METADATA +94 -82
  131. huggingface_hub-1.1.3.dist-info/RECORD +155 -0
  132. {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/WHEEL +1 -1
  133. huggingface_hub-1.1.3.dist-info/entry_points.txt +6 -0
  134. huggingface_hub/commands/delete_cache.py +0 -428
  135. huggingface_hub/commands/download.py +0 -200
  136. huggingface_hub/commands/huggingface_cli.py +0 -61
  137. huggingface_hub/commands/lfs.py +0 -200
  138. huggingface_hub/commands/repo_files.py +0 -128
  139. huggingface_hub/commands/scan_cache.py +0 -181
  140. huggingface_hub/commands/tag.py +0 -159
  141. huggingface_hub/commands/upload.py +0 -299
  142. huggingface_hub/commands/upload_large_folder.py +0 -129
  143. huggingface_hub/commands/user.py +0 -304
  144. huggingface_hub/commands/version.py +0 -37
  145. huggingface_hub/inference_api.py +0 -217
  146. huggingface_hub/keras_mixin.py +0 -500
  147. huggingface_hub/repository.py +0 -1477
  148. huggingface_hub/serialization/_tensorflow.py +0 -95
  149. huggingface_hub/utils/_hf_folder.py +0 -68
  150. huggingface_hub-0.29.0rc2.dist-info/RECORD +0 -131
  151. huggingface_hub-0.29.0rc2.dist-info/entry_points.txt +0 -6
  152. {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info/licenses}/LICENSE +0 -0
  153. {huggingface_hub-0.29.0rc2.dist-info → huggingface_hub-1.1.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,155 @@
1
+ huggingface_hub/__init__.py,sha256=q26ErgoSXMhbOIoPg0wLFmsWZd0GAxD203vUg90uzVI,52470
2
+ huggingface_hub/_commit_api.py,sha256=RUTK7SLa10_-AnfQOCY-pcLw_L_LyuGCfjzvpmb6edk,40619
3
+ huggingface_hub/_commit_scheduler.py,sha256=tqcdWVGJRIxGQtkFHs_AgBdN9ztUjOQSuAhfMAr1ieM,14751
4
+ huggingface_hub/_inference_endpoints.py,sha256=FGiAsAuVVW6YbGw6KvryfyMTWup6h0cURXR3zx6nwYY,17593
5
+ huggingface_hub/_jobs_api.py,sha256=BelnQPFWSH80-SJm8OGrZy8s1mwm8PmCGbV82sZ11xs,10871
6
+ huggingface_hub/_local_folder.py,sha256=gVG89_stPbxsQpkYh6YCXhhgfvhHFavP4uKmGkHjEzY,17305
7
+ huggingface_hub/_login.py,sha256=Me2o4B1qovbcXNKlHaakUrxho1XtPPSV7DD1sn2apEA,18971
8
+ huggingface_hub/_oauth.py,sha256=Pvu5zi733W7ZofFpzET1ZJjTJeg3JkdlW1TBc0WgBjU,18695
9
+ huggingface_hub/_snapshot_download.py,sha256=UWzMC-4RPjmtaDrZKZzJlxeX0Fi8vyWoqtO439TElx0,20622
10
+ huggingface_hub/_space_api.py,sha256=x3g73UhCyz4HEQIGjy7RTKUMO6j8VERpMD9RR-j9cEM,5464
11
+ huggingface_hub/_tensorboard_logger.py,sha256=3TocVxxSIioqxOkI6p1N4plnWfAizfdU456V0-K10Bs,8414
12
+ huggingface_hub/_upload_large_folder.py,sha256=J3AFi-PikkrfDIl1NLloZ-UrRCa4SAXZR2FPRg6Xg1M,29564
13
+ huggingface_hub/_webhooks_payload.py,sha256=qCZjBa5dhssg_O0yzgzxPyMpwAxLG96I4qen_HIk0Qc,3611
14
+ huggingface_hub/_webhooks_server.py,sha256=-trDDzwsFHuE0IIwxWJLtfq9D35k8AVas-UAMSn3qxc,15668
15
+ huggingface_hub/community.py,sha256=FACeqlP7OgR2vLLJ0IN4cfglBiEGbyTafJ0cXfsjgnQ,12359
16
+ huggingface_hub/constants.py,sha256=Wv-R7Ey_kyIFG39w3jPBY0tJO-37ZNtuTtkVy4pPewo,9711
17
+ huggingface_hub/dataclasses.py,sha256=aJD2PJMq6FMztM66Q1qNmFi7mNDe9qLdBc03hPQNMlM,22326
18
+ huggingface_hub/errors.py,sha256=zefsTHS6_POYb22EbHKuXMDWWRLvheM8ns9fXX4QDu0,11681
19
+ huggingface_hub/fastai_utils.py,sha256=0joRPBUccjFALLCfhQLyD_K8qxGvQiLThKJClwej_JQ,16657
20
+ huggingface_hub/file_download.py,sha256=c1K0uVCBy08uS2_q5IFQqJBLuzavo2RI4vvXNrUuMqQ,79644
21
+ huggingface_hub/hf_api.py,sha256=3L4qWURQeN5yuiG-scYrSB8TSxjOdpVqb1APVhjqtPE,480475
22
+ huggingface_hub/hf_file_system.py,sha256=6yYvFMsFOoTcEXCJQoc6XKdlGTX6Fp_ZGeV_WIU7VKk,52726
23
+ huggingface_hub/hub_mixin.py,sha256=UvFMjhCISEjJxvur7dr3tuqpjjRDIV2MbTa2Ma74UzY,37064
24
+ huggingface_hub/lfs.py,sha256=_yqqEl3xbzWufgBBJ-vtPx-LUiuZBJpT9AQ9iX0VJ0c,14060
25
+ huggingface_hub/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ huggingface_hub/repocard.py,sha256=eGgvokul8iiCXYuPdrGGyiq6r0YZy_bA91p0SNdmkqw,34973
27
+ huggingface_hub/repocard_data.py,sha256=awhSsLRPrcFM9CurB9mrY40H1bE15yzoXDTVL60yD1U,34079
28
+ huggingface_hub/cli/__init__.py,sha256=A4zmzuHD2OHjQ5zmdfcnsj0JeCzHVPtpzh-wCjInugA,606
29
+ huggingface_hub/cli/_cli_utils.py,sha256=CGJcEwFbIVWK1azJ4AIml6D8FBbn24lPZfBR069cE98,5403
30
+ huggingface_hub/cli/auth.py,sha256=tJcKzQz8_pl0FFl8a-tNjxpK4AFfA38L4oztcXVdcSY,4515
31
+ huggingface_hub/cli/cache.py,sha256=v_2ssqCj3CLqFbD-nKK6BhGSCpgHzowrO4VvkSKU4k8,29168
32
+ huggingface_hub/cli/download.py,sha256=h9dUa91e1nOTmIcgtxyNE0ZGz6ZSrKu4nnlJsYp2HWg,6532
33
+ huggingface_hub/cli/hf.py,sha256=N_OvRoTWqfFtncPDqgk8b9h0FYR85CV-dhHEm-VDRX4,2406
34
+ huggingface_hub/cli/inference_endpoints.py,sha256=vS8qpRujHdB_AyyZp5uV5uMmNwlCZUf64VGSFCh7AGA,11113
35
+ huggingface_hub/cli/jobs.py,sha256=HgxxxDRaCHH62eBpihzf1SakevM3OWewPiIzWjFkYLw,23871
36
+ huggingface_hub/cli/lfs.py,sha256=UJI5nBbrt_a-lm5uU88gxD6hVu8xyQav-zBxLTv3Wzo,5895
37
+ huggingface_hub/cli/repo.py,sha256=kAHyiYQap5gVNY8kPmub4s7X9mGsn8vFJNIIzSeIOD4,9709
38
+ huggingface_hub/cli/repo_files.py,sha256=6d5GsLsCjqSKTSbJqCHnrRxB9kXj-yLRAtcVbQkQNMo,2799
39
+ huggingface_hub/cli/system.py,sha256=bEIXmK3qz4qIej1lv1LMCxnXEN9zZnwdl42g4mV_1nQ,982
40
+ huggingface_hub/cli/upload.py,sha256=Dpu-syLR6J52U2HM8bJbjAk5PNA2gxAYagjKoRTNSZs,11383
41
+ huggingface_hub/cli/upload_large_folder.py,sha256=xQuloimQT0PQH6r5urRpLv8M9I99yAWSGM-sbkG2pu8,4470
42
+ huggingface_hub/inference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ huggingface_hub/inference/_client.py,sha256=8l6OMduH8CCZevXUAh-SA8vFvShhQnDi7CbU3yHupLo,158079
44
+ huggingface_hub/inference/_common.py,sha256=TEHgPePoXkjIHGv0JxjMZ5zCwxVxK0bDONMDli3Rb2I,15069
45
+ huggingface_hub/inference/_generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ huggingface_hub/inference/_generated/_async_client.py,sha256=1kuFwveq1gUETCKfBt4lcpPsv8OtIKZ7txhTczgA9A8,161289
47
+ huggingface_hub/inference/_generated/types/__init__.py,sha256=9WvrGQ8aThtKSNzZF06j-CIE2ZuItne8FFnea1p1u38,6557
48
+ huggingface_hub/inference/_generated/types/audio_classification.py,sha256=Jg3mzfGhCSH6CfvVvgJSiFpkz6v4nNA0G4LJXacEgNc,1573
49
+ huggingface_hub/inference/_generated/types/audio_to_audio.py,sha256=2Ep4WkePL7oJwcp5nRJqApwviumGHbft9HhXE9XLHj4,891
50
+ huggingface_hub/inference/_generated/types/automatic_speech_recognition.py,sha256=FyViZkZqd0oo7Raqo48HESMAXHSnJap9HRWsKCi8Xz4,5509
51
+ huggingface_hub/inference/_generated/types/base.py,sha256=9sGEyvytJureiYimTb-pFIxG7jLe6okKzPamZuSiZyc,6896
52
+ huggingface_hub/inference/_generated/types/chat_completion.py,sha256=3-pAyko3ozXSsvE_nFl4wtALf3z5DVQSLjtAD-2tUe4,11242
53
+ huggingface_hub/inference/_generated/types/depth_estimation.py,sha256=c7IA81gZp5xIHol-7wlvy8V8UE--O1XF9rahauLVuoY,923
54
+ huggingface_hub/inference/_generated/types/document_question_answering.py,sha256=aJ_dC3pVLTHombqX3UwIFhKN_mFzpw4m89sfB2J488E,3196
55
+ huggingface_hub/inference/_generated/types/feature_extraction.py,sha256=A8nj27aQWF6XKQxNl0GsOnsNY--nN8Rnlh3nRXrThkU,1531
56
+ huggingface_hub/inference/_generated/types/fill_mask.py,sha256=E-dU2bmHlso1cei_ju_LQtYVvDZEqAM1-walZkMPa74,1702
57
+ huggingface_hub/inference/_generated/types/image_classification.py,sha256=A-Y024o8723_n8mGVos4TwdAkVL62McGeL1iIo4VzNs,1585
58
+ huggingface_hub/inference/_generated/types/image_segmentation.py,sha256=vrkI4SuP1Iq_iLXc-2pQhYY3SHN4gzvFBoZqbUHxU7o,1950
59
+ huggingface_hub/inference/_generated/types/image_to_image.py,sha256=snvGbmCdqchxGef25MceD7LSKAmVkIgnoX5t71rdlAQ,2290
60
+ huggingface_hub/inference/_generated/types/image_to_text.py,sha256=OaFEBAfgT-fOVzJ7xVermGf7VODhrc9-Jg38WrM7-2o,4810
61
+ huggingface_hub/inference/_generated/types/image_to_video.py,sha256=bC-L_cNsDhk4s_IdSiprJ9d1NeMGePLcUp7UPpco21w,2240
62
+ huggingface_hub/inference/_generated/types/object_detection.py,sha256=VuFlb1281qTXoSgJDmquGz-VNfEZLo2H0Rh_F6MF6ts,2000
63
+ huggingface_hub/inference/_generated/types/question_answering.py,sha256=zw38a9_9l2k1ifYZefjkioqZ4asfSRM9M4nU3gSCmAQ,2898
64
+ huggingface_hub/inference/_generated/types/sentence_similarity.py,sha256=5mDdTop4w6CpS-SulA03UVq5lBbzHuNMe8IQsTmAUPQ,1040
65
+ huggingface_hub/inference/_generated/types/summarization.py,sha256=eMJvNJmxdImVXLLMADmyDeB1YhJbN3Qd_fC6lPB7mTM,1481
66
+ huggingface_hub/inference/_generated/types/table_question_answering.py,sha256=SbgRCeEopJ0ig0U-q-Ft58kzD4aKfn1Dzu46r1g5z28,2281
67
+ huggingface_hub/inference/_generated/types/text2text_generation.py,sha256=S9as2uJKqCmRht_dFGws-KwQwEq1hD6w3gSLiGTMERI,1603
68
+ huggingface_hub/inference/_generated/types/text_classification.py,sha256=FarAjygLEfPofLfKeabzJ7PKEBItlHGoUNUOzyLRpL4,1445
69
+ huggingface_hub/inference/_generated/types/text_generation.py,sha256=g9pLc5XrWc1Ir0nmQ4xTa4ZauKHIJ9Pr7yM1FmZkX0Y,5916
70
+ huggingface_hub/inference/_generated/types/text_to_audio.py,sha256=1HR9Q6s9MXqtKGTvHPLGVMum5-eg7O-Pgv6Nd0v8_HU,4741
71
+ huggingface_hub/inference/_generated/types/text_to_image.py,sha256=sGGi1Fa0n5Pmd6G3I-F2SBJcJ1M7Gmqnng6sfi0AVzs,1903
72
+ huggingface_hub/inference/_generated/types/text_to_speech.py,sha256=ROFuR32ijROCeqbv81Jos0lmaA8SRWyIUsWrdD4yWow,4760
73
+ huggingface_hub/inference/_generated/types/text_to_video.py,sha256=xjC9Vp3eovuKEk7qhIeeC8VNJG8W0Kr8PEnOwOC1Ga4,1784
74
+ huggingface_hub/inference/_generated/types/token_classification.py,sha256=bpRwy_1knC11auZaeoVrCyYWBwyJLLKeiS-ypNkDTT8,1909
75
+ huggingface_hub/inference/_generated/types/translation.py,sha256=jfeWNGkZInGTOWP-Tq2dl1rGa8xuUQvZ40PxuOrsBpE,1757
76
+ huggingface_hub/inference/_generated/types/video_classification.py,sha256=TyydjQw2NRLK9sDGzJUVnkDeo848ebmCx588Ur8I9q0,1680
77
+ huggingface_hub/inference/_generated/types/visual_question_answering.py,sha256=AWrQ6qo4gZa3PGedaNpzDFqx5yOYyjhnUB6iuZEj_uo,1673
78
+ huggingface_hub/inference/_generated/types/zero_shot_classification.py,sha256=-PRiAdpXN0wxRrSVe3z8byEvuxcNby89mASU9CbfVzU,1732
79
+ huggingface_hub/inference/_generated/types/zero_shot_image_classification.py,sha256=1alzatw0RA88YUuHfrhRWQ5-Fix-iO3KcxfJV3WQB50,1481
80
+ huggingface_hub/inference/_generated/types/zero_shot_object_detection.py,sha256=sjdpVUN5zW9aYBymLVUs6i5HVk2qkUBO9ysEjHmsXVM,1605
81
+ huggingface_hub/inference/_mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
+ huggingface_hub/inference/_mcp/_cli_hacks.py,sha256=KX9HZJPa1p8ngY3mtYGGlVUXfg4vYbbBRs-8HLToP04,3284
83
+ huggingface_hub/inference/_mcp/agent.py,sha256=ufIzMGHore5n252hV5GZPM0ouDXIl6tv5Jl_5gHXnbg,4250
84
+ huggingface_hub/inference/_mcp/cli.py,sha256=AmSUT6wXlE6EWmI0SfQgTWYnL07322zGwwk2yMZZlBc,9640
85
+ huggingface_hub/inference/_mcp/constants.py,sha256=Ws8BujjgZWb5kPAVm4GLE_Rqse63MszHp863EWwoPCI,2487
86
+ huggingface_hub/inference/_mcp/mcp_client.py,sha256=dGp8PhN6aVw4bDnuSySFSiguHUiz-nzhgv89CVdO7pI,17243
87
+ huggingface_hub/inference/_mcp/types.py,sha256=yHNfPsM9MhD06oeKdkbmrBsW-3WhUeqA26fyfRfx_bk,929
88
+ huggingface_hub/inference/_mcp/utils.py,sha256=6XBYLikJ8lknx-k1QaG_uVoVYZ0yMzyo6WgtGp7Zdds,4175
89
+ huggingface_hub/inference/_providers/__init__.py,sha256=jLY5FNJO4WnHHrLsMv8e8vsEGPefrOVYy-Q-Igjr7mg,9974
90
+ huggingface_hub/inference/_providers/_common.py,sha256=Tt7oUZAtZ44hhM5xgNUSUVEmtkrkHbGyQ2y-kDUkPt0,13839
91
+ huggingface_hub/inference/_providers/black_forest_labs.py,sha256=vkjK_-4epSJa2-fLnbcXFzPAgQsGKhykKwd9Np-V2iw,2846
92
+ huggingface_hub/inference/_providers/cerebras.py,sha256=QOJ-1U-os7uE7p6eUnn_P_APq-yQhx28be7c3Tq2EuA,210
93
+ huggingface_hub/inference/_providers/clarifai.py,sha256=1cEXQwhGk4DRKiPCQUa5y-L6okTo4781EImQC8yJVOw,380
94
+ huggingface_hub/inference/_providers/cohere.py,sha256=GqUyCR4j6Re-_27ItwQF2p89Yya4e__EWDP9hTSs9w0,1247
95
+ huggingface_hub/inference/_providers/fal_ai.py,sha256=Dei4gy51q7oRk-0Vx50acv-0lud9dqSuwIVJrLhdlq8,11766
96
+ huggingface_hub/inference/_providers/featherless_ai.py,sha256=SceM3VsgzDSaCnzVxTFK6JepHaGStptdLlwrX-zsM2g,1376
97
+ huggingface_hub/inference/_providers/fireworks_ai.py,sha256=YfxC8wMU38qpv6xFc5HnHf6qK4x64nt-iwEDTip4C_U,1209
98
+ huggingface_hub/inference/_providers/groq.py,sha256=JTk2JV4ZOlaohho7zLAFQtk92kGVsPmLJ1hmzcwsqvQ,315
99
+ huggingface_hub/inference/_providers/hf_inference.py,sha256=dp15WQQNdbIJhLiRvH3PA651xdf7OjMx3R_1bjKqLxw,9534
100
+ huggingface_hub/inference/_providers/hyperbolic.py,sha256=LiAAiW7diy-ctrDKNYO_2N4Ght9wnvvD7hMo2NYbsNg,1979
101
+ huggingface_hub/inference/_providers/nebius.py,sha256=NQDJoNbFd9FPBA5yWTb_C42NoMeV8edpZCTRoXqtDOM,3574
102
+ huggingface_hub/inference/_providers/novita.py,sha256=AN4csxwKbRvNiaK87o9xVp9krL6mHPk6iv5iat87skA,2508
103
+ huggingface_hub/inference/_providers/nscale.py,sha256=RkyvmYtQbs2RPenF_pxDPMUMZM_botT21zqfVe2hT5Y,1796
104
+ huggingface_hub/inference/_providers/openai.py,sha256=GCVYeNdjWIgpQQ7E_Xv8IebmdhTi0S6WfFosz3nLtps,1089
105
+ huggingface_hub/inference/_providers/publicai.py,sha256=1I2W6rORloB5QHSvky4njZO2XKLTwA-kPdNoauoT5rg,210
106
+ huggingface_hub/inference/_providers/replicate.py,sha256=MBvjI-4IH8Antqr_8c3MRrBjAzElA3sAmEzeRVpIsPI,3814
107
+ huggingface_hub/inference/_providers/sambanova.py,sha256=t-J89tab8wut62jXSXl7pAK5mCrovwdgtvbDYK1DHis,2031
108
+ huggingface_hub/inference/_providers/scaleway.py,sha256=Jy81kXWbXCHBpx6xmyzdEfXGSyhUfjKOLHuDSvhHWGo,1209
109
+ huggingface_hub/inference/_providers/together.py,sha256=q32zFvXhmRogWXMSaEFVYS8m9blXI_oy7KPdeal7Wwg,3433
110
+ huggingface_hub/inference/_providers/wavespeed.py,sha256=908rHLPhrbbdmR4EDfkH58N8gg8zcoYy0bvHALbnGoU,5060
111
+ huggingface_hub/inference/_providers/zai_org.py,sha256=plGzMZuLrChZvgpS3CCPqI6ImotZZxNLgfxnR7v6tw8,646
112
+ huggingface_hub/serialization/__init__.py,sha256=jCiw_vVQYW52gwVfWiqgocf2Q19kGTQlRGVpf-4SLP8,963
113
+ huggingface_hub/serialization/_base.py,sha256=af1QBU_A3EKgAXvYCkENPyamL5Z7V5LxlIUoCxMsEYM,8097
114
+ huggingface_hub/serialization/_dduf.py,sha256=KpfM8D9w3UcAM0hhwYdnM8byIiZMUKQnTl25Wb1hHiw,15410
115
+ huggingface_hub/serialization/_torch.py,sha256=__M4aP9zuCJp9TAJLr0r-26LuSao2cofzeo2MPSe-VI,45124
116
+ huggingface_hub/templates/datasetcard_template.md,sha256=W-EMqR6wndbrnZorkVv56URWPG49l7MATGeI015kTvs,5503
117
+ huggingface_hub/templates/modelcard_template.md,sha256=4AqArS3cqdtbit5Bo-DhjcnDFR-pza5hErLLTPM4Yuc,6870
118
+ huggingface_hub/utils/__init__.py,sha256=WE5nh2AfvdET71MHhJEc8maZxYhsbPIdy1mkow-chDA,3846
119
+ huggingface_hub/utils/_auth.py,sha256=dtJXLgad9jyH33b3YOGFqbjV8Fi0PPR9GnBxgJqfKK4,8279
120
+ huggingface_hub/utils/_cache_assets.py,sha256=kai77HPQMfYpROouMBQCr_gdBCaeTm996Sqj0dExbNg,5728
121
+ huggingface_hub/utils/_cache_manager.py,sha256=1Yb3s4jIXudAV1H2nD7mmxi3CcUel8dCmXB06RiexLk,32991
122
+ huggingface_hub/utils/_chunk_utils.py,sha256=MH7-6FwCDZ8noV6dGRytCOJGSfcZmDBvsvVotdI8TvQ,2109
123
+ huggingface_hub/utils/_datetime.py,sha256=kCS5jaKV25kOncX1xujbXsz5iDLcjLcLw85semGNzxQ,2770
124
+ huggingface_hub/utils/_deprecation.py,sha256=4tWi3vBSdvnhA0z_Op-tkAQ0xrJ4TUb0HbPhMiXUnOs,4872
125
+ huggingface_hub/utils/_dotenv.py,sha256=2LLdzpA-LzLxO15GLb9WKT5IGrTurIRmFPrMX1yDzsU,2011
126
+ huggingface_hub/utils/_experimental.py,sha256=3-c8irbn9sJr2CwWbzhGkIrdXKg8_x7BifhHFy32ei8,2470
127
+ huggingface_hub/utils/_fixes.py,sha256=xQZzfwLqZV8-gNcw9mrZ-M1acA6NZHszI_-cSZIWN-U,3978
128
+ huggingface_hub/utils/_git_credential.py,sha256=gdQbYZyKEynpqLmtr8lSnCrfPTBzdFdmODmHIgivr4k,4612
129
+ huggingface_hub/utils/_headers.py,sha256=k_ApvA8fJGHc0yNp2IFY8wySM9MQ5UZEpjr1g-fpRJ4,8060
130
+ huggingface_hub/utils/_http.py,sha256=6dRcxQnVuTRcwW4AgdT_6pjFmvhsA_Pg1tp2f2awxwg,31524
131
+ huggingface_hub/utils/_lfs.py,sha256=EC0Oz6Wiwl8foRNkUOzrETXzAWlbgpnpxo5a410ovFY,3957
132
+ huggingface_hub/utils/_pagination.py,sha256=wEHEWhCu9vN5pv51t7ixSGe13g63kS6AJM4P53eY9M4,1894
133
+ huggingface_hub/utils/_parsing.py,sha256=T6UCjUh0h731A0Jh-eH5RWcqVQ5m0IyMcXHl5G2YNUs,3021
134
+ huggingface_hub/utils/_paths.py,sha256=WCR2WbqDJLdNlU4XZNXXNmGct3OiDwPesGYrq41T2wE,5036
135
+ huggingface_hub/utils/_runtime.py,sha256=YIbpExk5dxRXGbdwUjTJDBNnZIwo6_5xi4ZjVOPI6Vg,12595
136
+ huggingface_hub/utils/_safetensors.py,sha256=2_xbCsDPsCwR1tyBjJ5MoOHsX4ksocjzc4jS7oGe7_s,4439
137
+ huggingface_hub/utils/_subprocess.py,sha256=9qDWT1a2QF2TmXOQJDlPK6LwzYl9XjXeRadQPn15U14,4612
138
+ huggingface_hub/utils/_telemetry.py,sha256=nKHFBRBymGI8zWS7Qi0DZ_qUZRZc0fUbSLjfCaNghIU,4881
139
+ huggingface_hub/utils/_terminal.py,sha256=ai6nDaW8wqVMxf4gDy6wN9fyszYzKiCUrYu6lzWdR9M,2115
140
+ huggingface_hub/utils/_typing.py,sha256=cC9p6E8hG2LId8sFWJ9H-cpQozv3asuoww_XiA1-XWI,3617
141
+ huggingface_hub/utils/_validators.py,sha256=A3BkXbpX4KnUD2WFsYOgkXnYdpLiXXG8KbyNdq0qz78,8346
142
+ huggingface_hub/utils/_verification.py,sha256=KoAGX5YzdBT0DwqBcDW7QtzCdWiXOgsxJw9r0THyr4M,5496
143
+ huggingface_hub/utils/_xet.py,sha256=cVPjHSYL13qNuhr1T1DOyERy30WJJa-SonsAuwy1j8Q,8896
144
+ huggingface_hub/utils/_xet_progress_reporting.py,sha256=bxwanhLxigDASflFZVt7S8eENIviguyVg1Q9vFtmDf8,6169
145
+ huggingface_hub/utils/endpoint_helpers.py,sha256=9VtIAlxQ5H_4y30sjCAgbu7XCqAtNLC7aRYxaNn0hLI,2366
146
+ huggingface_hub/utils/insecure_hashlib.py,sha256=z3dVUFvdBZ8kQI_8Vzvvlr3ims-EBiY-SYPdnzIKOkw,1008
147
+ huggingface_hub/utils/logging.py,sha256=N6NXaCcbPbZSF-Oe-TY3ZnmkpmdFVyTOV8ASo-yVXLE,4916
148
+ huggingface_hub/utils/sha.py,sha256=OFnNGCba0sNcT2gUwaVCJnldxlltrHHe0DS_PCpV3C4,2134
149
+ huggingface_hub/utils/tqdm.py,sha256=lhdAR-4zn9cablCDS6240-O2vb4bdTfTbjUW684QWI4,10757
150
+ huggingface_hub-1.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
151
+ huggingface_hub-1.1.3.dist-info/METADATA,sha256=cKw3h13NNp9Iu7Wfazl5rJM7RNy7zgQd4wLjbSwBzMA,13856
152
+ huggingface_hub-1.1.3.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
153
+ huggingface_hub-1.1.3.dist-info/entry_points.txt,sha256=j3KnOggx2dIP7NUkPyYgXdRnLxd94aHmqJ8J6tEZwY8,154
154
+ huggingface_hub-1.1.3.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
155
+ huggingface_hub-1.1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.1)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,6 @@
1
+ [console_scripts]
2
+ hf = huggingface_hub.cli.hf:main
3
+ tiny-agents = huggingface_hub.inference._mcp.cli:app
4
+
5
+ [fsspec.specs]
6
+ hf = huggingface_hub.HfFileSystem
@@ -1,428 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2022-present, the HuggingFace Inc. team.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- """Contains command to delete some revisions from the HF cache directory.
16
-
17
- Usage:
18
- huggingface-cli delete-cache
19
- huggingface-cli delete-cache --disable-tui
20
- huggingface-cli delete-cache --dir ~/.cache/huggingface/hub
21
-
22
- NOTE:
23
- This command is based on `InquirerPy` to build the multiselect menu in the terminal.
24
- This dependency has to be installed with `pip install huggingface_hub[cli]`. Since
25
- we want to avoid as much as possible cross-platform issues, I chose a library that
26
- is built on top of `python-prompt-toolkit` which seems to be a reference in terminal
27
- GUI (actively maintained on both Unix and Windows, 7.9k stars).
28
-
29
- For the moment, the TUI feature is in beta.
30
-
31
- See:
32
- - https://github.com/kazhala/InquirerPy
33
- - https://inquirerpy.readthedocs.io/en/latest/
34
- - https://github.com/prompt-toolkit/python-prompt-toolkit
35
-
36
- Other solutions could have been:
37
- - `simple_term_menu`: would be good as well for our use case but some issues suggest
38
- that Windows is less supported.
39
- See: https://github.com/IngoMeyer441/simple-term-menu
40
- - `PyInquirer`: very similar to `InquirerPy` but older and not maintained anymore.
41
- In particular, no support of Python3.10.
42
- See: https://github.com/CITGuru/PyInquirer
43
- - `pick` (or `pickpack`): easy to use and flexible but built on top of Python's
44
- standard library `curses` that is specific to Unix (not implemented on Windows).
45
- See https://github.com/wong2/pick and https://github.com/anafvana/pickpack.
46
- - `inquirer`: lot of traction (700 stars) but explicitly states "experimental
47
- support of Windows". Not built on top of `python-prompt-toolkit`.
48
- See https://github.com/magmax/python-inquirer
49
-
50
- TODO: add support for `huggingface-cli delete-cache aaaaaa bbbbbb cccccc (...)` ?
51
- TODO: add "--keep-last" arg to delete revisions that are not on `main` ref
52
- TODO: add "--filter" arg to filter repositories by name ?
53
- TODO: add "--sort" arg to sort by size ?
54
- TODO: add "--limit" arg to limit to X repos ?
55
- TODO: add "-y" arg for immediate deletion ?
56
- See discussions in https://github.com/huggingface/huggingface_hub/issues/1025.
57
- """
58
-
59
- import os
60
- from argparse import Namespace, _SubParsersAction
61
- from functools import wraps
62
- from tempfile import mkstemp
63
- from typing import Any, Callable, Iterable, List, Optional, Union
64
-
65
- from ..utils import CachedRepoInfo, CachedRevisionInfo, HFCacheInfo, scan_cache_dir
66
- from . import BaseHuggingfaceCLICommand
67
- from ._cli_utils import ANSI
68
-
69
-
70
- try:
71
- from InquirerPy import inquirer
72
- from InquirerPy.base.control import Choice
73
- from InquirerPy.separator import Separator
74
-
75
- _inquirer_py_available = True
76
- except ImportError:
77
- _inquirer_py_available = False
78
-
79
-
80
- def require_inquirer_py(fn: Callable) -> Callable:
81
- """Decorator to flag methods that require `InquirerPy`."""
82
-
83
- # TODO: refactor this + imports in a unified pattern across codebase
84
- @wraps(fn)
85
- def _inner(*args, **kwargs):
86
- if not _inquirer_py_available:
87
- raise ImportError(
88
- "The `delete-cache` command requires extra dependencies to work with"
89
- " the TUI.\nPlease run `pip install huggingface_hub[cli]` to install"
90
- " them.\nOtherwise, disable TUI using the `--disable-tui` flag."
91
- )
92
-
93
- return fn(*args, **kwargs)
94
-
95
- return _inner
96
-
97
-
98
- # Possibility for the user to cancel deletion
99
- _CANCEL_DELETION_STR = "CANCEL_DELETION"
100
-
101
-
102
- class DeleteCacheCommand(BaseHuggingfaceCLICommand):
103
- @staticmethod
104
- def register_subcommand(parser: _SubParsersAction):
105
- delete_cache_parser = parser.add_parser("delete-cache", help="Delete revisions from the cache directory.")
106
-
107
- delete_cache_parser.add_argument(
108
- "--dir",
109
- type=str,
110
- default=None,
111
- help="cache directory (optional). Default to the default HuggingFace cache.",
112
- )
113
-
114
- delete_cache_parser.add_argument(
115
- "--disable-tui",
116
- action="store_true",
117
- help=(
118
- "Disable Terminal User Interface (TUI) mode. Useful if your"
119
- " platform/terminal doesn't support the multiselect menu."
120
- ),
121
- )
122
-
123
- delete_cache_parser.set_defaults(func=DeleteCacheCommand)
124
-
125
- def __init__(self, args: Namespace) -> None:
126
- self.cache_dir: Optional[str] = args.dir
127
- self.disable_tui: bool = args.disable_tui
128
-
129
- def run(self):
130
- """Run `delete-cache` command with or without TUI."""
131
- # Scan cache directory
132
- hf_cache_info = scan_cache_dir(self.cache_dir)
133
-
134
- # Manual review from the user
135
- if self.disable_tui:
136
- selected_hashes = _manual_review_no_tui(hf_cache_info, preselected=[])
137
- else:
138
- selected_hashes = _manual_review_tui(hf_cache_info, preselected=[])
139
-
140
- # If deletion is not cancelled
141
- if len(selected_hashes) > 0 and _CANCEL_DELETION_STR not in selected_hashes:
142
- confirm_message = _get_expectations_str(hf_cache_info, selected_hashes) + " Confirm deletion ?"
143
-
144
- # Confirm deletion
145
- if self.disable_tui:
146
- confirmed = _ask_for_confirmation_no_tui(confirm_message)
147
- else:
148
- confirmed = _ask_for_confirmation_tui(confirm_message)
149
-
150
- # Deletion is confirmed
151
- if confirmed:
152
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
153
- print("Start deletion.")
154
- strategy.execute()
155
- print(
156
- f"Done. Deleted {len(strategy.repos)} repo(s) and"
157
- f" {len(strategy.snapshots)} revision(s) for a total of"
158
- f" {strategy.expected_freed_size_str}."
159
- )
160
- return
161
-
162
- # Deletion is cancelled
163
- print("Deletion is cancelled. Do nothing.")
164
-
165
-
166
- @require_inquirer_py
167
- def _manual_review_tui(hf_cache_info: HFCacheInfo, preselected: List[str]) -> List[str]:
168
- """Ask the user for a manual review of the revisions to delete.
169
-
170
- Displays a multi-select menu in the terminal (TUI).
171
- """
172
- # Define multiselect list
173
- choices = _get_tui_choices_from_scan(repos=hf_cache_info.repos, preselected=preselected)
174
- checkbox = inquirer.checkbox(
175
- message="Select revisions to delete:",
176
- choices=choices, # List of revisions with some pre-selection
177
- cycle=False, # No loop between top and bottom
178
- height=100, # Large list if possible
179
- # We use the instruction to display to the user the expected effect of the
180
- # deletion.
181
- instruction=_get_expectations_str(
182
- hf_cache_info,
183
- selected_hashes=[c.value for c in choices if isinstance(c, Choice) and c.enabled],
184
- ),
185
- # We use the long instruction to should keybindings instructions to the user
186
- long_instruction="Press <space> to select, <enter> to validate and <ctrl+c> to quit without modification.",
187
- # Message that is displayed once the user validates its selection.
188
- transformer=lambda result: f"{len(result)} revision(s) selected.",
189
- )
190
-
191
- # Add a callback to update the information line when a revision is
192
- # selected/unselected
193
- def _update_expectations(_) -> None:
194
- # Hacky way to dynamically set an instruction message to the checkbox when
195
- # a revision hash is selected/unselected.
196
- checkbox._instruction = _get_expectations_str(
197
- hf_cache_info,
198
- selected_hashes=[choice["value"] for choice in checkbox.content_control.choices if choice["enabled"]],
199
- )
200
-
201
- checkbox.kb_func_lookup["toggle"].append({"func": _update_expectations})
202
-
203
- # Finally display the form to the user.
204
- try:
205
- return checkbox.execute()
206
- except KeyboardInterrupt:
207
- return [] # Quit without deletion
208
-
209
-
210
- @require_inquirer_py
211
- def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
212
- """Ask for confirmation using Inquirer."""
213
- return inquirer.confirm(message, default=default).execute()
214
-
215
-
216
- def _get_tui_choices_from_scan(repos: Iterable[CachedRepoInfo], preselected: List[str]) -> List:
217
- """Build a list of choices from the scanned repos.
218
-
219
- Args:
220
- repos (*Iterable[`CachedRepoInfo`]*):
221
- List of scanned repos on which we want to delete revisions.
222
- preselected (*List[`str`]*):
223
- List of revision hashes that will be preselected.
224
-
225
- Return:
226
- The list of choices to pass to `inquirer.checkbox`.
227
- """
228
- choices: List[Union[Choice, Separator]] = []
229
-
230
- # First choice is to cancel the deletion. If selected, nothing will be deleted,
231
- # no matter the other selected items.
232
- choices.append(
233
- Choice(
234
- _CANCEL_DELETION_STR,
235
- name="None of the following (if selected, nothing will be deleted).",
236
- enabled=False,
237
- )
238
- )
239
-
240
- # Display a separator per repo and a Choice for each revisions of the repo
241
- for repo in sorted(repos, key=_repo_sorting_order):
242
- # Repo as separator
243
- choices.append(
244
- Separator(
245
- f"\n{repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
246
- f" used {repo.last_accessed_str})"
247
- )
248
- )
249
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
250
- # Revision as choice
251
- choices.append(
252
- Choice(
253
- revision.commit_hash,
254
- name=(
255
- f"{revision.commit_hash[:8]}:"
256
- f" {', '.join(sorted(revision.refs)) or '(detached)'} #"
257
- f" modified {revision.last_modified_str}"
258
- ),
259
- enabled=revision.commit_hash in preselected,
260
- )
261
- )
262
-
263
- # Return choices
264
- return choices
265
-
266
-
267
- def _manual_review_no_tui(hf_cache_info: HFCacheInfo, preselected: List[str]) -> List[str]:
268
- """Ask the user for a manual review of the revisions to delete.
269
-
270
- Used when TUI is disabled. Manual review happens in a separate tmp file that the
271
- user can manually edit.
272
- """
273
- # 1. Generate temporary file with delete commands.
274
- fd, tmp_path = mkstemp(suffix=".txt") # suffix to make it easier to find by editors
275
- os.close(fd)
276
-
277
- lines = []
278
- for repo in sorted(hf_cache_info.repos, key=_repo_sorting_order):
279
- lines.append(
280
- f"\n# {repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
281
- f" used {repo.last_accessed_str})"
282
- )
283
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
284
- lines.append(
285
- # Deselect by prepending a '#'
286
- f"{'' if revision.commit_hash in preselected else '#'} "
287
- f" {revision.commit_hash} # Refs:"
288
- # Print `refs` as comment on same line
289
- f" {', '.join(sorted(revision.refs)) or '(detached)'} # modified"
290
- # Print `last_modified` as comment on same line
291
- f" {revision.last_modified_str}"
292
- )
293
-
294
- with open(tmp_path, "w") as f:
295
- f.write(_MANUAL_REVIEW_NO_TUI_INSTRUCTIONS)
296
- f.write("\n".join(lines))
297
-
298
- # 2. Prompt instructions to user.
299
- instructions = f"""
300
- TUI is disabled. In order to select which revisions you want to delete, please edit
301
- the following file using the text editor of your choice. Instructions for manual
302
- editing are located at the beginning of the file. Edit the file, save it and confirm
303
- to continue.
304
- File to edit: {ANSI.bold(tmp_path)}
305
- """
306
- print("\n".join(line.strip() for line in instructions.strip().split("\n")))
307
-
308
- # 3. Wait for user confirmation.
309
- while True:
310
- selected_hashes = _read_manual_review_tmp_file(tmp_path)
311
- if _ask_for_confirmation_no_tui(
312
- _get_expectations_str(hf_cache_info, selected_hashes) + " Continue ?",
313
- default=False,
314
- ):
315
- break
316
-
317
- # 4. Return selected_hashes
318
- os.remove(tmp_path)
319
- return selected_hashes
320
-
321
-
322
- def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
323
- """Ask for confirmation using pure-python."""
324
- YES = ("y", "yes", "1")
325
- NO = ("n", "no", "0")
326
- DEFAULT = ""
327
- ALL = YES + NO + (DEFAULT,)
328
- full_message = message + (" (Y/n) " if default else " (y/N) ")
329
- while True:
330
- answer = input(full_message).lower()
331
- if answer == DEFAULT:
332
- return default
333
- if answer in YES:
334
- return True
335
- if answer in NO:
336
- return False
337
- print(f"Invalid input. Must be one of {ALL}")
338
-
339
-
340
- def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]) -> str:
341
- """Format a string to display to the user how much space would be saved.
342
-
343
- Example:
344
- ```
345
- >>> _get_expectations_str(hf_cache_info, selected_hashes)
346
- '7 revisions selected counting for 4.3G.'
347
- ```
348
- """
349
- if _CANCEL_DELETION_STR in selected_hashes:
350
- return "Nothing will be deleted."
351
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
352
- return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
353
-
354
-
355
- def _read_manual_review_tmp_file(tmp_path: str) -> List[str]:
356
- """Read the manually reviewed instruction file and return a list of revision hash.
357
-
358
- Example:
359
- ```txt
360
- # This is the tmp file content
361
- ###
362
-
363
- # Commented out line
364
- 123456789 # revision hash
365
-
366
- # Something else
367
- # a_newer_hash # 2 days ago
368
- an_older_hash # 3 days ago
369
- ```
370
-
371
- ```py
372
- >>> _read_manual_review_tmp_file(tmp_path)
373
- ['123456789', 'an_older_hash']
374
- ```
375
- """
376
- with open(tmp_path) as f:
377
- content = f.read()
378
-
379
- # Split lines
380
- lines = [line.strip() for line in content.split("\n")]
381
-
382
- # Filter commented lines
383
- selected_lines = [line for line in lines if not line.startswith("#")]
384
-
385
- # Select only before comment
386
- selected_hashes = [line.split("#")[0].strip() for line in selected_lines]
387
-
388
- # Return revision hashes
389
- return [hash for hash in selected_hashes if len(hash) > 0]
390
-
391
-
392
- _MANUAL_REVIEW_NO_TUI_INSTRUCTIONS = f"""
393
- # INSTRUCTIONS
394
- # ------------
395
- # This is a temporary file created by running `huggingface-cli delete-cache` with the
396
- # `--disable-tui` option. It contains a set of revisions that can be deleted from your
397
- # local cache directory.
398
- #
399
- # Please manually review the revisions you want to delete:
400
- # - Revision hashes can be commented out with '#'.
401
- # - Only non-commented revisions in this file will be deleted.
402
- # - Revision hashes that are removed from this file are ignored as well.
403
- # - If `{_CANCEL_DELETION_STR}` line is uncommented, the all cache deletion is cancelled and
404
- # no changes will be applied.
405
- #
406
- # Once you've manually reviewed this file, please confirm deletion in the terminal. This
407
- # file will be automatically removed once done.
408
- # ------------
409
-
410
- # KILL SWITCH
411
- # ------------
412
- # Un-comment following line to completely cancel the deletion process
413
- # {_CANCEL_DELETION_STR}
414
- # ------------
415
-
416
- # REVISIONS
417
- # ------------
418
- """.strip()
419
-
420
-
421
- def _repo_sorting_order(repo: CachedRepoInfo) -> Any:
422
- # First split by Dataset/Model, then sort by last accessed (oldest first)
423
- return (repo.repo_type, repo.last_accessed)
424
-
425
-
426
- def _revision_sorting_order(revision: CachedRevisionInfo) -> Any:
427
- # Sort by last modified (oldest first)
428
- return revision.last_modified