
    Wi'                     H   d Z ddlZddlmZmZ ddlZddlmZmZm	Z	m
Z
 ddlmZ ddlmZmZmZmZmZmZmZmZ  ed	      Z ed
	      Z ed	      Zej3                  ed       ej3                  ed        G d deej6                        Zej;                  dddg      ej<                  dddddfdededeee    ej>                  d	      f   dededee  ej>                  d	      f   deee    ej>                  d	      f   d dfd!       Z!ej;                  d"d#g      ej<                  ddfdededed$ee  ej>                  d%	      f   d df
d&       Z"ej;                  d'd(g      dej<                  fd)ed*ededed df
d+       Z#ej;                  d,d-d.g      dddej<                  fded/eee    ej>                  d0	      f   deee     ej>                  d1	      f   deded dfd2       Z$ej;                  dd3d4g      ddej<                  dfdedee ejJ                  d5	      f   d6edededee  ej>                  d7	      f   d dfd8       Z&ej;                  d"d9g      dej<                  fdedee ejJ                  d:	      f   deded df
d;       Z'ej;                  dd<d=g      dddej<                  fdedee ejJ                  d>	      f   d?eee    ej>                  d@dAdB	      f   d6ededed dfdC       Z(ej;                  dDdEg      dej<                  fdededed dfdF       Z)ej;                  d"dGg      ddej<                  fdedee ejJ                  dH	      f   dIee  ej>                  dJdKdL	      f   deded dfdM       Z*y)Na  Contains commands to interact with repositories on the Hugging Face Hub.

Usage:
    # create a new dataset repo on the Hub
    hf repo create my-cool-dataset --repo-type=dataset

    # create a private model repo on the Hub
    hf repo create my-cool-model --private
    N)	AnnotatedOptional)CLIErrorHfHubHTTPErrorRepositoryNotFoundErrorRevisionNotFoundError)ANSI   )
PrivateOpt	RepoIdArgRepoTypeRepoTypeOptRevisionOptTokenOpt
get_hf_apityper_factoryzManage repos on the Hub.)helpz"Manage tags for a repo on the Hub.z&Manage branches for a repo on the Hub.tag)namebranchc                       e Zd ZdZdZdZy)GatedChoicesautomanualfalseN)__name__
__module____qualname__r   r   r        d/home/sietch6/trending-topics-pipeline/venv/lib/python3.12/site-packages/huggingface_hub/cli/repo.pyr   r   3   s    DFEr    r   createzhf repo create my-modelz7hf repo create my-dataset --repo-type dataset --private)examplesFrepo_id	repo_type	space_sdkzEHugging Face Spaces SDK type. Required when --type is set to 'space'.privatetokenexist_okz-Do not raise an error if repo already exists.resource_group_idzoResource group in which to create the repo. Resource groups is only available for Enterprise Hub organizations.returnc           	          t        |      }|j                  | |j                  |||||      }t        dt	        j
                  |j                         d       t        dt	        j
                  |              y)zCreate a new repo on the Hub.r(   )r$   r%   r'   r(   r)   r*   r&   Successfully created  on the Hub.zYour repo is now available at N)r   create_repovalueprintr	   boldr$   )	r$   r%   r&   r'   r(   r)   r*   apirepo_urls	            r!   repo_creater6   9   sy    @ 5
!C//+  H 
!$))H,<,<"=!>l
KL	*499X+>*?
@Ar    deletezhf repo delete my-model
missing_okz=If set to True, do not raise an error if repo does not exist.c                     t        |      }|j                  | |j                  |       t        dt	        j
                  |        d       y)z>Delete a repo from the Hub. This is an irreversible operation.r-   )r$   r%   r8   Successfully deleted r/   N)r   delete_repor1   r2   r	   r3   )r$   r%   r(   r8   r4   s        r!   repo_deleter<   g   sJ     5
!COO//  
 
!$))G"4!5\
BCr    movez:hf repo move old-namespace/my-model new-namespace/my-modelfrom_idto_idc                     t        |      }|j                  | ||j                         t        dt	        j
                  |        dt	        j
                  |       d       y)z8Move a repository from a namespace to another namespace.r-   )r>   r?   r%   zSuccessfully moved z to r/   N)r   	move_repor1   r2   r	   r3   )r>   r?   r(   r%   r4   s        r!   	repo_moverB   }   sZ     5
!CMM//  
 
		' 234		%8H7I
VWr    settingsz#hf repo settings my-model --privatez&hf repo settings my-model --gated autogatedz$The gated status for the repository.z)Whether the repository should be private.c                     t        |      }|j                  | |r|j                  nd||j                         t        dt	        j
                  |        d       y)z$Update the settings of a repository.r-   N)r$   rD   r'   r%   z%Successfully updated the settings of r/   )r   update_repo_settingsr1   r2   r	   r3   )r$   rD   r'   r(   r%   r4   s         r!   repo_settingsrG      sW    2 5
!C#u{{//	   
1$))G2D1E\
RSr    z"hf repo branch create my-model devz4hf repo branch create my-model dev --revision abc123z!The name of the branch to create.revisionz?If set to True, do not raise an error if branch already exists.c           
          t        |      }|j                  | |||j                  |       t        dt	        j
                  |       d|j                   dt	        j
                  |               y)z*Create a new branch for a repo on the Hub.r-   )r$   r   rH   r%   r)   r.    branch on  N)r   create_branchr1   r2   r	   r3   )r$   r   rH   r(   r%   r)   r4   s          r!   branch_createrM      sp    4 5
!C//   
!$))F"3!4K	?PPQRVR[R[\cRdQe
fgr    z"hf repo branch delete my-model devz!The name of the branch to delete.c           
          t        |      }|j                  | ||j                         t        dt	        j
                  |       d|j                   dt	        j
                  |               y)z'Delete a branch from a repo on the Hub.r-   )r$   r   r%   r:   rJ   rK   N)r   delete_branchr1   r2   r	   r3   )r$   r   r(   r%   r4   s        r!   branch_deleterP      sj     5
!C//  
 
!$))F"3!4K	?PPQRVR[R[\cRdQe
fgr    z hf repo tag create my-model v1.0z3hf repo tag create my-model v1.0 -m "First release"zThe name of the tag to create.messagez-mz	--messagez%The description of the tag to create.c           
      P   |j                   }t        |      }t        dt        j                  |       d| dt        j                  |               	 |j                  | ||||       t        dt        j                  |       dt        j                  |               y# t        $ r%}t        |j                          d|  d      |d}~wt        $ r}t        d	| d      |d}~wt        $ r2}|j                  j                  d
k(  rt        d| d|  d      | d}~ww xY w)zCreate a tag for a repo.r-   zYou are about to create tag  on rK   )r$   r   tag_messagerH   r%    '' not found.Nz
Revision 'i  Tag 'z' already exists on ''.Tag z created on )r1   r   r2   r	   r3   
create_tagr   r   
capitalizer   r   responsestatus_code)	r$   r   rQ   rH   r(   r%   repo_type_strr4   es	            r!   
tag_creater`      s    8 OOM
5
!C	(3(8]O1TYYW^M_L`
ab	wCWxcpq 
D3 TYYw-?,@
AB # V-2245RyMNTUU  CH:\:;B ::!!S(U3%'<WIRHIqPs0   B" "	D%+ CD%C''D%3-D  D%listzhf repo tag list my-modelc                    |j                   }t        |      }	 |j                  | |      }t        |j                        dk(  r!t        d       t        j                  d      t        d	| d
t        j                  |        d       |j                  D ]  }t        |j                          y# t        $ r%}t	        |j                          d|  d      |d}~ww xY w)zList tags for a repo.r-   )r$   r%   rU   rV   Nr   zNo tags found)codez	Tags for rK   :)r1   r   list_repo_refsr   r   r[   lentagsr2   typerExitr	   r3   r   )r$   r(   r%   r^   r4   refsr_   ts           r!   tag_listrl     s     OOM
5
!CV!!']!K 499~ojja  	Im_Adii&8%9
;<YY aff # V-2245RyMNTUUVs   B2 2	C ; CC z hf repo tag delete my-model v1.0zThe name of the tag to delete.yesz-yz--yesz"Answer Yes to prompt automaticallyc           
      \   |j                   }t        dt        j                  |       d| dt        j                  |               |s<t	        d      j                         }|dvrt        d       t        j                         t        |      }	 |j                  | ||       t        dt        j                  |       dt        j                  |               y# t        $ r%}t        |j                          d	|  d
      |d}~wt        $ r}t        d| d|  d      |d}~ww xY w)zDelete a tag for a repo.zYou are about to delete tag rS   rK   zProceed? [Y/n] ) yrm   Abortr-   )r$   r   r%   rU   rV   NrW   z' not found on 'rX   rY   z deleted on )r1   r2   r	   r3   inputlowerrh   ri   r   
delete_tagr   r   r[   r   )	r$   r   rm   r(   r%   r^   choicer4   r_   s	            r!   
tag_deleterv   -  s   * OOM	(3(8]O1TYYW^M_L`
ab()//1))'N**,
5
!CHwC=I
 
D3 TYYw-?,@
AB	 # V-2245RyMNTUU  Hse#3G9B?@aGHs$   C 	D+' DD+D&&D+)+__doc__enumtypingr   r   rh   huggingface_hub.errorsr   r   r   r   huggingface_hub.utilsr	   
_cli_utilsr   r   r   r   r   r   r   r   repo_clitag_cli
branch_cli	add_typerstrEnumr   commandmodelOptionboolr6   r<   rB   rG   ArgumentrM   rP   r`   rl   rv   r   r    r!   <module>r      s    &  k k &	 	 	 89
A
B HI
   7  '   :H  -3		  
!A   &^^ 	 	 	-$B$B$B X	
	$B $B $B @	
	$B" ! C	
	#$B. 
/$B$BN 
(&?%@A &^^ 	DDD D P	
		D 
D BD* 
&$`#ab %^^	XXX X 	X
 
X cX  
-0   	 	%^^TT7	
	T <	
	T T T  
!TT8 ,>   !%^^ 	!hh4	
	h h h h R	
	h" 
#hh< H(L'MN %^^hh4	
	h h h 
h Oh* 	*=  , 	 %^^%"C"C	1	
	
"C 8	
	"C  !"C" #"C$ %"C& 
'"C"CJ 	#>"?@ %^^  
	 A( 	%G$HI  	%^^#"C"C	1	
	
"C 
5	
	
"C  !"C" #"C$ 
%"C J"Cr    