huggingface-hub 0.36.0__py3-none-any.whl → 1.0.0__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.

Potentially problematic release.


This version of huggingface-hub might be problematic. Click here for more details.

Files changed (132) hide show
  1. huggingface_hub/__init__.py +33 -45
  2. huggingface_hub/_commit_api.py +39 -43
  3. huggingface_hub/_commit_scheduler.py +11 -8
  4. huggingface_hub/_inference_endpoints.py +8 -8
  5. huggingface_hub/_jobs_api.py +20 -20
  6. huggingface_hub/_login.py +17 -43
  7. huggingface_hub/_oauth.py +8 -8
  8. huggingface_hub/_snapshot_download.py +135 -50
  9. huggingface_hub/_space_api.py +4 -4
  10. huggingface_hub/_tensorboard_logger.py +5 -5
  11. huggingface_hub/_upload_large_folder.py +18 -32
  12. huggingface_hub/_webhooks_payload.py +3 -3
  13. huggingface_hub/_webhooks_server.py +2 -2
  14. huggingface_hub/cli/__init__.py +0 -14
  15. huggingface_hub/cli/_cli_utils.py +143 -39
  16. huggingface_hub/cli/auth.py +105 -171
  17. huggingface_hub/cli/cache.py +594 -361
  18. huggingface_hub/cli/download.py +120 -112
  19. huggingface_hub/cli/hf.py +38 -41
  20. huggingface_hub/cli/jobs.py +689 -1017
  21. huggingface_hub/cli/lfs.py +120 -143
  22. huggingface_hub/cli/repo.py +282 -216
  23. huggingface_hub/cli/repo_files.py +50 -84
  24. huggingface_hub/cli/system.py +6 -25
  25. huggingface_hub/cli/upload.py +198 -220
  26. huggingface_hub/cli/upload_large_folder.py +91 -106
  27. huggingface_hub/community.py +5 -5
  28. huggingface_hub/constants.py +17 -52
  29. huggingface_hub/dataclasses.py +135 -21
  30. huggingface_hub/errors.py +47 -30
  31. huggingface_hub/fastai_utils.py +8 -9
  32. huggingface_hub/file_download.py +351 -303
  33. huggingface_hub/hf_api.py +398 -570
  34. huggingface_hub/hf_file_system.py +101 -66
  35. huggingface_hub/hub_mixin.py +32 -54
  36. huggingface_hub/inference/_client.py +177 -162
  37. huggingface_hub/inference/_common.py +38 -54
  38. huggingface_hub/inference/_generated/_async_client.py +218 -258
  39. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +3 -3
  40. huggingface_hub/inference/_generated/types/base.py +10 -7
  41. huggingface_hub/inference/_generated/types/chat_completion.py +16 -16
  42. huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
  43. huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
  44. huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
  45. huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
  46. huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
  47. huggingface_hub/inference/_generated/types/summarization.py +2 -2
  48. huggingface_hub/inference/_generated/types/table_question_answering.py +4 -4
  49. huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
  50. huggingface_hub/inference/_generated/types/text_generation.py +10 -10
  51. huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
  52. huggingface_hub/inference/_generated/types/token_classification.py +2 -2
  53. huggingface_hub/inference/_generated/types/translation.py +2 -2
  54. huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
  55. huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
  56. huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
  57. huggingface_hub/inference/_mcp/agent.py +3 -3
  58. huggingface_hub/inference/_mcp/constants.py +1 -2
  59. huggingface_hub/inference/_mcp/mcp_client.py +33 -22
  60. huggingface_hub/inference/_mcp/types.py +10 -10
  61. huggingface_hub/inference/_mcp/utils.py +4 -4
  62. huggingface_hub/inference/_providers/__init__.py +12 -4
  63. huggingface_hub/inference/_providers/_common.py +62 -24
  64. huggingface_hub/inference/_providers/black_forest_labs.py +6 -6
  65. huggingface_hub/inference/_providers/cohere.py +3 -3
  66. huggingface_hub/inference/_providers/fal_ai.py +25 -25
  67. huggingface_hub/inference/_providers/featherless_ai.py +4 -4
  68. huggingface_hub/inference/_providers/fireworks_ai.py +3 -3
  69. huggingface_hub/inference/_providers/hf_inference.py +13 -13
  70. huggingface_hub/inference/_providers/hyperbolic.py +4 -4
  71. huggingface_hub/inference/_providers/nebius.py +10 -10
  72. huggingface_hub/inference/_providers/novita.py +5 -5
  73. huggingface_hub/inference/_providers/nscale.py +4 -4
  74. huggingface_hub/inference/_providers/replicate.py +15 -15
  75. huggingface_hub/inference/_providers/sambanova.py +6 -6
  76. huggingface_hub/inference/_providers/together.py +7 -7
  77. huggingface_hub/lfs.py +21 -94
  78. huggingface_hub/repocard.py +15 -16
  79. huggingface_hub/repocard_data.py +57 -57
  80. huggingface_hub/serialization/__init__.py +0 -1
  81. huggingface_hub/serialization/_base.py +9 -9
  82. huggingface_hub/serialization/_dduf.py +7 -7
  83. huggingface_hub/serialization/_torch.py +28 -28
  84. huggingface_hub/utils/__init__.py +11 -6
  85. huggingface_hub/utils/_auth.py +5 -5
  86. huggingface_hub/utils/_cache_manager.py +49 -74
  87. huggingface_hub/utils/_deprecation.py +1 -1
  88. huggingface_hub/utils/_dotenv.py +3 -3
  89. huggingface_hub/utils/_fixes.py +0 -10
  90. huggingface_hub/utils/_git_credential.py +3 -3
  91. huggingface_hub/utils/_headers.py +7 -29
  92. huggingface_hub/utils/_http.py +371 -208
  93. huggingface_hub/utils/_pagination.py +4 -4
  94. huggingface_hub/utils/_parsing.py +98 -0
  95. huggingface_hub/utils/_paths.py +5 -5
  96. huggingface_hub/utils/_runtime.py +59 -23
  97. huggingface_hub/utils/_safetensors.py +21 -21
  98. huggingface_hub/utils/_subprocess.py +9 -9
  99. huggingface_hub/utils/_telemetry.py +3 -3
  100. huggingface_hub/{commands/_cli_utils.py → utils/_terminal.py} +4 -9
  101. huggingface_hub/utils/_typing.py +3 -3
  102. huggingface_hub/utils/_validators.py +53 -72
  103. huggingface_hub/utils/_xet.py +16 -16
  104. huggingface_hub/utils/_xet_progress_reporting.py +1 -1
  105. huggingface_hub/utils/insecure_hashlib.py +3 -9
  106. huggingface_hub/utils/tqdm.py +3 -3
  107. {huggingface_hub-0.36.0.dist-info → huggingface_hub-1.0.0.dist-info}/METADATA +16 -35
  108. huggingface_hub-1.0.0.dist-info/RECORD +152 -0
  109. {huggingface_hub-0.36.0.dist-info → huggingface_hub-1.0.0.dist-info}/entry_points.txt +0 -1
  110. huggingface_hub/commands/__init__.py +0 -27
  111. huggingface_hub/commands/delete_cache.py +0 -476
  112. huggingface_hub/commands/download.py +0 -204
  113. huggingface_hub/commands/env.py +0 -39
  114. huggingface_hub/commands/huggingface_cli.py +0 -65
  115. huggingface_hub/commands/lfs.py +0 -200
  116. huggingface_hub/commands/repo.py +0 -151
  117. huggingface_hub/commands/repo_files.py +0 -132
  118. huggingface_hub/commands/scan_cache.py +0 -183
  119. huggingface_hub/commands/tag.py +0 -161
  120. huggingface_hub/commands/upload.py +0 -318
  121. huggingface_hub/commands/upload_large_folder.py +0 -131
  122. huggingface_hub/commands/user.py +0 -208
  123. huggingface_hub/commands/version.py +0 -40
  124. huggingface_hub/inference_api.py +0 -217
  125. huggingface_hub/keras_mixin.py +0 -497
  126. huggingface_hub/repository.py +0 -1471
  127. huggingface_hub/serialization/_tensorflow.py +0 -92
  128. huggingface_hub/utils/_hf_folder.py +0 -68
  129. huggingface_hub-0.36.0.dist-info/RECORD +0 -170
  130. {huggingface_hub-0.36.0.dist-info → huggingface_hub-1.0.0.dist-info}/LICENSE +0 -0
  131. {huggingface_hub-0.36.0.dist-info → huggingface_hub-1.0.0.dist-info}/WHEEL +0 -0
  132. {huggingface_hub-0.36.0.dist-info → huggingface_hub-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,152 @@
1
+ huggingface_hub/__init__.py,sha256=D3F3oo_ENTnnxwqvHdXdE8qoxL3G7M5IPuhXHMLEw9s,52363
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=cGiZg244nIOi2OLTqm4V8-ZUY3O0Rr7NlOmoLeHUIbY,17592
5
+ huggingface_hub/_jobs_api.py,sha256=BelnQPFWSH80-SJm8OGrZy8s1mwm8PmCGbV82sZ11xs,10871
6
+ huggingface_hub/_local_folder.py,sha256=2iHXNgIT3UdSt2PvCovd0NzgVxTRypKb-rvAFLK-gZU,17305
7
+ huggingface_hub/_login.py,sha256=X2fRO3QbZmrgmTuFZHJ58m5CDTx81rx7YEcfPoPs62I,18970
8
+ huggingface_hub/_oauth.py,sha256=91zR_H235vxi-fg2YXzDgmA09j4BR3dim9VVzf6srps,18695
9
+ huggingface_hub/_snapshot_download.py,sha256=9UKPYATR1Nml6nsWEOj7porYa0MBsaCTttoGh4Tx8DY,19441
10
+ huggingface_hub/_space_api.py,sha256=aOowzC3LUytfgFrZprn9vKTQHXLpDWJKjl9X4qq_ZxQ,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=tCH5D0f-X9m1nM0eed9iW_qWbBRULFlF67QZJSyiHX8,15666
15
+ huggingface_hub/community.py,sha256=FACeqlP7OgR2vLLJ0IN4cfglBiEGbyTafJ0cXfsjgnQ,12359
16
+ huggingface_hub/constants.py,sha256=sxGBFkQ8K8gRqDlLStfWDrRUPpb0CkxKZhL9mYJuyyg,9710
17
+ huggingface_hub/dataclasses.py,sha256=b1lo5BI881Drd7UM_pUrK8zdJdhXOGj4-pHxFS_P4M4,21962
18
+ huggingface_hub/errors.py,sha256=lnXNYKsoJwm_G3377u7aDJGnGwKqCyaiZ1DfjtlzMR8,11411
19
+ huggingface_hub/fastai_utils.py,sha256=0joRPBUccjFALLCfhQLyD_K8qxGvQiLThKJClwej_JQ,16657
20
+ huggingface_hub/file_download.py,sha256=NUQ9jQjmp7DWlA6jwvTJ4y1mV4wH0XN4JysWgcCTAnc,78472
21
+ huggingface_hub/hf_api.py,sha256=75iTEnMty3NJMf8FrzSZL6dO5DPnCMz3VFvM672bWP8,476100
22
+ huggingface_hub/hf_file_system.py,sha256=BzmmHqb5_y91-pOqKKMAzOvGmt8nKqp64zFtZPmOcPY,49312
23
+ huggingface_hub/hub_mixin.py,sha256=xQDBbxjEHVMdb333hCmjsjYsaxU7IICdgZFf8tq0toU,37063
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=-wss1XDYjr88OjwK4Gzi8c-gQwPIHM8qRgxXYgeilUM,34978
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=e9z0qMXpRfrzERi220QTzwkq9jOldVGUVtmoDV-sgYs,5402
30
+ huggingface_hub/cli/auth.py,sha256=tJcKzQz8_pl0FFl8a-tNjxpK4AFfA38L4oztcXVdcSY,4515
31
+ huggingface_hub/cli/cache.py,sha256=oMsHmkmZmgSKBpF0xdIpyGsnZNTlth9YJoVw8pk1IX8,21446
32
+ huggingface_hub/cli/download.py,sha256=h9dUa91e1nOTmIcgtxyNE0ZGz6ZSrKu4nnlJsYp2HWg,6532
33
+ huggingface_hub/cli/hf.py,sha256=q8J-SPVe56Qse1b2WT_vKxB4quKpTE_4HSywNA-7ns0,2356
34
+ huggingface_hub/cli/jobs.py,sha256=HgxxxDRaCHH62eBpihzf1SakevM3OWewPiIzWjFkYLw,23871
35
+ huggingface_hub/cli/lfs.py,sha256=UJI5nBbrt_a-lm5uU88gxD6hVu8xyQav-zBxLTv3Wzo,5895
36
+ huggingface_hub/cli/repo.py,sha256=kAHyiYQap5gVNY8kPmub4s7X9mGsn8vFJNIIzSeIOD4,9709
37
+ huggingface_hub/cli/repo_files.py,sha256=6d5GsLsCjqSKTSbJqCHnrRxB9kXj-yLRAtcVbQkQNMo,2799
38
+ huggingface_hub/cli/system.py,sha256=bEIXmK3qz4qIej1lv1LMCxnXEN9zZnwdl42g4mV_1nQ,982
39
+ huggingface_hub/cli/upload.py,sha256=Dpu-syLR6J52U2HM8bJbjAk5PNA2gxAYagjKoRTNSZs,11383
40
+ huggingface_hub/cli/upload_large_folder.py,sha256=xQuloimQT0PQH6r5urRpLv8M9I99yAWSGM-sbkG2pu8,4470
41
+ huggingface_hub/inference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ huggingface_hub/inference/_client.py,sha256=KIRstAwRk6RyVe2bk7XsiGV_ZdwegjyU_KIDVzQbmII,157960
43
+ huggingface_hub/inference/_common.py,sha256=qS3i2R8Dz_VCb6sWt1ZqnmOt8jxPU6uSxlyq-0_9ytg,15350
44
+ huggingface_hub/inference/_generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ huggingface_hub/inference/_generated/_async_client.py,sha256=0xu4TCjav_qXbFNhv6-uBMo26UgH-z34jAJGfUj7obE,161170
46
+ huggingface_hub/inference/_generated/types/__init__.py,sha256=9WvrGQ8aThtKSNzZF06j-CIE2ZuItne8FFnea1p1u38,6557
47
+ huggingface_hub/inference/_generated/types/audio_classification.py,sha256=Jg3mzfGhCSH6CfvVvgJSiFpkz6v4nNA0G4LJXacEgNc,1573
48
+ huggingface_hub/inference/_generated/types/audio_to_audio.py,sha256=2Ep4WkePL7oJwcp5nRJqApwviumGHbft9HhXE9XLHj4,891
49
+ huggingface_hub/inference/_generated/types/automatic_speech_recognition.py,sha256=FyViZkZqd0oo7Raqo48HESMAXHSnJap9HRWsKCi8Xz4,5509
50
+ huggingface_hub/inference/_generated/types/base.py,sha256=9sGEyvytJureiYimTb-pFIxG7jLe6okKzPamZuSiZyc,6896
51
+ huggingface_hub/inference/_generated/types/chat_completion.py,sha256=3-pAyko3ozXSsvE_nFl4wtALf3z5DVQSLjtAD-2tUe4,11242
52
+ huggingface_hub/inference/_generated/types/depth_estimation.py,sha256=c7IA81gZp5xIHol-7wlvy8V8UE--O1XF9rahauLVuoY,923
53
+ huggingface_hub/inference/_generated/types/document_question_answering.py,sha256=aJ_dC3pVLTHombqX3UwIFhKN_mFzpw4m89sfB2J488E,3196
54
+ huggingface_hub/inference/_generated/types/feature_extraction.py,sha256=A8nj27aQWF6XKQxNl0GsOnsNY--nN8Rnlh3nRXrThkU,1531
55
+ huggingface_hub/inference/_generated/types/fill_mask.py,sha256=E-dU2bmHlso1cei_ju_LQtYVvDZEqAM1-walZkMPa74,1702
56
+ huggingface_hub/inference/_generated/types/image_classification.py,sha256=A-Y024o8723_n8mGVos4TwdAkVL62McGeL1iIo4VzNs,1585
57
+ huggingface_hub/inference/_generated/types/image_segmentation.py,sha256=vrkI4SuP1Iq_iLXc-2pQhYY3SHN4gzvFBoZqbUHxU7o,1950
58
+ huggingface_hub/inference/_generated/types/image_to_image.py,sha256=snvGbmCdqchxGef25MceD7LSKAmVkIgnoX5t71rdlAQ,2290
59
+ huggingface_hub/inference/_generated/types/image_to_text.py,sha256=OaFEBAfgT-fOVzJ7xVermGf7VODhrc9-Jg38WrM7-2o,4810
60
+ huggingface_hub/inference/_generated/types/image_to_video.py,sha256=bC-L_cNsDhk4s_IdSiprJ9d1NeMGePLcUp7UPpco21w,2240
61
+ huggingface_hub/inference/_generated/types/object_detection.py,sha256=VuFlb1281qTXoSgJDmquGz-VNfEZLo2H0Rh_F6MF6ts,2000
62
+ huggingface_hub/inference/_generated/types/question_answering.py,sha256=zw38a9_9l2k1ifYZefjkioqZ4asfSRM9M4nU3gSCmAQ,2898
63
+ huggingface_hub/inference/_generated/types/sentence_similarity.py,sha256=5mDdTop4w6CpS-SulA03UVq5lBbzHuNMe8IQsTmAUPQ,1040
64
+ huggingface_hub/inference/_generated/types/summarization.py,sha256=eMJvNJmxdImVXLLMADmyDeB1YhJbN3Qd_fC6lPB7mTM,1481
65
+ huggingface_hub/inference/_generated/types/table_question_answering.py,sha256=kzT-BRnX6AwrkMqcofUZHLccxQPteg5wsJjfd9z5PjI,2281
66
+ huggingface_hub/inference/_generated/types/text2text_generation.py,sha256=S9as2uJKqCmRht_dFGws-KwQwEq1hD6w3gSLiGTMERI,1603
67
+ huggingface_hub/inference/_generated/types/text_classification.py,sha256=FarAjygLEfPofLfKeabzJ7PKEBItlHGoUNUOzyLRpL4,1445
68
+ huggingface_hub/inference/_generated/types/text_generation.py,sha256=g9pLc5XrWc1Ir0nmQ4xTa4ZauKHIJ9Pr7yM1FmZkX0Y,5916
69
+ huggingface_hub/inference/_generated/types/text_to_audio.py,sha256=1HR9Q6s9MXqtKGTvHPLGVMum5-eg7O-Pgv6Nd0v8_HU,4741
70
+ huggingface_hub/inference/_generated/types/text_to_image.py,sha256=sGGi1Fa0n5Pmd6G3I-F2SBJcJ1M7Gmqnng6sfi0AVzs,1903
71
+ huggingface_hub/inference/_generated/types/text_to_speech.py,sha256=ROFuR32ijROCeqbv81Jos0lmaA8SRWyIUsWrdD4yWow,4760
72
+ huggingface_hub/inference/_generated/types/text_to_video.py,sha256=xjC9Vp3eovuKEk7qhIeeC8VNJG8W0Kr8PEnOwOC1Ga4,1784
73
+ huggingface_hub/inference/_generated/types/token_classification.py,sha256=bpRwy_1knC11auZaeoVrCyYWBwyJLLKeiS-ypNkDTT8,1909
74
+ huggingface_hub/inference/_generated/types/translation.py,sha256=jfeWNGkZInGTOWP-Tq2dl1rGa8xuUQvZ40PxuOrsBpE,1757
75
+ huggingface_hub/inference/_generated/types/video_classification.py,sha256=TyydjQw2NRLK9sDGzJUVnkDeo848ebmCx588Ur8I9q0,1680
76
+ huggingface_hub/inference/_generated/types/visual_question_answering.py,sha256=AWrQ6qo4gZa3PGedaNpzDFqx5yOYyjhnUB6iuZEj_uo,1673
77
+ huggingface_hub/inference/_generated/types/zero_shot_classification.py,sha256=-PRiAdpXN0wxRrSVe3z8byEvuxcNby89mASU9CbfVzU,1732
78
+ huggingface_hub/inference/_generated/types/zero_shot_image_classification.py,sha256=1alzatw0RA88YUuHfrhRWQ5-Fix-iO3KcxfJV3WQB50,1481
79
+ huggingface_hub/inference/_generated/types/zero_shot_object_detection.py,sha256=sjdpVUN5zW9aYBymLVUs6i5HVk2qkUBO9ysEjHmsXVM,1605
80
+ huggingface_hub/inference/_mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
+ huggingface_hub/inference/_mcp/_cli_hacks.py,sha256=KX9HZJPa1p8ngY3mtYGGlVUXfg4vYbbBRs-8HLToP04,3284
82
+ huggingface_hub/inference/_mcp/agent.py,sha256=ufIzMGHore5n252hV5GZPM0ouDXIl6tv5Jl_5gHXnbg,4250
83
+ huggingface_hub/inference/_mcp/cli.py,sha256=AmSUT6wXlE6EWmI0SfQgTWYnL07322zGwwk2yMZZlBc,9640
84
+ huggingface_hub/inference/_mcp/constants.py,sha256=Ws8BujjgZWb5kPAVm4GLE_Rqse63MszHp863EWwoPCI,2487
85
+ huggingface_hub/inference/_mcp/mcp_client.py,sha256=dGp8PhN6aVw4bDnuSySFSiguHUiz-nzhgv89CVdO7pI,17243
86
+ huggingface_hub/inference/_mcp/types.py,sha256=yHNfPsM9MhD06oeKdkbmrBsW-3WhUeqA26fyfRfx_bk,929
87
+ huggingface_hub/inference/_mcp/utils.py,sha256=6XBYLikJ8lknx-k1QaG_uVoVYZ0yMzyo6WgtGp7Zdds,4175
88
+ huggingface_hub/inference/_providers/__init__.py,sha256=l1a-sf6OHOtAIlqLDqySWZV6iw9g-FErC6-R0VkdCHk,9458
89
+ huggingface_hub/inference/_providers/_common.py,sha256=bul88ILjJit7BG5L5PFXyS6HQF4-istiYylC9WBHZz0,13818
90
+ huggingface_hub/inference/_providers/black_forest_labs.py,sha256=vkjK_-4epSJa2-fLnbcXFzPAgQsGKhykKwd9Np-V2iw,2846
91
+ huggingface_hub/inference/_providers/cerebras.py,sha256=QOJ-1U-os7uE7p6eUnn_P_APq-yQhx28be7c3Tq2EuA,210
92
+ huggingface_hub/inference/_providers/clarifai.py,sha256=1cEXQwhGk4DRKiPCQUa5y-L6okTo4781EImQC8yJVOw,380
93
+ huggingface_hub/inference/_providers/cohere.py,sha256=GqUyCR4j6Re-_27ItwQF2p89Yya4e__EWDP9hTSs9w0,1247
94
+ huggingface_hub/inference/_providers/fal_ai.py,sha256=F8mWK9BhVvDzp3LNjhuIWF0xLR-Y5gdHpUPUqlPBi-U,9983
95
+ huggingface_hub/inference/_providers/featherless_ai.py,sha256=SceM3VsgzDSaCnzVxTFK6JepHaGStptdLlwrX-zsM2g,1376
96
+ huggingface_hub/inference/_providers/fireworks_ai.py,sha256=YfxC8wMU38qpv6xFc5HnHf6qK4x64nt-iwEDTip4C_U,1209
97
+ huggingface_hub/inference/_providers/groq.py,sha256=JTk2JV4ZOlaohho7zLAFQtk92kGVsPmLJ1hmzcwsqvQ,315
98
+ huggingface_hub/inference/_providers/hf_inference.py,sha256=dp15WQQNdbIJhLiRvH3PA651xdf7OjMx3R_1bjKqLxw,9534
99
+ huggingface_hub/inference/_providers/hyperbolic.py,sha256=LiAAiW7diy-ctrDKNYO_2N4Ght9wnvvD7hMo2NYbsNg,1979
100
+ huggingface_hub/inference/_providers/nebius.py,sha256=NQDJoNbFd9FPBA5yWTb_C42NoMeV8edpZCTRoXqtDOM,3574
101
+ huggingface_hub/inference/_providers/novita.py,sha256=AN4csxwKbRvNiaK87o9xVp9krL6mHPk6iv5iat87skA,2508
102
+ huggingface_hub/inference/_providers/nscale.py,sha256=RkyvmYtQbs2RPenF_pxDPMUMZM_botT21zqfVe2hT5Y,1796
103
+ huggingface_hub/inference/_providers/openai.py,sha256=GCVYeNdjWIgpQQ7E_Xv8IebmdhTi0S6WfFosz3nLtps,1089
104
+ huggingface_hub/inference/_providers/publicai.py,sha256=1I2W6rORloB5QHSvky4njZO2XKLTwA-kPdNoauoT5rg,210
105
+ huggingface_hub/inference/_providers/replicate.py,sha256=MBvjI-4IH8Antqr_8c3MRrBjAzElA3sAmEzeRVpIsPI,3814
106
+ huggingface_hub/inference/_providers/sambanova.py,sha256=t-J89tab8wut62jXSXl7pAK5mCrovwdgtvbDYK1DHis,2031
107
+ huggingface_hub/inference/_providers/scaleway.py,sha256=Jy81kXWbXCHBpx6xmyzdEfXGSyhUfjKOLHuDSvhHWGo,1209
108
+ huggingface_hub/inference/_providers/together.py,sha256=q32zFvXhmRogWXMSaEFVYS8m9blXI_oy7KPdeal7Wwg,3433
109
+ huggingface_hub/inference/_providers/zai_org.py,sha256=plGzMZuLrChZvgpS3CCPqI6ImotZZxNLgfxnR7v6tw8,646
110
+ huggingface_hub/serialization/__init__.py,sha256=jCiw_vVQYW52gwVfWiqgocf2Q19kGTQlRGVpf-4SLP8,963
111
+ huggingface_hub/serialization/_base.py,sha256=af1QBU_A3EKgAXvYCkENPyamL5Z7V5LxlIUoCxMsEYM,8097
112
+ huggingface_hub/serialization/_dduf.py,sha256=eyUREtvL7od9SSYKrGcCayF29w3xcP1qXTx7RntWp9k,15411
113
+ huggingface_hub/serialization/_torch.py,sha256=MHQEyqSlCjmAyUMoefi-E8ljxbIsp14DQd8DfjlcH74,45119
114
+ huggingface_hub/templates/datasetcard_template.md,sha256=W-EMqR6wndbrnZorkVv56URWPG49l7MATGeI015kTvs,5503
115
+ huggingface_hub/templates/modelcard_template.md,sha256=4AqArS3cqdtbit5Bo-DhjcnDFR-pza5hErLLTPM4Yuc,6870
116
+ huggingface_hub/utils/__init__.py,sha256=DfhKYcd-7sc6lN1JpBT_PUOhxK8RvW1YfYDaPLYeLrc,3799
117
+ huggingface_hub/utils/_auth.py,sha256=TAz8pjk1lP7gseit8Trl2LygKun9unMEBWg_36EeDkA,8280
118
+ huggingface_hub/utils/_cache_assets.py,sha256=kai77HPQMfYpROouMBQCr_gdBCaeTm996Sqj0dExbNg,5728
119
+ huggingface_hub/utils/_cache_manager.py,sha256=TYJcC0cibN-MztTQrqzyDPB6HI3m_rGvAuYn2ybB1K8,32992
120
+ huggingface_hub/utils/_chunk_utils.py,sha256=MH7-6FwCDZ8noV6dGRytCOJGSfcZmDBvsvVotdI8TvQ,2109
121
+ huggingface_hub/utils/_datetime.py,sha256=kCS5jaKV25kOncX1xujbXsz5iDLcjLcLw85semGNzxQ,2770
122
+ huggingface_hub/utils/_deprecation.py,sha256=4tWi3vBSdvnhA0z_Op-tkAQ0xrJ4TUb0HbPhMiXUnOs,4872
123
+ huggingface_hub/utils/_dotenv.py,sha256=2LLdzpA-LzLxO15GLb9WKT5IGrTurIRmFPrMX1yDzsU,2011
124
+ huggingface_hub/utils/_experimental.py,sha256=3-c8irbn9sJr2CwWbzhGkIrdXKg8_x7BifhHFy32ei8,2470
125
+ huggingface_hub/utils/_fixes.py,sha256=xQZzfwLqZV8-gNcw9mrZ-M1acA6NZHszI_-cSZIWN-U,3978
126
+ huggingface_hub/utils/_git_credential.py,sha256=4B77QzeiPxCwK6BWZgUc1avzRKpna3wYlhVg7AuSCzA,4613
127
+ huggingface_hub/utils/_headers.py,sha256=k_ApvA8fJGHc0yNp2IFY8wySM9MQ5UZEpjr1g-fpRJ4,8060
128
+ huggingface_hub/utils/_http.py,sha256=ZcajY2zWUEfoumyhShqV3fKUP5pnAra305A0s4LT4pE,31423
129
+ huggingface_hub/utils/_lfs.py,sha256=EC0Oz6Wiwl8foRNkUOzrETXzAWlbgpnpxo5a410ovFY,3957
130
+ huggingface_hub/utils/_pagination.py,sha256=wEHEWhCu9vN5pv51t7ixSGe13g63kS6AJM4P53eY9M4,1894
131
+ huggingface_hub/utils/_parsing.py,sha256=T6UCjUh0h731A0Jh-eH5RWcqVQ5m0IyMcXHl5G2YNUs,3021
132
+ huggingface_hub/utils/_paths.py,sha256=WCR2WbqDJLdNlU4XZNXXNmGct3OiDwPesGYrq41T2wE,5036
133
+ huggingface_hub/utils/_runtime.py,sha256=OnosxuCoOD1LOFodUb7HB3WAF8Q3udvjjXm-b-JXUuc,12593
134
+ huggingface_hub/utils/_safetensors.py,sha256=2_xbCsDPsCwR1tyBjJ5MoOHsX4ksocjzc4jS7oGe7_s,4439
135
+ huggingface_hub/utils/_subprocess.py,sha256=9qDWT1a2QF2TmXOQJDlPK6LwzYl9XjXeRadQPn15U14,4612
136
+ huggingface_hub/utils/_telemetry.py,sha256=a7t0jaOUPVNxbDWi4KQgVf8vSpZv0I-tK2HwlAowvEE,4884
137
+ huggingface_hub/utils/_terminal.py,sha256=ai6nDaW8wqVMxf4gDy6wN9fyszYzKiCUrYu6lzWdR9M,2115
138
+ huggingface_hub/utils/_typing.py,sha256=cC9p6E8hG2LId8sFWJ9H-cpQozv3asuoww_XiA1-XWI,3617
139
+ huggingface_hub/utils/_validators.py,sha256=p9ScwDqjTfrEQx5dmJJKCovExTUqwGA7TNIx511jBxE,8347
140
+ huggingface_hub/utils/_xet.py,sha256=P9b4lc4bJfOSZ7OVO-fg26_ayN0ESb_f1nQ7Bx9ZLfg,7297
141
+ huggingface_hub/utils/_xet_progress_reporting.py,sha256=bxwanhLxigDASflFZVt7S8eENIviguyVg1Q9vFtmDf8,6169
142
+ huggingface_hub/utils/endpoint_helpers.py,sha256=9VtIAlxQ5H_4y30sjCAgbu7XCqAtNLC7aRYxaNn0hLI,2366
143
+ huggingface_hub/utils/insecure_hashlib.py,sha256=z3dVUFvdBZ8kQI_8Vzvvlr3ims-EBiY-SYPdnzIKOkw,1008
144
+ huggingface_hub/utils/logging.py,sha256=N6NXaCcbPbZSF-Oe-TY3ZnmkpmdFVyTOV8ASo-yVXLE,4916
145
+ huggingface_hub/utils/sha.py,sha256=OFnNGCba0sNcT2gUwaVCJnldxlltrHHe0DS_PCpV3C4,2134
146
+ huggingface_hub/utils/tqdm.py,sha256=-9gfgNA8bg5v5YBToSuB6noClI3a6YaGeFZP61IWmeY,10662
147
+ huggingface_hub-1.0.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
148
+ huggingface_hub-1.0.0.dist-info/METADATA,sha256=_LVuRhSRrSorPU_WNlzmRJJ-TH66g54Vau6B0PpMEko,13737
149
+ huggingface_hub-1.0.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
150
+ huggingface_hub-1.0.0.dist-info/entry_points.txt,sha256=8Dw-X6nV_toOLZqujrhQMj2uTLs4wzV8EIF1y3FlzVs,153
151
+ huggingface_hub-1.0.0.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
152
+ huggingface_hub-1.0.0.dist-info/RECORD,,
@@ -1,6 +1,5 @@
1
1
  [console_scripts]
2
2
  hf = huggingface_hub.cli.hf:main
3
- huggingface-cli = huggingface_hub.commands.huggingface_cli:main
4
3
  tiny-agents = huggingface_hub.inference._mcp.cli:app
5
4
 
6
5
  [fsspec.specs]
@@ -1,27 +0,0 @@
1
- # Copyright 2020 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
-
15
- from abc import ABC, abstractmethod
16
- from argparse import _SubParsersAction
17
-
18
-
19
- class BaseHuggingfaceCLICommand(ABC):
20
- @staticmethod
21
- @abstractmethod
22
- def register_subcommand(parser: _SubParsersAction):
23
- raise NotImplementedError()
24
-
25
- @abstractmethod
26
- def run(self):
27
- raise NotImplementedError()
@@ -1,476 +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, show_deprecation_warning
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
- show_deprecation_warning("huggingface-cli delete-cache", "hf cache delete")
148
-
149
- # Scan cache directory
150
- hf_cache_info = scan_cache_dir(self.cache_dir)
151
-
152
- # Manual review from the user
153
- if self.disable_tui:
154
- selected_hashes = _manual_review_no_tui(hf_cache_info, preselected=[], sort_by=self.sort_by)
155
- else:
156
- selected_hashes = _manual_review_tui(hf_cache_info, preselected=[], sort_by=self.sort_by)
157
-
158
- # If deletion is not cancelled
159
- if len(selected_hashes) > 0 and _CANCEL_DELETION_STR not in selected_hashes:
160
- confirm_message = _get_expectations_str(hf_cache_info, selected_hashes) + " Confirm deletion ?"
161
-
162
- # Confirm deletion
163
- if self.disable_tui:
164
- confirmed = _ask_for_confirmation_no_tui(confirm_message)
165
- else:
166
- confirmed = _ask_for_confirmation_tui(confirm_message)
167
-
168
- # Deletion is confirmed
169
- if confirmed:
170
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
171
- print("Start deletion.")
172
- strategy.execute()
173
- print(
174
- f"Done. Deleted {len(strategy.repos)} repo(s) and"
175
- f" {len(strategy.snapshots)} revision(s) for a total of"
176
- f" {strategy.expected_freed_size_str}."
177
- )
178
- return
179
-
180
- # Deletion is cancelled
181
- print("Deletion is cancelled. Do nothing.")
182
-
183
-
184
- def _get_repo_sorting_key(repo: CachedRepoInfo, sort_by: Optional[SortingOption_T] = None):
185
- if sort_by == "alphabetical":
186
- return (repo.repo_type, repo.repo_id.lower()) # by type then name
187
- elif sort_by == "lastUpdated":
188
- return -max(rev.last_modified for rev in repo.revisions) # newest first
189
- elif sort_by == "lastUsed":
190
- return -repo.last_accessed # most recently used first
191
- elif sort_by == "size":
192
- return -repo.size_on_disk # largest first
193
- else:
194
- return (repo.repo_type, repo.repo_id) # default stable order
195
-
196
-
197
- @require_inquirer_py
198
- def _manual_review_tui(
199
- hf_cache_info: HFCacheInfo,
200
- preselected: List[str],
201
- sort_by: Optional[SortingOption_T] = None,
202
- ) -> List[str]:
203
- """Ask the user for a manual review of the revisions to delete.
204
-
205
- Displays a multi-select menu in the terminal (TUI).
206
- """
207
- # Define multiselect list
208
- choices = _get_tui_choices_from_scan(
209
- repos=hf_cache_info.repos,
210
- preselected=preselected,
211
- sort_by=sort_by,
212
- )
213
- checkbox = inquirer.checkbox(
214
- message="Select revisions to delete:",
215
- choices=choices, # List of revisions with some pre-selection
216
- cycle=False, # No loop between top and bottom
217
- height=100, # Large list if possible
218
- # We use the instruction to display to the user the expected effect of the
219
- # deletion.
220
- instruction=_get_expectations_str(
221
- hf_cache_info,
222
- selected_hashes=[c.value for c in choices if isinstance(c, Choice) and c.enabled],
223
- ),
224
- # We use the long instruction to should keybindings instructions to the user
225
- long_instruction="Press <space> to select, <enter> to validate and <ctrl+c> to quit without modification.",
226
- # Message that is displayed once the user validates its selection.
227
- transformer=lambda result: f"{len(result)} revision(s) selected.",
228
- )
229
-
230
- # Add a callback to update the information line when a revision is
231
- # selected/unselected
232
- def _update_expectations(_) -> None:
233
- # Hacky way to dynamically set an instruction message to the checkbox when
234
- # a revision hash is selected/unselected.
235
- checkbox._instruction = _get_expectations_str(
236
- hf_cache_info,
237
- selected_hashes=[choice["value"] for choice in checkbox.content_control.choices if choice["enabled"]],
238
- )
239
-
240
- checkbox.kb_func_lookup["toggle"].append({"func": _update_expectations})
241
-
242
- # Finally display the form to the user.
243
- try:
244
- return checkbox.execute()
245
- except KeyboardInterrupt:
246
- return [] # Quit without deletion
247
-
248
-
249
- @require_inquirer_py
250
- def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
251
- """Ask for confirmation using Inquirer."""
252
- return inquirer.confirm(message, default=default).execute()
253
-
254
-
255
- def _get_tui_choices_from_scan(
256
- repos: Iterable[CachedRepoInfo],
257
- preselected: List[str],
258
- sort_by: Optional[SortingOption_T] = None,
259
- ) -> List:
260
- """Build a list of choices from the scanned repos.
261
-
262
- Args:
263
- repos (*Iterable[`CachedRepoInfo`]*):
264
- List of scanned repos on which we want to delete revisions.
265
- preselected (*List[`str`]*):
266
- List of revision hashes that will be preselected.
267
- sort_by (*Optional[SortingOption_T]*):
268
- Sorting direction. Choices: "alphabetical", "lastUpdated", "lastUsed", "size".
269
-
270
- Return:
271
- The list of choices to pass to `inquirer.checkbox`.
272
- """
273
- choices: List[Union[Choice, Separator]] = []
274
-
275
- # First choice is to cancel the deletion
276
- choices.append(
277
- Choice(
278
- _CANCEL_DELETION_STR,
279
- name="None of the following (if selected, nothing will be deleted).",
280
- enabled=False,
281
- )
282
- )
283
-
284
- # Sort repos based on specified criteria
285
- sorted_repos = sorted(repos, key=lambda repo: _get_repo_sorting_key(repo, sort_by))
286
-
287
- for repo in sorted_repos:
288
- # Repo as separator
289
- choices.append(
290
- Separator(
291
- f"\n{repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
292
- f" used {repo.last_accessed_str})"
293
- )
294
- )
295
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
296
- # Revision as choice
297
- choices.append(
298
- Choice(
299
- revision.commit_hash,
300
- name=(
301
- f"{revision.commit_hash[:8]}:"
302
- f" {', '.join(sorted(revision.refs)) or '(detached)'} #"
303
- f" modified {revision.last_modified_str}"
304
- ),
305
- enabled=revision.commit_hash in preselected,
306
- )
307
- )
308
-
309
- # Return choices
310
- return choices
311
-
312
-
313
- def _manual_review_no_tui(
314
- hf_cache_info: HFCacheInfo,
315
- preselected: List[str],
316
- sort_by: Optional[SortingOption_T] = None,
317
- ) -> List[str]:
318
- """Ask the user for a manual review of the revisions to delete.
319
-
320
- Used when TUI is disabled. Manual review happens in a separate tmp file that the
321
- user can manually edit.
322
- """
323
- # 1. Generate temporary file with delete commands.
324
- fd, tmp_path = mkstemp(suffix=".txt") # suffix to make it easier to find by editors
325
- os.close(fd)
326
-
327
- lines = []
328
-
329
- sorted_repos = sorted(hf_cache_info.repos, key=lambda repo: _get_repo_sorting_key(repo, sort_by))
330
-
331
- for repo in sorted_repos:
332
- lines.append(
333
- f"\n# {repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
334
- f" used {repo.last_accessed_str})"
335
- )
336
- for revision in sorted(repo.revisions, key=_revision_sorting_order):
337
- lines.append(
338
- # Deselect by prepending a '#'
339
- f"{'' if revision.commit_hash in preselected else '#'} "
340
- f" {revision.commit_hash} # Refs:"
341
- # Print `refs` as comment on same line
342
- f" {', '.join(sorted(revision.refs)) or '(detached)'} # modified"
343
- # Print `last_modified` as comment on same line
344
- f" {revision.last_modified_str}"
345
- )
346
-
347
- with open(tmp_path, "w") as f:
348
- f.write(_MANUAL_REVIEW_NO_TUI_INSTRUCTIONS)
349
- f.write("\n".join(lines))
350
-
351
- # 2. Prompt instructions to user.
352
- instructions = f"""
353
- TUI is disabled. In order to select which revisions you want to delete, please edit
354
- the following file using the text editor of your choice. Instructions for manual
355
- editing are located at the beginning of the file. Edit the file, save it and confirm
356
- to continue.
357
- File to edit: {ANSI.bold(tmp_path)}
358
- """
359
- print("\n".join(line.strip() for line in instructions.strip().split("\n")))
360
-
361
- # 3. Wait for user confirmation.
362
- while True:
363
- selected_hashes = _read_manual_review_tmp_file(tmp_path)
364
- if _ask_for_confirmation_no_tui(
365
- _get_expectations_str(hf_cache_info, selected_hashes) + " Continue ?",
366
- default=False,
367
- ):
368
- break
369
-
370
- # 4. Return selected_hashes sorted to maintain stable order
371
- os.remove(tmp_path)
372
- return sorted(selected_hashes) # Sort to maintain stable order
373
-
374
-
375
- def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
376
- """Ask for confirmation using pure-python."""
377
- YES = ("y", "yes", "1")
378
- NO = ("n", "no", "0")
379
- DEFAULT = ""
380
- ALL = YES + NO + (DEFAULT,)
381
- full_message = message + (" (Y/n) " if default else " (y/N) ")
382
- while True:
383
- answer = input(full_message).lower()
384
- if answer == DEFAULT:
385
- return default
386
- if answer in YES:
387
- return True
388
- if answer in NO:
389
- return False
390
- print(f"Invalid input. Must be one of {ALL}")
391
-
392
-
393
- def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]) -> str:
394
- """Format a string to display to the user how much space would be saved.
395
-
396
- Example:
397
- ```
398
- >>> _get_expectations_str(hf_cache_info, selected_hashes)
399
- '7 revisions selected counting for 4.3G.'
400
- ```
401
- """
402
- if _CANCEL_DELETION_STR in selected_hashes:
403
- return "Nothing will be deleted."
404
- strategy = hf_cache_info.delete_revisions(*selected_hashes)
405
- return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
406
-
407
-
408
- def _read_manual_review_tmp_file(tmp_path: str) -> List[str]:
409
- """Read the manually reviewed instruction file and return a list of revision hash.
410
-
411
- Example:
412
- ```txt
413
- # This is the tmp file content
414
- ###
415
-
416
- # Commented out line
417
- 123456789 # revision hash
418
-
419
- # Something else
420
- # a_newer_hash # 2 days ago
421
- an_older_hash # 3 days ago
422
- ```
423
-
424
- ```py
425
- >>> _read_manual_review_tmp_file(tmp_path)
426
- ['123456789', 'an_older_hash']
427
- ```
428
- """
429
- with open(tmp_path) as f:
430
- content = f.read()
431
-
432
- # Split lines
433
- lines = [line.strip() for line in content.split("\n")]
434
-
435
- # Filter commented lines
436
- selected_lines = [line for line in lines if not line.startswith("#")]
437
-
438
- # Select only before comment
439
- selected_hashes = [line.split("#")[0].strip() for line in selected_lines]
440
-
441
- # Return revision hashes
442
- return [hash for hash in selected_hashes if len(hash) > 0]
443
-
444
-
445
- _MANUAL_REVIEW_NO_TUI_INSTRUCTIONS = f"""
446
- # INSTRUCTIONS
447
- # ------------
448
- # This is a temporary file created by running `huggingface-cli delete-cache` with the
449
- # `--disable-tui` option. It contains a set of revisions that can be deleted from your
450
- # local cache directory.
451
- #
452
- # Please manually review the revisions you want to delete:
453
- # - Revision hashes can be commented out with '#'.
454
- # - Only non-commented revisions in this file will be deleted.
455
- # - Revision hashes that are removed from this file are ignored as well.
456
- # - If `{_CANCEL_DELETION_STR}` line is uncommented, the all cache deletion is cancelled and
457
- # no changes will be applied.
458
- #
459
- # Once you've manually reviewed this file, please confirm deletion in the terminal. This
460
- # file will be automatically removed once done.
461
- # ------------
462
-
463
- # KILL SWITCH
464
- # ------------
465
- # Un-comment following line to completely cancel the deletion process
466
- # {_CANCEL_DELETION_STR}
467
- # ------------
468
-
469
- # REVISIONS
470
- # ------------
471
- """.strip()
472
-
473
-
474
- def _revision_sorting_order(revision: CachedRevisionInfo) -> Any:
475
- # Sort by last modified (oldest first)
476
- return revision.last_modified