
    j@              (       B   d Z ddlZddlmZ ddlZddlmZm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mZmZmZmZmZmZmZmZ dd	l m!Z!  ed
          Z"e"#                    d          dej$        ddfd            Z% ed          Z& ed          Z'e"(                    e&d           e"(                    e'd            G d de)ej*                  Z+ee,dz   ej-        dd          f         Z.ee,dz   ej-        dd          f         Z/eedz   ej-        dd          f         Z0eedz   ej-        dd          f         Z1ee2dz   ej-        d d!          f         Z3e"4                    d"g d#$          ej5        dddddd%ddddddddddfd&ed'ed(ee)dz   ej-        d)          f         d*ed+e.d,e/d-ed.ee, ej-        d/          f         d0ee)dz   ej-        d1          f         d2eedz   ej-        d3d4          f         d5e0d6e1d7e3d8ed9ed:ed;ed<eddf&d=            Z6e"4                    d>g d?$          dej5        ddddd%ddddddddfd@edAee)dz   ej7        dB          f         d'ed*ed+e.d,e/d-ed.ee, ej-        d/          f         d5e0d6e1d7e3d8ed9ed:ed;ed<eddf"dC            Z8e"4                    dDdEg$          ej5        dd%d%fd&ed'ed-edFee, ej-        dG          f         dHee, ej-        dIdJdK          f         ddfdL            Z9e"4                    dMdNg$          dej5        fd@edAed-ed'eddf
dO            Z:e"4                    dPg dQ$          dddddej5        fd&edRee+dz   ej-        dS          f         d*ed+e.d,e/d-ed'eddfdT            Z;e"4                    dUg dV$          ej5        dddd%dfd&edWee<e)          ej7        dX          f         d'edYedZee)dz   ej-        d[          f         d\ee)dz   ej-        d]          f         d^ee, ej-        d_          f         d-eddfd`            Z=e'4                    d"dadbg$          ddej5        d%fd&edee) ej7        dc          f         dYed-ed'ed.ee, ej-        dd          f         ddfde            Z>e'4                    dDdfg$          dej5        fd&edee) ej7        dg          f         d-ed'eddf
dh            Z?e&4                    d"didjg$          dddej5        fd&edee) ej7        dk          f         dlee)dz   ej-        dmdndo          f         dYed-ed'eddfdp            Z@e&4                    dqdrg$          dej5        fd&ed-ed'eddfds            ZAe&4                    dDdtg$          d%dej5        fd&edee) ej7        du          f         dHee, ej-        dIdJdv          f         d-ed'eddfdw            ZBdS )xae  Contains commands to interact with repositories on the Hugging Face Hub.

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

    # create a private model repo on the Hub
    hf repos create my-cool-model --private

    # delete files from a repo on the Hub
    hf repos delete-files my-model file.txt
    N)	Annotated)SpaceHardwareSpaceStorage)CLIErrorHfHubHTTPErrorRepositoryNotFoundErrorRevisionNotFoundError)REPO_REGIONS   )
EnvFileOptEnvOpt
PrivateOpt	RepoIdArgRepoTypeRepoTypeOptRevisionOptSecretsFileOpt
SecretsOptTokenOpt
VolumesOptenv_map_to_key_value_list
get_hf_apiparse_env_mapparse_volumestyper_factory)outzManage repos on the Hub.)helpT)invoke_without_commandctxreturnc                 H    | j         dk    rt          j        d           d S d S )Nrepoz/`hf repo` is deprecated in favor of `hf repos`.)	info_namer   warning)r   s    \/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/huggingface_hub/cli/repos.py_repos_callbackr&   <   s.    
}EFFFFF     z"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dS )GatedChoicesautomanualfalseN)__name__
__module____qualname__r-   r.   r/    r'   r%   r,   r,   H   s        DFEEEr'   r,   z--publiczDWhether to make the repo public. Ignored if the repo already exists.z--protectedzVWhether to make the Space protected (Spaces only). Ignored if the repo already exists.z--flavorzOSpace hardware flavor (e.g. 'cpu-basic', 't4-medium', 'l4x4'). Only for Spaces.z	--storagezq(Deprecated, use volumes instead) Space persistent storage tier ('small', 'medium', or 'large'). Only for Spaces.z--sleep-timez[Seconds of inactivity before the Space is put to sleep. Use -1 to disable. Only for Spaces.create)zhf repos create my-modelz8hf repos create my-dataset --repo-type dataset --privatezxhf repos create my-space --type space --space-sdk gradio --flavor t4-medium --secrets HF_TOKEN -e THEME=dark --protectedzihf repos create my-space --type space --space-sdk gradio -v hf://gpt2:/models -v hf://buckets/org/b:/dataz$hf repos create my-model --region us)examplesFrepo_id	repo_type	space_sdkzEHugging Face Spaces SDK type. Required when --type is set to 'space'.privatepublic	protected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.regionz--regionzbCloud region in which to create the repo. Can be one of 'us' or 'eu'. Requires Team plan or above.hardwarestorage
sleep_timesecretssecrets_fileenvenv_filevolumec                 f   t          |          }|                    | |j        |rdn	|rdn|rdnd||||	||
||t          t	          ||                    t          t	          ||                    t          |                    }t          j        d|j        t          |                     dS )	zCreate a new repo on the Hub.r<   r9   r:   r;   N)r6   r7   
visibilityr<   r=   r>   r?   r8   space_hardwarespace_storagespace_sleep_timespace_secretsspace_variablesspace_volumeszRepo created)r6   url)
r   create_repovaluer   r   r   r   resultr6   str)r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   apirepo_urls                       r%   repo_createrX   v   s    h 5
!
!
!C/ 'g99-gXXT]Eg[[cg+#/g|0T0TUU1-X2N2NOO#F++   H  J~x'7S]]KKKKKKr'   	duplicate)z/hf repos duplicate openai/gdpval --type datasetzzhf repos duplicate multimodalart/dreambooth-training my-dreambooth --type space --flavor l4x4 --secrets HF_TOKEN --privatezfhf repos duplicate org/my-space my-space --type space -v hf://gpt2:/models -v hf://buckets/org/b:/datafrom_idto_idz_Destination repo ID (e.g. `myorg/my-copy`). Defaults to your namespace with the same repo name.c                 d   t          |          }|                    | ||j        |rdn	|rdn|rdnd||||	|
t          t	          ||                    t          t	          ||                    t          |                    }t          j        d| |j        t          |                     dS )	z7Duplicate a repo on the Hub (model, dataset, or Space).rI   r9   r:   r;   N)rZ   r[   r7   rJ   r<   r=   rK   rL   rM   rN   rO   rP   zRepo duplicated)rZ   r[   rQ   )
r   duplicate_reporS   r   r   r   r   rT   r6   rU   )rZ   r[   r7   r9   r:   r;   r<   r=   r@   rA   rB   rC   rD   rE   rF   rG   rV   rW   s                     r%   repo_duplicater^      s    J 5
!
!
!C!!/ 'g99-gXXT]Eg[[cg#/g|0T0TUU1-X2N2NOO#F++ "  H J '9IsS[}}]]]]]]r'   deletezhf repos delete my-model
missing_okz=If set to True, do not raise an error if repo does not exist.yesz-yz--yesz#Answer Yes to prompt automatically.c                     t          j        d|j         d|  d|           t          |          }|                    | |j        |           t          j        d|            d	S )
z>Delete a repo from the Hub. This is an irreversible operation.z$You are about to permanently delete  'z'. Proceed?ra   rI   )r6   r7   r`   zRepo deletedr6   N)r   confirmrS   r   delete_reporT   )r6   r7   r<   r`   ra   rV   s         r%   repo_deleterh      s    * K^y^^'^^^dghhhh
5
!
!
!COO/    
 J~w//////r'   movez;hf repos move old-namespace/my-model new-namespace/my-modelc                     t          |          }|                    | ||j                   t          j        d| |           dS )z8Move a repository from a namespace to another namespace.rI   )rZ   r[   r7   z
Repo moved)rZ   r[   N)r   	move_reporS   r   rT   )rZ   r[   r<   r7   rV   s        r%   	repo_moverl     sY     5
!
!
!CMM/    
 J|WE::::::r'   settings)z$hf repos settings my-model --privatez'hf repos settings my-model --gated autoz8hf repos settings my-space --repo-type space --protectedgatedz$The gated status for the repository.c                     t          |          }|                    | |dn|t          j        u rdn|j        |rdn	|rdn|rdnd|j                   t          j        d| 	           dS )
z$Update the settings of a repository.rI   NFr9   r:   r;   )r6   rn   rJ   r7   zRepo settings updatedre   )r   update_repo_settingsr,   r/   rS   r   rT   )r6   rn   r9   r:   r;   r<   r7   rV   s           r%   repo_settingsrq   %  s    . 5
!
!
!C}tt5L<N3N3N%%TYT_ 'g99-gXXT]Eg[[cg/	     J&888888r'   zdelete-files)z'hf repos delete-files my-model file.txtz'hf repos delete-files my-model "*.json"z&hf repos delete-files my-model folder/patternszXGlob patterns to match files to delete. Based on fnmatch, '*' matches files recursively.revisioncommit_messagez9The summary / title / first line of the generated commit.commit_descriptionz(The description of the generated commit.	create_prz7Whether to create a new Pull Request for these changes.c           	          t          |          }|                    || |j        ||||          }	t          j        d| |	           dS )z$Delete files from a repo on the Hub.rI   )delete_patternsr6   r7   rs   rt   ru   rv   zFiles deleted)r6   
commit_urlN)r   delete_filesrS   r   rT   )
r6   rr   r7   rs   rt   ru   rv   r<   rV   rQ   s
             r%   repo_delete_filesr{   F  se    N 5
!
!
!C


 /%-   C JC@@@@@@r'   z#hf repos branch create my-model devz5hf repos branch create my-model dev --revision abc123z!The name of the branch to create.z?If set to True, do not raise an error if branch already exists.c                     t          |          }|                    | |||j        |           t          j        d||j        |            dS )z*Create a new branch for a repo on the Hub.rI   )r6   r*   rs   r7   r=   zBranch createdr*   r7   r6   N)r   create_branchrS   r   rT   )r6   r*   rs   r<   r7   r=   rV   s          r%   branch_creater   z  sg    4 5
!
!
!C/     J)/SZ[[[[[[r'   z#hf repos branch delete my-model devz!The name of the branch to delete.c                     t          |          }|                    | ||j                   t          j        d||j        |            dS )z'Delete a branch from a repo on the Hub.rI   )r6   r*   r7   zBranch deletedr}   N)r   delete_branchrS   r   rT   )r6   r*   r<   r7   rV   s        r%   branch_deleter     sa     5
!
!
!C/    
 J)/SZ[[[[[[r'   z!hf repos tag create my-model v1.0z4hf repos 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                    |j         }t          |          }	 |                    | ||||           n# t          $ r-}t	          |                                 d|  d          |d}~wt          $ r}t	          d| d          |d}~wt          $ r-}|j        j	        dk    rt	          d| d	|  d
          | d}~ww xY wt          j        d|||            dS )zCreate a tag for a repo.rI   )r6   r(   tag_messagers   r7   rc   ' not found.Nz
Revision 'i  Tag 'z' already exists on ''.zTag createdr(   r7   r6   )rS   r   
create_tagr   r   
capitalizer	   r   responsestatus_coder   rT   )	r6   r(   r   rs   r<   r7   repo_type_strrV   es	            r%   
tag_creater     s3   8 OM
5
!
!
!C	wCWxcpqqqq" V V V-2244MMMMMNNTUU  C C C:H:::;;B   :!S((H3HHWHHHIIqP J}#PPPPPPs,   4 
C(A&&C3BC(B<<Cz	list | lszhf repos tag list my-modelc                 $   |j         }t          |          }	 |                    | |          }n:# t          $ r-}t	          |                                 d|  d          |d}~ww xY wd |j        D             }t          j        |           dS )zList tags for a repo.rI   )r6   r7   rc   r   Nc                 8    g | ]}|j         |j        |j        d S )r)   target_commitrefr   ).0ts     r%   
<listcomp>ztag_list.<locals>.<listcomp>  s)    aaaRSafqquMMaaar'   )	rS   r   list_repo_refsr   r   r   tagsr   table)r6   r<   r7   r   rV   refsr   itemss           r%   tag_listr     s     OM
5
!
!
!CV!!']!KK" V V V-2244MMMMMNNTUUVaaW[W`aaaEIes   1 
A((A##A(z!hf repos tag delete my-model v1.0zThe name of the tag to delete.z"Answer Yes to prompt automaticallyc                    |j         }t          j        d| d| d|             t          j        d|           t	          |          }	 |                    | ||           n^# t          $ r-}t          |                                 d|  d	          |d
}~wt          $ r}t          d| d|  d          |d
}~ww xY wt          j
        d|||            d
S )zDelete a tag for a repo.zYou are about to delete tag z on  zProceed?rd   rI   )r6   r(   r7   rc   r   Nr   z' not found on 'r   zTag deletedr   )rS   r   textrf   r   
delete_tagr   r   r   r	   rT   )r6   r(   ra   r<   r7   r   rV   r   s           r%   
tag_deleter     s'   * OMHNCNN]NNWNNOOOK
$$$$
5
!
!
!CHwC=IIII" V V V-2244MMMMMNNTUU  H H H?s??G???@@aGHJ}#PPPPPPs$   A% %
C /(BC $B;;C )C__doc__enumtypingr   typerhuggingface_hubr   r   huggingface_hub.errorsr   r   r   r	   huggingface_hub.hf_apir
   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _outputr   	repos_clicallbackContextr&   tag_cli
branch_cli	add_typerrU   Enumr,   boolOption	PublicOptProtectedOptSpaceHardwareOptSpaceStorageOptintSpaceSleepTimeOptcommandmodelrX   Argumentr^   rh   rl   rq   listr{   r   r   r   r   r   r3   r'   r%   <module>r      sx            7 7 7 7 7 7 7 7 k k k k k k k k k k k k / / / / / /                                   $       M9:::	 400G G4 G G G 10G
 -A
B
B
B] HIII
 	  G%  ( ( ( 	  JX  . . .    3	    4KELS  	 4KELe   DEL^    4EL A   $JELj        	 	 &^ 	" 	 	 	!%#$(#'O;L ;L;L;L d
X	
 	
 	
	;L ;L ;L ;L ;L @	
 	
 	
	;L& !d
 C	
 	
 	
	';L2 tu	
 	
 	
	3;L@ A;LB C;LD "E;LF G;LH !I;LJ 
K;LL M;LN O;LP 
Q;L ;L ;L	 	;L|       	%^" 	!%#$(#'5,^ ,^,^d
r	
 	
 	
	,^ ,^ ,^ ,^ ,^ ,^ @	
 	
 	
	,^& ',^( ),^* "+,^, -,^. !/,^0 
1,^2 3,^4 5,^6 
7,^ ,^ ,^ ,^^ 8'A&BCC &^ 	 	#0 000 0 P	
 	
 	
		0 
6	
 	
 	
	
0$ 
%0 0 0 DC0< 6%b$cdd %^	; ;;; ; 	;
 
; ; ; ed;        	"%^9 99t7	
 	
 	
	9 9 9 9 9 9 
9 9 9 92        &^  	 	 	9)A )A)AS	k	
 	
 	
	)A )A )A d
L	
 	
 	
	)A  "d
;	
 	
 	
	!)A, J	
 	
 	
	-)A8 9)A: 
;)A )A )A )AX -?    !%^ 	!\ \\4	
 	
 	
	\ \ \ \ R	
 	
 	
	\" 
#\ \ \ \< H(M'NOO %^\ \\4	
 	
 	
	\ \ \ 
\ \ \ PO\* 	+>   , 	 %^%!Q !Q!Q	1	
 	
 	
	
!Q d
8	
 	
 	
	!Q  !!Q" #!Q$ %!Q& 
'!Q !Q !Q !QH 	(D'EFF %^   
	   GF  	%H$IJJ  	%^#Q QQ	1	
 	
 	
	
Q 
5	
 	
 	
	
Q  !Q" #Q$ 
%Q Q Q KJQ Q Qr'   