
    gjJN              (           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	 ddl
mZmZmZmZ ddl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#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z,m-Z-  e&d          Z.e./                    d          dej0        ddfd            Z1 G d de2ej3                  Z4 G d de2ej3                  Z5ee6dz   ej7        dd          f         Z8ee6dz   ej7        dd          f         Z9ee2dz   ej7        dd e	e                    f         Z:eedz   ej7        d d!          f         Z;ee<dz   ej7        d"d#          f         Z= e&d$          Z> e&d%          Z?e.@                    e>d&'           e.@                    e?d('           e.A                    d)g d*+          ddded,dfd-ee2dz   ej7        d.          f         d/ee4dz   ej7        d0d1d2          f         d3ed4ed5ee6 ej7        d6d7          f         d8e ddfd9            ZBe.A                    d:g d;+          ejC        dddddd,ddddddddddfd<ed/ed=ee2dz   ej7        d>          f         d?ed@e8dAe9d8e dBee6 ej7        dC          f         dDee2dz   ej7        dE          f         dFeedz   ej7        dGdH          f         dIe:dJe;dKe=dLedMedNedOedPe!ddf&dQ            ZDe.A                    dRg dS+          dejC        ddddd,ddddddddfdTedUee2dz   ejE        dV          f         d/ed?ed@e8dAe9d8e dBee6 ej7        dC          f         dIe:dJe;dKe=dLedMedNedOedPe!ddf"dW            ZFe.A                    dXdYg+          ejC        dd,d,fd<ed/ed8e dZee6 ej7        d[          f         d\ee6 ej7        d]d^d_          f         ddfd`            ZGe.A                    dadbg+          dejC        fdTedUed8e d/eddf
dc            ZHe.A                    ddg de+          dddddejC        fd<edfee5dz   ej7        dg          f         d?ed@e8dAe9d8e d/eddfdh            ZIe.A                    dig dj+          ejC        dddd,dfd<edkeeJe2          ejE        dl          f         d/edmednee2dz   ej7        do          f         dpee2dz   ej7        dq          f         dree6 ej7        ds          f         d8e ddfdt            ZK e.A                    dug dvw           e(dx                     e?A                    d:dydzg+          ddejC        d,fd<ed(ee2 ejE        d{          f         dmed8e d/edBee6 ej7        d|          f         ddfd}            ZLe?A                    dXd~g+          dejC        fd<ed(ee2 ejE        d          f         d8e d/eddf
d            ZMe>A                    d:ddg+          dddejC        fd<ed&ee2 ejE        d          f         dee2dz   ej7        ddd          f         dmed8e d/eddfd            ZNe>A                    d)dg+          dejC        fd<ed8e d/eddfd            ZOe>A                    dXdg+          d,dejC        fd<ed&ee2 ejE        d          f         d\ee6 ej7        d]d^d          f         d8e d/eddfd            ZPdS )ae  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)
SoftChoice)CLIErrorHfHubHTTPErrorRepositoryNotFoundErrorRevisionNotFoundError)REPO_REGIONS   )run_city_game)REPO_LIST_DEFAULT_LIMIT
EnvFileOptEnvOptLimitOpt
PrivateOpt	RepoIdArgRepoTypeRepoTypeOptRevisionOpt	SearchOptSecretsFileOpt
SecretsOptTokenOpt
VolumesOptenv_map_to_key_value_list
get_hf_apiparse_env_mapparse_volumestyper_factory)make_cp)format_size)OutputFormat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/app.qaans.com/backend/venv/lib/python3.11/site-packages/huggingface_hub/cli/repos.py_repos_callbackr.   C   s.    
}EFFFFF     c                       e Zd ZdZdZdZdZdS )RepoTypeAllmodeldatasetspacebucketN)__name__
__module____qualname__r2   r3   r4   r5    r/   r-   r1   r1   I   s"        EGEFFFr/   r1   c                       e Zd ZdZdZdZdS )GatedChoicesautomanualfalseN)r6   r7   r8   r<   r=   r>   r9   r/   r-   r;   r;   P   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.)r%   
click_typez	--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.z"Manage tags for a repo on the Hub.z&Manage branches for a repo on the Hub.tag)namebranchz	list | ls)zhf repos lszhf repos ls --explorez,hf repos ls --namespace my-org --search bert)examplesF	namespacezKOrganization name. If not provided, lists repos for the authenticated user.	repo_typez--typez--repo-typez=Filter by repository type (model, dataset, space, or bucket).searchlimitexplorez	--explorez-Explore your repos as an interactive 3D city.tokenc                 0  
 t          |          }t          |                    |                     }fd|D             }|"|                                

fd|D             }t	          |          }|r:t
          j        t          j        k    rt          |           dS t          d          |dk    r
|d|         }d |D             }	t          j        |	d	d
d
d           |dk    r#||k    rt          j        d| d| d           dS dS dS )zEList all repos (models, datasets, spaces, buckets) with storage info.rI   )rD   Nc                 4    g | ]}|j         j        k    |S r9   )typevalue).0rrE   s     r-   
<listcomp>zrepo_list.<locals>.<listcomp>   s'    ???qQVy%>%>%>%>%>r/   c                 J    g | ]}|j                                         v | S r9   )idlower)rO   rP   search_lowers     r-   rQ   zrepo_list.<locals>.<listcomp>   s-    BBBq\QTZZ\\%A%A%A%A%Ar/   z5Repository exploration is only available in terminal.r   c           
          g | ]O}|j         |j        |j                            d           |j        t          |j        d          |j        dddPS )z%Y-%m-%dT)human_readablez.1f%)rS   rM   updated
visibilitystorage
%_of_total)rS   rM   
updated_atstrftimerZ   r"   r[   storage_percent)rO   rP   s     r-   rQ   zrepo_list.<locals>.<listcomp>   sw     
 
 
  $F|,,Z88,"19TBBB.5555	
 	

 
 
r/   rS   right)r[   r\   )id_key
alignmentszShowing z of z$ repos. Use `--limit 0` to list all.)r   listlist_user_reposrT   lenr$   moder#   humanr   r   tablehint)rD   rE   rF   rG   rH   rI   apirepostotalitemsrU   s    `        @r-   	repo_listrn      sd   @ 5
!
!
!C$$y$99::E????E???||~~BBBBEBBBJJE P8|)))%   FNOOOqyyfuf
 
 
 
 
E IeDPW-X-XYYYYqyyUU]]RERRuRRRSSSSS y]]r/   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 --protectedzqhf repos create my-space --type space --space-sdk gradio -v hf://org/my-model:/models -v hf://buckets/org/b:/dataz$hf repos create my-model --region usrepo_id	space_sdkzEHugging Face Spaces SDK type. Required when --type is set to 'space'.privatepublic	protected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.hardwarer[   
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.rK   rr   rs   rt   N)rp   rE   rZ   rI   ru   rv   rw   rq   space_hardwarespace_storagespace_sleep_timespace_secretsspace_variablesspace_volumeszRepo created)rp   url)
r   create_reporN   r   r   r   r$   resultrp   str)rp   rE   rq   rr   rs   rt   rI   ru   rv   rw   rx   r[   ry   rz   r{   r|   r}   r~   rj   repo_urls                       r-   repo_creater      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 --privateznhf repos duplicate org/my-space my-space --type space -v hf://org/my-model:/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).rK   rr   rs   rt   N)r   r   rE   rZ   rI   ru   r   r   r   r   r   r   zRepo duplicated)r   r   r   )
r   duplicate_reporN   r   r   r   r$   r   rp   r   )r   r   rE   rr   rs   rt   rI   ru   rx   r[   ry   rz   r{   r|   r}   r~   rj   r   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?r   rK   )rp   rE   r   zRepo deletedrp   N)r$   confirmrN   r   delete_repor   )rp   rE   rI   r   r   rj   s         r-   repo_deleter   E  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.rK   )r   r   rE   z
Repo moved)r   r   N)r   	move_reporN   r$   r   )r   r   rI   rE   rj   s        r-   	repo_mover   d  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.rK   NFrr   rs   rt   )rp   r   rZ   rE   zRepo settings updatedr   )r   update_repo_settingsr;   r>   rN   r$   r   )rp   r   rr   rs   rt   rI   rE   rj   s           r-   repo_settingsr   u  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.rK   )delete_patternsrp   rE   r   r   r   r   zFiles deleted)rp   
commit_urlN)r   delete_filesrN   r$   r   )
rp   r   rE   r   r   r   r   rI   rj   r   s
             r-   repo_delete_filesr     se    N 5
!
!
!C


 /%-   C JC@@@@@@r/   cp)	z:hf repos cp hf://username/my-model/config.json config.jsonz<hf repos cp hf://datasets/username/my-dataset/data.csv data/z0hf repos cp hf://username/my-model/config.json -zFhf repos cp model.safetensors hf://username/my-model/model.safetensorsz4hf repos cp config.json hf://username/my-model/logs/z0hf repos cp - hf://username/my-model/config.jsonzWhf repos cp hf://username/source-model/config.json hf://username/dest-model/config.jsonzghf repos cp hf://datasets/username/my-dataset/processed/ hf://datasets/username/dest-dataset/processed/zJhf repos cp hf://username/my-model/logs/ hf://username/archive-model/logs/)rA   rC   rk   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.rK   )rp   rB   r   rE   ru   zBranch createdrB   rE   rp   N)r   create_branchrN   r$   r   )rp   rB   r   rI   rE   ru   rj   s          r-   branch_creater     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.rK   )rp   rB   rE   zBranch deletedr   N)r   delete_branchrN   r$   r   )rp   rB   rI   rE   rj   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.rK   )rp   r@   tag_messager   rE   r   ' not found.Nz
Revision 'i  Tag 'z' already exists on ''.zTag createdr@   rE   rp   )rN   r   
create_tagr	   r   
capitalizer
   r   responsestatus_coder$   r   )	rp   r@   r   r   rI   rE   repo_type_strrj   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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.rK   )rp   rE   r   r   Nc                 8    g | ]}|j         |j        |j        d S )rA   target_commitrefr   )rO   ts     r-   rQ   ztag_list.<locals>.<listcomp>Q  s)    aaaRSafqquMMaaar/   )	rN   r   list_repo_refsr	   r   r   tagsr$   rh   )rp   rI   rE   r   rj   refsr   rm   s           r-   tag_listr   D  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?r   rK   )rp   r@   rE   r   r   Nr   z' not found on 'r   zTag deletedr   )rN   r$   textr   r   
delete_tagr	   r   r   r
   r   )rp   r@   r   rI   rE   r   rj   r   s           r-   
tag_deleter   U  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 )Q__doc__enumtypingr   typerhuggingface_hubr   r   huggingface_hub.cli._cli_utilsr   huggingface_hub.errorsr   r   r	   r
   huggingface_hub.hf_apir   
_city_gamer   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    _cpr!   _file_listingr"   _outputr#   r$   	repos_clicallbackContextr.   r   Enumr1   r;   boolOption	PublicOptProtectedOptSpaceHardwareOptSpaceStorageOptintSpaceSleepTimeOpttag_cli
branch_cli	add_typercommandrn   r2   r   Argumentr   r   r   r   rc   r   r   r   r   r   r   r9   r/   r-   <module>r      s            7 7 7 7 7 7 7 7 5 5 5 5 5 5 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
    #ty       3	    4KELS  	 4KELe   $JEL^:m,,    4EL A   $JELj    -A
B
B
B] HIII
 	  G%  ( ( ( 	  JX  . . .       	 	- 	+6T 6Td
^	
 	
 	
	6T dP	
 	
 	
	6T 6T  !6T" ['VWWW	Y#6T* +6T, 
-6T 6T 6T 6Tr     	 	 &^ 	" 	 	 	!%#$(#'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Z	  	       
''!  & -?    !%^ 	!\ \\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/   