huggingface-hub 0.31.0rc0__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 (150) hide show
  1. huggingface_hub/__init__.py +145 -46
  2. huggingface_hub/_commit_api.py +168 -119
  3. huggingface_hub/_commit_scheduler.py +15 -15
  4. huggingface_hub/_inference_endpoints.py +15 -12
  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 +239 -80
  10. huggingface_hub/_space_api.py +5 -5
  11. huggingface_hub/_tensorboard_logger.py +15 -19
  12. huggingface_hub/_upload_large_folder.py +172 -76
  13. huggingface_hub/_webhooks_payload.py +3 -3
  14. huggingface_hub/_webhooks_server.py +13 -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 +38 -53
  31. huggingface_hub/dataclasses.py +609 -0
  32. huggingface_hub/errors.py +80 -30
  33. huggingface_hub/fastai_utils.py +30 -41
  34. huggingface_hub/file_download.py +435 -351
  35. huggingface_hub/hf_api.py +2050 -1124
  36. huggingface_hub/hf_file_system.py +269 -152
  37. huggingface_hub/hub_mixin.py +43 -63
  38. huggingface_hub/inference/_client.py +347 -434
  39. huggingface_hub/inference/_common.py +133 -121
  40. huggingface_hub/inference/_generated/_async_client.py +397 -541
  41. huggingface_hub/inference/_generated/types/__init__.py +5 -1
  42. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +3 -3
  43. huggingface_hub/inference/_generated/types/base.py +10 -7
  44. huggingface_hub/inference/_generated/types/chat_completion.py +59 -23
  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 +6 -2
  50. huggingface_hub/inference/_generated/types/image_to_video.py +60 -0
  51. huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
  52. huggingface_hub/inference/_generated/types/summarization.py +2 -2
  53. huggingface_hub/inference/_generated/types/table_question_answering.py +5 -5
  54. huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
  55. huggingface_hub/inference/_generated/types/text_generation.py +10 -10
  56. huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
  57. huggingface_hub/inference/_generated/types/token_classification.py +2 -2
  58. huggingface_hub/inference/_generated/types/translation.py +2 -2
  59. huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
  60. huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
  61. huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
  62. huggingface_hub/inference/_mcp/__init__.py +0 -0
  63. huggingface_hub/inference/_mcp/_cli_hacks.py +88 -0
  64. huggingface_hub/inference/_mcp/agent.py +100 -0
  65. huggingface_hub/inference/_mcp/cli.py +247 -0
  66. huggingface_hub/inference/_mcp/constants.py +81 -0
  67. huggingface_hub/inference/_mcp/mcp_client.py +395 -0
  68. huggingface_hub/inference/_mcp/types.py +45 -0
  69. huggingface_hub/inference/_mcp/utils.py +128 -0
  70. huggingface_hub/inference/_providers/__init__.py +82 -7
  71. huggingface_hub/inference/_providers/_common.py +129 -27
  72. huggingface_hub/inference/_providers/black_forest_labs.py +6 -6
  73. huggingface_hub/inference/_providers/cerebras.py +1 -1
  74. huggingface_hub/inference/_providers/clarifai.py +13 -0
  75. huggingface_hub/inference/_providers/cohere.py +20 -3
  76. huggingface_hub/inference/_providers/fal_ai.py +183 -56
  77. huggingface_hub/inference/_providers/featherless_ai.py +38 -0
  78. huggingface_hub/inference/_providers/fireworks_ai.py +18 -0
  79. huggingface_hub/inference/_providers/groq.py +9 -0
  80. huggingface_hub/inference/_providers/hf_inference.py +69 -30
  81. huggingface_hub/inference/_providers/hyperbolic.py +4 -4
  82. huggingface_hub/inference/_providers/nebius.py +33 -5
  83. huggingface_hub/inference/_providers/novita.py +5 -5
  84. huggingface_hub/inference/_providers/nscale.py +44 -0
  85. huggingface_hub/inference/_providers/openai.py +3 -1
  86. huggingface_hub/inference/_providers/publicai.py +6 -0
  87. huggingface_hub/inference/_providers/replicate.py +31 -13
  88. huggingface_hub/inference/_providers/sambanova.py +18 -4
  89. huggingface_hub/inference/_providers/scaleway.py +28 -0
  90. huggingface_hub/inference/_providers/together.py +20 -5
  91. huggingface_hub/inference/_providers/wavespeed.py +138 -0
  92. huggingface_hub/inference/_providers/zai_org.py +17 -0
  93. huggingface_hub/lfs.py +33 -100
  94. huggingface_hub/repocard.py +34 -38
  95. huggingface_hub/repocard_data.py +57 -57
  96. huggingface_hub/serialization/__init__.py +0 -1
  97. huggingface_hub/serialization/_base.py +12 -15
  98. huggingface_hub/serialization/_dduf.py +8 -8
  99. huggingface_hub/serialization/_torch.py +69 -69
  100. huggingface_hub/utils/__init__.py +19 -8
  101. huggingface_hub/utils/_auth.py +7 -7
  102. huggingface_hub/utils/_cache_manager.py +92 -147
  103. huggingface_hub/utils/_chunk_utils.py +2 -3
  104. huggingface_hub/utils/_deprecation.py +1 -1
  105. huggingface_hub/utils/_dotenv.py +55 -0
  106. huggingface_hub/utils/_experimental.py +7 -5
  107. huggingface_hub/utils/_fixes.py +0 -10
  108. huggingface_hub/utils/_git_credential.py +5 -5
  109. huggingface_hub/utils/_headers.py +8 -30
  110. huggingface_hub/utils/_http.py +398 -239
  111. huggingface_hub/utils/_pagination.py +4 -4
  112. huggingface_hub/utils/_parsing.py +98 -0
  113. huggingface_hub/utils/_paths.py +5 -5
  114. huggingface_hub/utils/_runtime.py +61 -24
  115. huggingface_hub/utils/_safetensors.py +21 -21
  116. huggingface_hub/utils/_subprocess.py +9 -9
  117. huggingface_hub/utils/_telemetry.py +4 -4
  118. huggingface_hub/{commands/_cli_utils.py → utils/_terminal.py} +4 -4
  119. huggingface_hub/utils/_typing.py +25 -5
  120. huggingface_hub/utils/_validators.py +55 -74
  121. huggingface_hub/utils/_verification.py +167 -0
  122. huggingface_hub/utils/_xet.py +64 -17
  123. huggingface_hub/utils/_xet_progress_reporting.py +162 -0
  124. huggingface_hub/utils/insecure_hashlib.py +3 -5
  125. huggingface_hub/utils/logging.py +8 -11
  126. huggingface_hub/utils/tqdm.py +5 -4
  127. {huggingface_hub-0.31.0rc0.dist-info → huggingface_hub-1.1.3.dist-info}/METADATA +94 -85
  128. huggingface_hub-1.1.3.dist-info/RECORD +155 -0
  129. {huggingface_hub-0.31.0rc0.dist-info → huggingface_hub-1.1.3.dist-info}/WHEEL +1 -1
  130. huggingface_hub-1.1.3.dist-info/entry_points.txt +6 -0
  131. huggingface_hub/commands/delete_cache.py +0 -474
  132. huggingface_hub/commands/download.py +0 -200
  133. huggingface_hub/commands/huggingface_cli.py +0 -61
  134. huggingface_hub/commands/lfs.py +0 -200
  135. huggingface_hub/commands/repo_files.py +0 -128
  136. huggingface_hub/commands/scan_cache.py +0 -181
  137. huggingface_hub/commands/tag.py +0 -159
  138. huggingface_hub/commands/upload.py +0 -314
  139. huggingface_hub/commands/upload_large_folder.py +0 -129
  140. huggingface_hub/commands/user.py +0 -304
  141. huggingface_hub/commands/version.py +0 -37
  142. huggingface_hub/inference_api.py +0 -217
  143. huggingface_hub/keras_mixin.py +0 -500
  144. huggingface_hub/repository.py +0 -1477
  145. huggingface_hub/serialization/_tensorflow.py +0 -95
  146. huggingface_hub/utils/_hf_folder.py +0 -68
  147. huggingface_hub-0.31.0rc0.dist-info/RECORD +0 -135
  148. huggingface_hub-0.31.0rc0.dist-info/entry_points.txt +0 -6
  149. {huggingface_hub-0.31.0rc0.dist-info → huggingface_hub-1.1.3.dist-info/licenses}/LICENSE +0 -0
  150. {huggingface_hub-0.31.0rc0.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,474 +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
- huggingface-cli delete-cache --sort=size
22
-
23
- NOTE:
24
- This command is based on `InquirerPy` to build the multiselect menu in the terminal.
25
- This dependency has to be installed with `pip install huggingface_hub[cli]`. Since
26
- we want to avoid as much as possible cross-platform issues, I chose a library that
27
- is built on top of `python-prompt-toolkit` which seems to be a reference in terminal
28
- GUI (actively maintained on both Unix and Windows, 7.9k stars).
29
-
30
- For the moment, the TUI feature is in beta.
31
-
32
- See:
33
- - https://github.com/kazhala/InquirerPy
34
- - https://inquirerpy.readthedocs.io/en/latest/
35
- - https://github.com/prompt-toolkit/python-prompt-toolkit
36
-
37
- Other solutions could have been:
38
- - `simple_term_menu`: would be good as well for our use case but some issues suggest
39
- that Windows is less supported.
40
- See: https://github.com/IngoMeyer441/simple-term-menu
41
- - `PyInquirer`: very similar to `InquirerPy` but older and not maintained anymore.
42
- In particular, no support of Python3.10.
43
- See: https://github.com/CITGuru/PyInquirer
44
- - `pick` (or `pickpack`): easy to use and flexible but built on top of Python's
45
- standard library `curses` that is specific to Unix (not implemented on Windows).
46
- See https://github.com/wong2/pick and https://github.com/anafvana/pickpack.
47
- - `inquirer`: lot of traction (700 stars) but explicitly states "experimental
48
- support of Windows". Not built on top of `python-prompt-toolkit`.
49
- See https://github.com/magmax/python-inquirer
50
-
51
- TODO: add support for `huggingface-cli delete-cache aaaaaa bbbbbb cccccc (...)` ?
52
- TODO: add "--keep-last" arg to delete revisions that are not on `main` ref
53
- TODO: add "--filter" arg to filter repositories by name ?
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, Literal, 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
- SortingOption_T = Literal["alphabetical", "lastUpdated", "lastUsed", "size"]
80
-
81
-
82
- def require_inquirer_py(fn: Callable) -> Callable:
83
- """Decorator to flag methods that require `InquirerPy`."""
84
-
85
- # TODO: refactor this + imports in a unified pattern across codebase
86
- @wraps(fn)
87
- def _inner(*args, **kwargs):
88
- if not _inquirer_py_available:
89
- raise ImportError(
90
- "The `delete-cache` command requires extra dependencies to work with"
91
- " the TUI.\nPlease run `pip install huggingface_hub[cli]` to install"
92
- " them.\nOtherwise, disable TUI using the `--disable-tui` flag."
93
- )
94
-
95
- return fn(*args, **kwargs)
96
-
97
- return _inner
98
-
99
-
100
- # Possibility for the user to cancel deletion
101
- _CANCEL_DELETION_STR = "CANCEL_DELETION"
102
-
103
-
104
- class DeleteCacheCommand(BaseHuggingfaceCLICommand):
105
- @staticmethod
106
- def register_subcommand(parser: _SubParsersAction):
107
- delete_cache_parser = parser.add_parser("delete-cache", help="Delete revisions from the cache directory.")
108
-
109
- delete_cache_parser.add_argument(
110
- "--dir",
111
- type=str,
112
- default=None,
113
- help="cache directory (optional). Default to the default HuggingFace cache.",
114
- )
115
-
116
- delete_cache_parser.add_argument(
117
- "--disable-tui",
118
- action="store_true",
119
- help=(
120
- "Disable Terminal User Interface (TUI) mode. Useful if your"
121
- " platform/terminal doesn't support the multiselect menu."
122
- ),
123
- )
124
-
125
- delete_cache_parser.add_argument(
126
- "--sort",
127
- nargs="?",
128
- choices=["alphabetical", "lastUpdated", "lastUsed", "size"],
129
- help=(
130
- "Sort repositories by the specified criteria. Options: "
131
- "'alphabetical' (A-Z), "
132
- "'lastUpdated' (newest first), "
133
- "'lastUsed' (most recent first), "
134
- "'size' (largest first)."
135
- ),
136
- )
137
-
138
- delete_cache_parser.set_defaults(func=DeleteCacheCommand)
139
-
140
- def __init__(self, args: Namespace) -> None:
141
- self.cache_dir: Optional[str] = args.dir
142
- self.disable_tui: bool = args.disable_tui
143
- self.sort_by: Optional[SortingOption_T] = args.sort
144
-
145
- def run(self):
146
- """Run `delete-cache` command with or without TUI."""
147
- # Scan cache directory
148
- hf_cache_info = scan_cache_dir(self.cache_dir)
149
-
150
- # Manual review from the user
151
- if self.disable_tui:
152
- selected_hashes = _manual_review_no_tui(hf_cache_info, preselected=[], sort_by=self.sort_by)
153
- else:
154
- selected_hashes = _manual_review_tui(hf_cache_info, preselected=[], sort_by=self.sort_by)
155
-
156
- # If deletion is not cancelled
157
- if len(selected_hashes) > 0 and _CANCEL_DELETION_STR not in selected_hashes:
158
- confirm_message = _get_expectations_str(hf_cache_info, selected_hashes) + " Confirm deletion ?"
159
-
160
- # Confirm deletion
161
- if self.disable_tui:
162
- confirmed = _ask_for_confirmation_no_tui(confirm_message)
163
- else:
164
- confirmed = _ask_for_confirmation_tui(confirm_message)
165
-
166
- # Deletion is confirmed
167
- if confirmed:
168
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
169
- print("Start deletion.")
170
- strategy.execute()
171
- print(
172
- f"Done. Deleted {len(strategy.repos)} repo(s) and"
173
- f" {len(strategy.snapshots)} revision(s) for a total of"
174
- f" {strategy.expected_freed_size_str}."
175
- )
176
- return
177
-
178
- # Deletion is cancelled
179
- print("Deletion is cancelled. Do nothing.")
180
-
181
-
182
- def _get_repo_sorting_key(repo: CachedRepoInfo, sort_by: Optional[SortingOption_T] = None):
183
- if sort_by == "alphabetical":
184
- return (repo.repo_type, repo.repo_id.lower()) # by type then name
185
- elif sort_by == "lastUpdated":
186
- return -max(rev.last_modified for rev in repo.revisions) # newest first
187
- elif sort_by == "lastUsed":
188
- return -repo.last_accessed # most recently used first
189
- elif sort_by == "size":
190
- return -repo.size_on_disk # largest first
191
- else:
192
- return (repo.repo_type, repo.repo_id) # default stable order
193
-
194
-
195
- @require_inquirer_py
196
- def _manual_review_tui(
197
- hf_cache_info: HFCacheInfo,
198
- preselected: List[str],
199
- sort_by: Optional[SortingOption_T] = None,
200
- ) -> List[str]:
201
- """Ask the user for a manual review of the revisions to delete.
202
-
203
- Displays a multi-select menu in the terminal (TUI).
204
- """
205
- # Define multiselect list
206
- choices = _get_tui_choices_from_scan(
207
- repos=hf_cache_info.repos,
208
- preselected=preselected,
209
- sort_by=sort_by,
210
- )
211
- checkbox = inquirer.checkbox(
212
- message="Select revisions to delete:",
213
- choices=choices, # List of revisions with some pre-selection
214
- cycle=False, # No loop between top and bottom
215
- height=100, # Large list if possible
216
- # We use the instruction to display to the user the expected effect of the
217
- # deletion.
218
- instruction=_get_expectations_str(
219
- hf_cache_info,
220
- selected_hashes=[c.value for c in choices if isinstance(c, Choice) and c.enabled],
221
- ),
222
- # We use the long instruction to should keybindings instructions to the user
223
- long_instruction="Press <space> to select, <enter> to validate and <ctrl+c> to quit without modification.",
224
- # Message that is displayed once the user validates its selection.
225
- transformer=lambda result: f"{len(result)} revision(s) selected.",
226
- )
227
-
228
- # Add a callback to update the information line when a revision is
229
- # selected/unselected
230
- def _update_expectations(_) -> None:
231
- # Hacky way to dynamically set an instruction message to the checkbox when
232
- # a revision hash is selected/unselected.
233
- checkbox._instruction = _get_expectations_str(
234
- hf_cache_info,
235
- selected_hashes=[choice["value"] for choice in checkbox.content_control.choices if choice["enabled"]],
236
- )
237
-
238
- checkbox.kb_func_lookup["toggle"].append({"func": _update_expectations})
239
-
240
- # Finally display the form to the user.
241
- try:
242
- return checkbox.execute()
243
- except KeyboardInterrupt:
244
- return [] # Quit without deletion
245
-
246
-
247
- @require_inquirer_py
248
- def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
249
- """Ask for confirmation using Inquirer."""
250
- return inquirer.confirm(message, default=default).execute()
251
-
252
-
253
- def _get_tui_choices_from_scan(
254
- repos: Iterable[CachedRepoInfo],
255
- preselected: List[str],
256
- sort_by: Optional[SortingOption_T] = None,
257
- ) -> List:
258
- """Build a list of choices from the scanned repos.
259
-
260
- Args:
261
- repos (*Iterable[`CachedRepoInfo`]*):
262
- List of scanned repos on which we want to delete revisions.
263
- preselected (*List[`str`]*):
264
- List of revision hashes that will be preselected.
265
- sort_by (*Optional[SortingOption_T]*):
266
- Sorting direction. Choices: "alphabetical", "lastUpdated", "lastUsed", "size".
267
-
268
- Return:
269
- The list of choices to pass to `inquirer.checkbox`.
270
- """
271
- choices: List[Union[Choice, Separator]] = []
272
-
273
- # First choice is to cancel the deletion
274
- choices.append(
275
- Choice(
276
- _CANCEL_DELETION_STR,
277
- name="None of the following (if selected, nothing will be deleted).",
278
- enabled=False,
279
- )
280
- )
281
-
282
- # Sort repos based on specified criteria
283
- sorted_repos = sorted(repos, key=lambda repo: _get_repo_sorting_key(repo, sort_by))
284
-
285
- for repo in sorted_repos:
286
- # Repo as separator
287
- choices.append(
288
- Separator(
289
- f"\n{repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
290
- f" used {repo.last_accessed_str})"
291
- )
292
- )
293
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
294
- # Revision as choice
295
- choices.append(
296
- Choice(
297
- revision.commit_hash,
298
- name=(
299
- f"{revision.commit_hash[:8]}:"
300
- f" {', '.join(sorted(revision.refs)) or '(detached)'} #"
301
- f" modified {revision.last_modified_str}"
302
- ),
303
- enabled=revision.commit_hash in preselected,
304
- )
305
- )
306
-
307
- # Return choices
308
- return choices
309
-
310
-
311
- def _manual_review_no_tui(
312
- hf_cache_info: HFCacheInfo,
313
- preselected: List[str],
314
- sort_by: Optional[SortingOption_T] = None,
315
- ) -> List[str]:
316
- """Ask the user for a manual review of the revisions to delete.
317
-
318
- Used when TUI is disabled. Manual review happens in a separate tmp file that the
319
- user can manually edit.
320
- """
321
- # 1. Generate temporary file with delete commands.
322
- fd, tmp_path = mkstemp(suffix=".txt") # suffix to make it easier to find by editors
323
- os.close(fd)
324
-
325
- lines = []
326
-
327
- sorted_repos = sorted(hf_cache_info.repos, key=lambda repo: _get_repo_sorting_key(repo, sort_by))
328
-
329
- for repo in sorted_repos:
330
- lines.append(
331
- f"\n# {repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
332
- f" used {repo.last_accessed_str})"
333
- )
334
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
335
- lines.append(
336
- # Deselect by prepending a '#'
337
- f"{'' if revision.commit_hash in preselected else '#'} "
338
- f" {revision.commit_hash} # Refs:"
339
- # Print `refs` as comment on same line
340
- f" {', '.join(sorted(revision.refs)) or '(detached)'} # modified"
341
- # Print `last_modified` as comment on same line
342
- f" {revision.last_modified_str}"
343
- )
344
-
345
- with open(tmp_path, "w") as f:
346
- f.write(_MANUAL_REVIEW_NO_TUI_INSTRUCTIONS)
347
- f.write("\n".join(lines))
348
-
349
- # 2. Prompt instructions to user.
350
- instructions = f"""
351
- TUI is disabled. In order to select which revisions you want to delete, please edit
352
- the following file using the text editor of your choice. Instructions for manual
353
- editing are located at the beginning of the file. Edit the file, save it and confirm
354
- to continue.
355
- File to edit: {ANSI.bold(tmp_path)}
356
- """
357
- print("\n".join(line.strip() for line in instructions.strip().split("\n")))
358
-
359
- # 3. Wait for user confirmation.
360
- while True:
361
- selected_hashes = _read_manual_review_tmp_file(tmp_path)
362
- if _ask_for_confirmation_no_tui(
363
- _get_expectations_str(hf_cache_info, selected_hashes) + " Continue ?",
364
- default=False,
365
- ):
366
- break
367
-
368
- # 4. Return selected_hashes sorted to maintain stable order
369
- os.remove(tmp_path)
370
- return sorted(selected_hashes) # Sort to maintain stable order
371
-
372
-
373
- def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
374
- """Ask for confirmation using pure-python."""
375
- YES = ("y", "yes", "1")
376
- NO = ("n", "no", "0")
377
- DEFAULT = ""
378
- ALL = YES + NO + (DEFAULT,)
379
- full_message = message + (" (Y/n) " if default else " (y/N) ")
380
- while True:
381
- answer = input(full_message).lower()
382
- if answer == DEFAULT:
383
- return default
384
- if answer in YES:
385
- return True
386
- if answer in NO:
387
- return False
388
- print(f"Invalid input. Must be one of {ALL}")
389
-
390
-
391
- def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]) -> str:
392
- """Format a string to display to the user how much space would be saved.
393
-
394
- Example:
395
- ```
396
- >>> _get_expectations_str(hf_cache_info, selected_hashes)
397
- '7 revisions selected counting for 4.3G.'
398
- ```
399
- """
400
- if _CANCEL_DELETION_STR in selected_hashes:
401
- return "Nothing will be deleted."
402
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
403
- return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
404
-
405
-
406
- def _read_manual_review_tmp_file(tmp_path: str) -> List[str]:
407
- """Read the manually reviewed instruction file and return a list of revision hash.
408
-
409
- Example:
410
- ```txt
411
- # This is the tmp file content
412
- ###
413
-
414
- # Commented out line
415
- 123456789 # revision hash
416
-
417
- # Something else
418
- # a_newer_hash # 2 days ago
419
- an_older_hash # 3 days ago
420
- ```
421
-
422
- ```py
423
- >>> _read_manual_review_tmp_file(tmp_path)
424
- ['123456789', 'an_older_hash']
425
- ```
426
- """
427
- with open(tmp_path) as f:
428
- content = f.read()
429
-
430
- # Split lines
431
- lines = [line.strip() for line in content.split("\n")]
432
-
433
- # Filter commented lines
434
- selected_lines = [line for line in lines if not line.startswith("#")]
435
-
436
- # Select only before comment
437
- selected_hashes = [line.split("#")[0].strip() for line in selected_lines]
438
-
439
- # Return revision hashes
440
- return [hash for hash in selected_hashes if len(hash) > 0]
441
-
442
-
443
- _MANUAL_REVIEW_NO_TUI_INSTRUCTIONS = f"""
444
- # INSTRUCTIONS
445
- # ------------
446
- # This is a temporary file created by running `huggingface-cli delete-cache` with the
447
- # `--disable-tui` option. It contains a set of revisions that can be deleted from your
448
- # local cache directory.
449
- #
450
- # Please manually review the revisions you want to delete:
451
- # - Revision hashes can be commented out with '#'.
452
- # - Only non-commented revisions in this file will be deleted.
453
- # - Revision hashes that are removed from this file are ignored as well.
454
- # - If `{_CANCEL_DELETION_STR}` line is uncommented, the all cache deletion is cancelled and
455
- # no changes will be applied.
456
- #
457
- # Once you've manually reviewed this file, please confirm deletion in the terminal. This
458
- # file will be automatically removed once done.
459
- # ------------
460
-
461
- # KILL SWITCH
462
- # ------------
463
- # Un-comment following line to completely cancel the deletion process
464
- # {_CANCEL_DELETION_STR}
465
- # ------------
466
-
467
- # REVISIONS
468
- # ------------
469
- """.strip()
470
-
471
-
472
- def _revision_sorting_order(revision: CachedRevisionInfo) -> Any:
473
- # Sort by last modified (oldest first)
474
- return revision.last_modified