+
    &jh                        R t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIt^ RIHt ^RIHtHtHtHtHtHtHtHt ^R	IHtHt ^R
IHtH t H!t!H"t"H#t#H$t$ ^RI%H&t& ]$! RR7      t']	! RR7       ! R R4      4       t(]PR                  ! R4      t*0 RAmt+0 RBmt,0 RCmt-]PR                  ! R4      t.RRRRRRRR/t// t0]1! ]-4       F  t2]2]0]2&   ]2 R2]0]2 R2&   ]2 R2]0]2 R2&   K   	  ]! R]0]3]4R7      t5]	! RR7       ! R  R!4      4       t6]7]]R,          3,          t8]9]]:]3,          3,          t;R" R# lt<R$ R% lt=R& R' lt>R( R) lt?R* R+ lt@R, R- ltAR. R/ ltBR0 R1 ltCR2 R3 ltD]'P                  R4. RDOR57      RER7 R8 ll4       tF]'P                  . RFOR57      RGR9 R: ll4       tG]'P                  R;R<.R57      RGR= R> ll4       tH]'P                  . RHOR57      ] P                  RRRR6R6R3R? R@ ll4       tJR# )IzHContains the 'hf cache' command group with cache management subcommands.N)defaultdict)CallableMapping)	dataclass)Enum)	AnnotatedAny)CLIError)ANSICachedRepoInfoCachedRevisionInfoCacheNotFoundHFCacheInfo_format_sizeparse_hf_uriscan_cache_dir)parse_duration
parse_size)	RepoIdArgRepoTypeOptRevisionOptTokenOpt
get_hf_apityper_factory)outzManage local cache directory.helpT)frozenc                   ,   a  ] tR t^1t o V 3R ltRtV tR# )_DeletionResolutionc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[S[S[ S[,          3,          ;R&   S[S[R3,          ;R&   # )   	revisionsselected.missing)	frozensetstrdictr   r   tuple)format__classdict__s   "q/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/huggingface_hub/cli/cache.py__annotate__ _DeletionResolution.__annotate__1   sF     ~  >9-?#@@AA  38_	      N)__name__
__module____qualname____firstlineno____annotate_func____static_attributes____classdictcell__r*   s   @r+   r   r   1   s      r.   r   zA^(?P<key>[a-zA-Z_]+)\s*(?P<op>==|!=|>=|<=|>|<|=)\s*(?P<value>.+)$accessedmodifiedsizenamez.^(?P<key>[a-zA-Z_]+)(?::(?P<order>asc|desc))?$descascz:asc_ascz:desc_descSortOptions)typemodulec                   0   a  ] tR t^Pt o RtV 3R ltRtV tR# )CacheDeletionCountsz>Simple counters summarizing cache deletions for CLI messaging.c                >   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   # )r!   
repo_countpartial_revision_counttotal_revision_count)int)r)   r*   s   "r+   r,    CacheDeletionCounts.__annotate__P   s+      O	 
     r.   r/   N)r0   r1   r2   r3   __doc__r4   r5   r6   r7   s   @r+   rD   rD   P   s     H  r.   rD   c                h    V ^8  d   QhR\         \        \        \        ,          3,          R\        /# )r!   selected_by_reporeturn)r   r   r%   r   rD   )r)   s   "r+   r,   r,   ]   s0     T Tni8J.KKLTTr.   c                   ^ p^ p^ pV P                  4        FW  w  rEV\        V4      ,          p\        V4      \        VP                  4      8X  g   K<  V^,          pV\        V4      ,          pKY  	  W#,
          p\        WV4      # )z(Summarize deletions across repositories.)itemslenr"   rD   )rM   rF   total_revisionsrevisions_in_full_reposrepor"   rG   s   &      r+   summarize_deletionsrU   ]   s|     JO+1133y>)y>S00!OJ#s9~5#	 4 -Fz?SSr.   c                `    V ^8  d   QhR\         \        \        \        ,          3,          RR/# )r!   rM   rN   N)r   r   r%   r   )r)   s   "r+   r,   r,   o   s/     [ [W^YWiMj=j5k [pt [r.   c           
     0   \        V P                  4       R R7       F  pVP                   RVP                   2p\        W,          R R7      p\	        V4      \	        VP
                  4      8X  d   \        P                  ! RV R24       Kq  \        P                  ! RV R24       V Fd  pRP                  \        VP                  4      4      ;'       g    R	p\        P                  ! R
VP                   RV RVP                   24       Kf  	  K  	  R# )zBPretty-print selected cache revisions during confirmation prompts.c                 N    V P                   V P                  P                  4       3# N	repo_typerepo_idlowerrT   s   &r+   <lambda>0print_cache_selected_revisions.<locals>.<lambda>q   s    $..RVR^R^RdRdRfAgr.   key/c                     V P                   # rY   commit_hashrevs   &r+   r_   r`   s       3??r.     - z (entire repo): z
(detached)z      z [z] N)sortedkeysr[   r\   rQ   r"   r   textjoinrefsrf   size_on_disk_str)rM   rT   repo_keyr"   revisionrq   s   &     r+   print_cache_selected_revisionsru   o   s    ',,.4ghnn%Qt||n5+17RS	y>S00HHtH:^454z#$!H88F8==12BBlDHHvh2232dV2h>W>W=XYZ " ir.   c          
          V ^8  d   QhR\         R\        \        \        \        3,          \        \        \        \        \
        3,          3,          3,          /# )r!   hf_cache_inforN   )r   r(   r'   r&   r   r   )r)   s   "r+   r,   r,   ~   sK     ( ((
n	eN$667	78:(r.   c                    / p/ pV P                    FQ  pVP                  P                  4       pW1V&   VP                   F   pW53W%P                  P                  4       &   K"  	  KS  	  W3# )zPCreate lookup tables so CLI commands can resolve repo ids and revisions quickly.)reposcache_idr]   r"   rf   )rw   repo_lookuprevision_lookuprT   rs   rt   s   &     r+   build_cache_indexr}   ~   sk     .0KLNO##==&&( $HH=A<LO006689 ' $
 ''r.   c                0    V ^8  d   QhR\         R\         /# )r!   targetrN   )r&   )r)   s   "r+   r,   r,      s     
" 
"s 
"s 
"r.   c                   V P                  R4      '       g   V # \        V 4      pVP                  '       g   \        R4      hVP                  f   VP
                  '       d   \        R4      hVP                   RVP                   2# )zCReturn the cache id matching a repo target passed to `hf cache rm`.zhf://z:Only repository hf:// URIs are supported by `hf cache rm`.zBOnly repo-level hf:// URIs are supported by `hf cache rm` for now.rc   )
startswithr   is_repor	   rt   path_in_reporA   id)r   uris   & r+   _repo_cache_id_from_targetr      sq    W%%
v
C;;;STT
||3#3#3#3[\\hhZq!!r.   c                t    V ^8  d   QhR\         R\        R\        \        \        ,          \
        3,          /# )r!   rw   include_revisionsrN   )r   boolr(   list
CacheEntryRepoRefsMap)r)   s   "r+   r,   r,      s3     " ""6:"
4
[()"r.   c          	        . p/ p\        V P                  R R7      pV F  p\        VP                   UUu0 uF  qfP                   F  qwkK  	  K  	  upp4      W5&   V'       d4   \        VP                  R R7       F  pVP                  WV34       K  	  Kx  VP                  VR34       K  	  V'       d   VP                  R R7       W#3# VP                  R R7       W#3# u uppi )z;Flatten cache metadata into rows consumed by `hf cache ls`.c                 N    V P                   V P                  P                  4       3# rY   rZ   r^   s   &r+   r_   'collect_cache_entries.<locals>.<lambda>   s    QUQ]Q]QcQcQe@fr.   ra   c                     V P                   # rY   re   rg   s   &r+   r_   r      ri   r.   Nc                 j    V ^ ,          P                   V ^,          e   V ^,          P                  3# R3# )     )rz   rf   entrys   &r+   r_   r      s2    a!!(-a(<a$$BDr.   c                 (    V ^ ,          P                   # )r   )rz   r   s   &r+   r_   r      s    uQx'8'8r.   )rm   ry   r%   r"   rq   appendsort)rw   r   entriesrepo_refs_mapsorted_reposrT   rt   refs   &$      r+   collect_cache_entriesr      s     !#G!#M---3fgL'T^^(e^WdWdPSWd^(ef"4>>7RS/0 T NND$<(   	 	
 !! 	89!! )fs   C"c          	          V ^8  d   QhR\         R\        R\        \        \        R,          \
        .\        3,          /# )r!   exprr   rN   N)r&   r   r   r   r   floatr   )r)   s   "r+   r,   r,      s;     > >
>)>~1D8%@$FG>r.   c           
       aaaaa	a
a \         P                  V P                  4       4      pV'       g   \        RV  R24      hVP	                  R4      P                  4       oVP	                  R4      oVP	                  R4      P                  4       oS\        9  d#   \        RS RV  R\        \        4       R	24      hS\        9  d#   \        R
S RV  R\        \        4       R	24      hSR8X  d   \        S4      o
VV
3R l# SR9   d'   \        SP                  4       4      o	R VVV	3R llpV# SR8X  d2   SP                  4       oSR8w  d   \        RS R24      hR V3R llpV# SR8w  d   \        RS R	24      hR VV3R llpV# )zqConvert a `hf cache ls` filter expression into the yes/no test we apply to each cache entry before displaying it.zInvalid filter expression: 'z'.rb   opvaluezUnsupported operator 'z' in filter ''. Must be one of .zUnsupported filter key '' in 'r:   c                 ^   < \        Ve   VP                  SS4      # V P                  SS4      # rY   )_compare_numericsize_on_disk)rT   rt   _r   size_thresholds   &&&r+   r_   &compile_cache_filter.<locals>.<lambda>   s3    )9%-%9H!!*
?C?P?P*
r.   c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# )r!   rT   rt   NnowrN   r   r   r   r   )r)   s   "r+   r,   *compile_cache_filter.<locals>.__annotate__   s6     
	B 
	B~ 
	B9Kd9R 
	BY^ 
	Bcg 
	Br.   c                    < SR 8X  d   V P                   MVe   VP                  MV P                  pVf   R# \        W#,
          SS4      # )r8   F)last_accessedlast_modifiedr   )rT   rt   r   	timestamprb   r   secondss   &&& r+   _time_filter*compile_cache_filter.<locals>._time_filter   sU     *$ "" ' ++''   #CORAAr.   rA   =z/Only '=' is supported for 'type' filters. Got 'c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# r!   rT   rt   Nr   rN   r   )r)   s   "r+   r,   r      s0     	6 	6~ 	69Kd9R 	6W\ 	6ae 	6r.   c                 >   < V P                   P                  4       S8H  # rY   )r[   r]   )rT   rt   r   expecteds   &&&r+   _type_filter*compile_cache_filter.<locals>._type_filter   s    >>'')X55r.   z.Only '=' is supported for 'refs' filters. Got c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# r   r   )r)   s   "r+   r,   r      s6     	F 	F~ 	F9Kd9R 	FW\ 	Fae 	Fr.   c                    < Ve   VP                   MSP                  V \        4       4      pSP                  4       V Uu. uF  qDP                  4       NK  	  up9   # u upi rY   )rq   getr%   r]   )rT   rt   r   rq   r   r   	value_raws   &&&  r+   _refs_filter*compile_cache_filter.<locals>._refs_filter   sM    $,$88==m>O>OPTV_Va>bD??$(E(EEE(Es   A>   r8   r9   )_FILTER_PATTERNmatchstrip
ValueErrorgroupr]   _ALLOWED_OPERATORSr   _FILTER_KEYSr   r   )r   r   r   r   r   r   r   rb   r   r   r   r   s   &f    @@@@@@r+   compile_cache_filterr      s    !!$**,/E7vR@AA
++e

"
"
$C	T	BG$**,I	##1"]4&HZ[_`r[sZttuvww
,3C5tfDVW[\hWiVjjklmm
f}#I.
 	
 && !23
	B 
	B 
f}??$9NrdRTUVV	6 	6  9MbTQRSTT	F 	F r.   c                V    V ^8  d   QhR\         R,          R\        R\         R\        /# )r!   leftNr   rightrN   )r   r&   r   )r)   s   "r+   r,   r,      s,      54< S  4 r.   c                z    V f   R# RW8H  RW8g  RW8  RW8  RW8  RW8*  /pW9  d   \        RV 24      hW1,          # )	z)Evaluate numeric comparisons for filters.Fr   !=><>=<=z)Unsupported numeric comparison operator: )r   )r   r   r   comparisonss   &&& r+   r   r      s`    | 	T]dmT\T\dmdmK 
DRDIJJ?r.   c          	          V ^8  d   QhR\         R\        \        \        .\        \        R3,          3,          \
        3,          /# )r!   	sort_exprrN   .)r&   r(   r   r   r   r   )r)   s   "r+   r,   r,     s:     3 3# 3%*uSRUX9V0WY]0]*^ 3r.   c           
       a \         P                  V P                  4       P                  4       4      pV'       g   \	        RV  R24      hVP                  R4      P                  4       oVP                  R4      pS\        9  d#   \	        RS RV  R\        \        4       R24      hV'       d   TM\        S,          pVR	8H  pR
 V3R llpWT3# )zConvert a `hf cache ls` sort expression into a key function for sorting entries.

Returns:
    A tuple of (key_function, reverse_flag) where reverse_flag indicates whether
    to sort in descending order (True) or ascending order (False).
zInvalid sort expression: 'z5'. Expected format: 'key' or 'key:asc' or 'key:desc'.rb   orderzUnsupported sort key 'r   r   r   r<   c                J    V ^8  d   QhR\         R\        \        R3,          /# )r!   r   rN   .)r   r(   r   )r)   s   "r+   r,   (compile_cache_sort.<locals>.__annotate__   s"     9 9 9c3h 9r.   c                   < V w  rSR 8X  d   VP                   P                  4       pV3# SR8X  d#   Ve   VP                  pV3# VP                  pV3# SR8X  d#   VP                  e   VP                  pV3# RpV3# SR8X  dC   Ve    VP                  e   VP                  MRpV3# VP                  e   VP                  MRpV3# \        RS 24      h)r;   r:   r8   g        r9   zUnsupported sort key: )rz   r]   r   r   r   r   )r   rT   rt   r   rb   s   &   r+   	_sort_key%compile_cache_sort.<locals>._sort_key   s    &=,,.E8O&=-5-AH))E8O HLGXGXE8O* +/*<*<*HD&&E8O ORE8O*#2:2H2H2T..Z] 8O /3.@.@.L**RU8O 1#788r.   )	_SORT_PATTERNr   r   r]   r   r   
_SORT_KEYSr   _SORT_DEFAULT_ORDER)r   r   explicit_orderr   reverser   rb   s   &     @r+   compile_cache_sortr     s     	 1 7 7 9:E5i[@uvww
++e

"
"
$C[[)N
*1#fYKGYZ^_iZjYkklmnn -N2Ec2JEvoG9 9< r.   c                R    V ^8  d   QhR\         R\        \        ,          R\        /# )r!   rw   targetsrN   )r   r   r&   r   )r)   s   "r+   r,   r,   A  s&     & &[ &49 &Qd &r.   c                d   \        V 4      w  r#\        \        4      p\        4       p. pV EF/  pVP                  4       pV'       g   K  VP	                  4       p	\
        P                  ! RV	4      '       da   VP                  V	4      p
V
f   VP                  V4       Ks  V
w  rWK,          P                  V4       VP                  VP                  4       K  VP                  \        V4      P	                  4       4      pVf   VP                  V4       K  VP                   F5  pWM,          P                  V4       VP                  VP                  4       K7  	  EK2  	  VP                  4        UUu/ uF  w  rV\        V4      bK  	  ppp\        \        V4      V\!        V4      R7      # u uppi )z8Resolve the deletion targets into a deletion resolution.z[0-9a-fA-F]{40}r"   r#   r$   )r}   r   setr   r]   re	fullmatchr   r   addrf   r   r"   rP   r%   r   r(   )rw   r   r{   r|   r#   r"   r$   
raw_targetr   loweredr   rT   rt   matched_reporevsfrozen_selecteds   &&              r+   _resolve_deletion_targetsr   A  sf   #4]#C K>I#>NH%IG
!!#,,.<<*G44#''0E}z*"NDNx(MM(../"'A&'I'O'O'QRNN:&$..H"&&x0MM(../ /+ 2 @H~~?OP?OtYt_,?OOPI& g  Qs   2F,z	list | ls)examplesFc                   V ^8  d   QhR\         \        R,          \        P                  ! RR7      3,          R\         \        \        P                  ! RR7      3,          R\         \
        \        ,          R,          \        P                  ! RR	R
R7      3,          R\         \        R,          \        P                  ! RR7      3,          R\         \        R,          \        P                  ! RR7      3,          RR/# )r!   	cache_dirN9Cache directory to scan (defaults to Hugging Face cache).r   r"   zCInclude revisions in the output instead of aggregated repositories.filterz-fz--filterzZFilter entries (e.g. 'size>1GB', 'type=model', 'accessed>7d'). Can be used multiple times.r   a  Sort entries by key. Supported keys: 'accessed', 'modified', 'name', 'size'. Append ':asc' or ':desc' to explicitly set the order (e.g., 'modified:asc'). Defaults: 'accessed', 'modified', 'size' default to 'desc' (newest/biggest first); 'name' defaults to 'asc' (alphabetical).limitzSLimit the number of results returned. Returns only the top N entries after sorting.rN   )r   r&   typerOptionr   r   r@   rI   )r)   s   "r+   r,   r,   v  s     |
 |
d
L	
	|
 V	
	|
 S	Dm	
	|
* d7	
	+|
< d
f	
	=|
H 
I|
r.   c                j    \        V 4      pT;'       g    . p\	        YQR7      w  r T U
u. uF  p
\        Y4      NK  	  pp
\        P                  ! 4       pT F3  pT Uu. uF$  q! T^ ,          T^,          T4      '       g   K"  TNK&  	  ppK5  	  T'       d-    \        TP                  4      w  ppTP                  TTR7       Te'   T^ 8  d   \        P                  ! RT R24      hTRT pT'       d   T UUu. uF  w  ppTf   K  RTP                  RTP                  R	TP                   R
TP"                  R\        TP$                  4      RTP&                  RTP(                  R\+        TP,                  4      /NK  	  ppp\.        P0                  ! T. ROR
RR/R7       MT UUu. uF}  w  ppRTP                  RTP                  R	TP                   RTP&                  RTP2                  ;'       g    RRTP(                  R\+        T	P5                  T\7        4       4      4      /NK  	  ppp\.        P0                  ! T. RORRR/R7       T'       d   T UUu0 uF  w  ppTkK
  	  ppp\9        T4      pT'       d&   \;        R T 4       4      p\;        R T 4       4      pM$\;        R T 4       4      p\;        R T 4       4      p\.        P<                  ! \>        P@                  ! RT RT R\C        T4       R24      4       R# R#   \         d   p\        RTP                   24      ThRp?ii ; iu up
i   \         d&   p\        P                  ! \        T4      4      ThRp?ii ; iu upi   \         d&   p\        P                  ! \        T4      4      ThRp?ii ; iu uppi u uppi u uppi )z&List cached repositories or revisions.Cache directory not found: N)r   )rb   r   z&Limit must be a positive integer, got r   r   r\   r[   rt   snapshot_pathr:   r   rq   r   )headersid_key
alignmentsr   r   c              3   6   "   T F  w  rVf   K  ^x  K  	  R # 5irY   r/   .0r   rh   s   &  r+   	<genexpr>ls.<locals>.<genexpr>  s      LvqCs   
c              3   J   "   T F  w  rVf   K  VP                   x  K  	  R # 5irY   r   r  s   &  r+   r  r    s     WG&!s-S--Gs   ##c              3   L   "   T F  p\        VP                  4      x  K  	  R # 5irY   )rQ   r"   r  rT   s   & r+   r  r    s      NT^^!4!4s   "$c              3   8   "   T F  qP                   x  K  	  R # 5irY   r  r
  s   & r+   r  r    s     H<4..<   z
Found z repo(s) for a total of z revision(s) and z	 on disk.)r   rt   r:   r   rq   )r   r:   r   r   rq   )"r   r   r	   r   r   r   r   r   BadParameterr&   timer   r   r   rz   r\   r[   rf   r   rr   last_modified_strrm   rq   r   tablelast_accessed_strr   r%   rQ   sumro   r
   boldr   )r   r"   r   r   r   rw   excfiltersr   r   r   
filter_fnsr   fnr   sort_key_fnr   rT   rt   rP   r   unique_reposrF   revision_count
total_sizes   &&&&&                    r+   lsr  m  s   ^O&y1 llG2=^G4LSTGD*4?G
T ))+C&-MgUE!HeAh1L55gM  	8#5djj#A KLL['L:
 19$$'MeWTU%VWW&5/ #*
 #*h	dmm4<<T^^H00X%;%;!<11!;!;x}}-	 #* 	 
 			G(		
" #
 #a dmm4<<T^^--!7!7!=!=2!7!7}00y{CD # 	 
 			L(		
 ,34GqG4&
  L LLNWGWWJ  N NNNH<HHJII:,&>~>N O$Z01<	
 M  O4S]]ODE3NO U 4  S*34
 N  	8$$SX.C7	8
*
( 5s   L L8 L3 L8  M+M++M0 ;	N#	A8N#(AN)47N)N/L0L++L03L8 8M( M##M(0N ; NN c                   V ^8  d   QhR\         \        \        ,          \        P                  ! RR7      3,          R\         \        R,          \        P
                  ! RR7      3,          R\         \        \        P
                  ! RR	R
R7      3,          R\         \        \        P
                  ! RR7      3,          RR/# )r!   r   ziOne or more repo IDs (e.g. model/bert-base-uncased), repo-level hf:// URIs, or revision hashes to delete.r   r   Nr   yes-y--yesSkip confirmation prompt.dry_run,Preview deletions without removing anything.rN   )r   r   r&   r   Argumentr   r   )r)   s   "r+   r,   r,     s     O OS	|	
	O d
L	
	O 
,	
	
O* ?	
	+O6 
7Or.   c           	         \        V4      p\	        Y@4      pTP
                  '       d<   RP                  R TP
                   4       4      p\        P                  ! RT 24       \        TP                  4      ^ 8X  d.   \        P                  ! R4       \        P                  ! ^ R7      hTP                  ! \        TP                  4      !  p\!        TP"                  4      p	. p
T	P$                  '       d   T
P'                  T	P$                   R24       T	P(                  '       d   T
P'                  T	P(                   R	24       T
'       g   T
P'                  T	P*                   R	24       R
P                  T
4      p\        P                  ! RT RTP,                   R24       \/        TP"                  4       T'       d<   \        P0                  ! RRT	P$                  T	P*                  TP,                  R7       R# \        P2                  ! RTR7       TP5                  4        \!        TP"                  4      p	\        P0                  ! RT	P$                   RT	P*                   RTP,                   R2T	P$                  T	P*                  TP,                  R7       R#   \         d   p\        RTP                   24      ThRp?ii ; i)z(Remove cached repositories or revisions.r   N
c              3   ,   "   T F
  pR V 2x  K  	  R# 5irj   Nr/   )r  r   s   & r+   r  rm.<locals>.<genexpr>#  s     K8Jud5'N8J   zCould not find in cache:
zNothing to delete.codez repo(s)z revision(s)z and About to delete z totalling r   Dry run: no files were deleted.T)r"  ry   r"   r:   zProceed with deletion?r  Deleted z repo(s) and z revision(s); freed )repos_deletedrevisions_deletedfreed)r   r   r	   r   r   r$   rp   r   warningrQ   r"   ro   r   Exitdelete_revisionsrm   rU   r#   rF   r   rG   rH   expected_freed_size_strru   resultconfirmexecute)r   r   r  r"  rw   r  
resolutiondetailsstrategycountssummary_partssummary_texts   &&&&        r+   rmrA    sP   LO&y1 +=BJ))K
8J8JKK0	:;
: A%%&jja  --vj6J6J/KLH !4!45F!M 1 12(;<$$$ = =>lKL ; ;<LIJ<<.LHH~[9Y9Y8ZZ[\]":#6#67

-##1111	
 	KK(c2 !4!45FJJ
6$$%]63N3N2O P2231	6'' 55..U  O4S]]ODE3NOs   J K&J??Kzhf cache prunezhf cache prune --dry-runc                   V ^8  d   QhR\         \        R,          \        P                  ! RR7      3,          R\         \        \        P                  ! RRRR7      3,          R	\         \        \        P                  ! R
R7      3,          RR/# )r!   r   Nr   r   r  r  r   r!  r"  r#  rN   )r   r&   r   r   r   )r)   s   "r+   r,   r,   Q  s     F Fd
L	
	F 
,	
	
F ?	
	F* 
+Fr.   c                    \        V 4      p/ p\	        4       pTP
                   FE  p\        R TP                   4       4      pT'       g   K)  YT&   TP                  R T 4       4       KG  	  \        T4      ^ 8X  d   \        P                  ! R4       R# \        \        T4      TRR7      p	TP                  ! \        T	P                  4      !  p
\        T4      p\        P                  ! RTP                    RT
P"                   R	24       \%        T4       T'       d1   \        P&                  ! R
RTP                   T
P"                  R7       R# \        P(                  ! RTR7       T
P+                  4        \        P&                  ! RTP                    RT
P"                   R2TP                   T
P"                  R7       R#   \         d   p\        RTP                   24      ThRp?ii ; i)z)Remove detached revisions from the cache.r   Nc              3   ^   "   T F#  p\        VP                  4      ^ 8X  g   K  Vx  K%  	  R# 5i)r   N)rQ   rq   r  rt   s   & r+   r  prune.<locals>.<genexpr>p  s#     `n(HMMHZ^_H_XXns   -
-c              3   8   "   T F  qP                   x  K  	  R # 5irY   re   rE  s   & r+   r  rF  t  s     Gh(--hr  z2No unreferenced revisions found. Nothing to prune.r   r-  z unreferenced revision(s) (z total).r.  T)r"  r"   r:   zProceed?r/  r0  z! unreferenced revision(s); freed r   )r2  r3  r/   )r   r   r	   r   r   ry   r%   r"   updaterQ   r   ro   r   r6  rm   rU   rH   r7  ru   r8  r9  r:  )r   r  r"  rw   r  r#   r"   rT   detachedr;  r=  r>  s   &&&         r+   prunerJ  P  s   0O&y1 EGH%I##`dnn``!GhGG $ 9~EF$I&J
 --vj6J6J/KLH *FHH
66677RS[SsSsRtt|} #8,

-1111		
 	KK
$JJ
6..//PQYQqQqPrrst 55..S  O4S]]ODE3NOs   G G*G%%G*c                   V ^8  d   QhR\         R\        R\        R\        \        R,          \
        P                  ! RR7      3,          R\        \        R,          \
        P                  ! R	R7      3,          R
\        \        \
        P                  ! RRR7      3,          R\        \        \
        P                  ! RRR7      3,          R\        RR/	# )r!   r\   r[   rt   r   NzXCache directory to use when verifying files from cache (defaults to Hugging Face cache).r   	local_dirz?If set, verify files under this directory instead of the cache.fail_on_missing_filesz--fail-on-missing-filesz?Fail if some files exist on the remote but are missing locally.fail_on_extra_filesz--fail-on-extra-fileszLFail if some files exist locally but are not present on the remote revision.tokenrN   )	r   r   r   r   r&   r   r   r   r   )r)   s   "r+   r,   r,     s     f fff f d
k	
		f d
R	
	f  %%R	
	!f. ##_	
	/f< =f> 
?fr.   c           
     "   Ve2   Ve.   \         P                  ! R4       \        P                  ! ^R7      h\	        VR7      pTP                  T \        VR4      '       d   VP                  M
\        V4      VVVVR7      p	^ p
V	P                  '       d>   RP                  R V	P                   4       4      p\         P                  ! R	V 24       ^p
V	P                  '       ds   V'       d?   RP                  R
 V	P                   4       4      p\         P                  ! RV 24       ^p
M,\         P                  ! \        V	P                  4       R24       V	P                  '       ds   V'       d?   RP                  R V	P                   4       4      p\         P                  ! RV 24       ^p
M,\         P                  ! \        V	P                  4       R24       V	P                   pV
^ 8w  dN   \         P                  ! RV  RVP                   RV RV	P"                   24       \        P                  ! V
R7      h\         P$                  ! RV	P&                   RVP                   RV  R2V VP                  V	P&                  \        V4      R7       R# )a  Verify checksums for a single repo revision from cache or a local directory.

Examples:
  - Verify main revision in cache: `hf cache verify gpt2`
  - Verify specific revision: `hf cache verify gpt2 --revision refs/pr/1`
  - Verify dataset: `hf cache verify karpathy/fineweb-edu-100b-shuffle --repo-type dataset`
  - Verify local dir: `hf cache verify deepseek-ai/DeepSeek-OCR --local-dir /path/to/repo`
NzCCannot pass both --local-dir and --cache-dir. Use one or the other.r+  )rO  r   )r\   r[   rt   rL  r   rO  r&  c           
   3   v   "   T F/  pR VR,           RVR,           RVR,           RVR,           2x  K1  	  R# 5i)	rj   pathz: expected r   z (	algorithmz), got actualNr/   )r  ms   & r+   r  verify.<locals>.<genexpr>  sE      
& 1V9+[:r!K.9IQRS[Q\P]^&s   79u<   ❌ Checksum verification failed for the following file(s):
c              3   ,   "   T F
  pR V 2x  K  	  R# 5ir(  r/   r  ps   & r+   r  rV    s     I4Hq$qc
4Hr*  u6   ❌ Missing files (present remotely, absent locally):
zM remote file(s) are missing locally. Use --fail-on-missing-files for details.c              3   ,   "   T F
  pR V 2x  K  	  R# 5ir(  r/   rX  s   & r+   r  rV    s     G4Fq$qc
4Fr*  u4   ❌ Extra files (present locally, absent remotely):
zV local file(s) do not exist on the remote repo. Use --fail-on-extra-files for details.zVerification failed for 'z' (z) in z.
  Revision: z	Verified z file(s) for z 'z'. All checksums match.)r\   r[   checkedrR  )r   errorr   r5  r   verify_repo_checksumshasattrr   r&   
mismatchesrp   ro   missing_pathsr4  rQ   extra_pathsverified_pathrt   r8  checked_count)r\   r[   rt   r   rL  rM  rN  rO  apir8  	exit_coder<  verified_locations   &&&&&&&&     r+   verifyrg    sC   ` !6		WXjja  
5
!C&&%,Y%@%@)//c)n ' F I)) 
&&
 
 	PQXPYZ[	 iiIF4H4HIIGHHNwiXYIKKv++,- .; ;
 iiGF4F4FGGGHHLWIVWIKKv))*+ ,9 9
 ,,A~		'yIOO3DEJ[I\\klrl{l{k|}	
 jji((JJ
F(()y6Gr'Rij//$$"#r.   >   r   r   r   r   r   r   >   rq   r:   rA   r8   r9   >   r;   r:   r8   r9   )zhf cache lszhf cache ls --revisionsz*hf cache ls --filter "size>1GB" --limit 20zhf cache ls --format json)NFNNN)zhf cache rm model/gpt2z-hf cache rm hf://models/openai-community/gpt2zhf cache rm <revision_hash>z hf cache rm model/gpt2 --dry-runzhf cache rm model/gpt2 --yes)NFF)zhf cache verify gpt2z)hf cache verify gpt2 --revision refs/pr/1z.hf cache verify my-dataset --repo-type dataset)KrK   r   r  collectionsr   collections.abcr   r   dataclassesr   enumr   typingr   r   r   huggingface_hub.errorsr	   utilsr
   r   r   r   r   r   r   r   utils._parsingr   r   
_cli_utilsr   r   r   r   r   r   _outputr   	cache_clir   compiler   r   r   r   r   r   _sort_options_dictrm   rb   r&   r0   r@   rD   r(   r   r'   r%   r   rU   ru   r}   r   r   r   r   r   r   commandr  rA  rJ  modelrg  r/   r.   r+   <module>rw     sq   O 	  # - !  !  +	 	 	 8 ` `  >?	 $   **ab6 ?5


LM 
F
E   *C!s*-d|#d|$+.%u#e}% 
 ="43xP $   >#5#<<=
>9S>12T$[("
""4>B(3l&X   |
|
~   OOd -/IJKF LFR    )..  	 	 	 	=ffr.   