
    iA              (          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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 m!Z!  ed	
      Z"e"jG                  d      dejH                  ddfd       Z% ed
      Z& ed
      Z'e"jQ                  e&d       e"jQ                  e'd        G d de)ejT                        Z+ee,dz   ejZ                  dd
      f   Z.ee,dz   ejZ                  dd
      f   Z/eedz   ejZ                  dd
      f   Z0eedz   ejZ                  dd
      f   Z1ee2dz   ejZ                  dd 
      f   Z3e"ji                  d!g d"#      ejj                  dddddd$ddddddddde jl                  fd%ed&ed'ee)dz   ejZ                  d(
      f   d)ed*e.d+e/d,ed-ee, ejZ                  d.
      f   d/ee)dz   ejZ                  d0
      f   d1e0d2e1d3e3d4ed5ed6ed7ed8ed9eddf&d:       Z7e"ji                  d;g d<#      dejj                  ddddd$dddddddde jl                  fd=ed>ee)dz   ejp                  d?
      f   d&ed)ed*e.d+e/d,ed-ee, ejZ                  d.
      f   d1e0d2e1d3e3d4ed5ed6ed7ed8ed9eddf$d@       Z9e"ji                  dAdBg#      ejj                  dd$d$e jl                  fd%ed&ed,edCee, ejZ                  dD
      f   dEee, ejZ                  dFdGdH
      f   d9eddfdI       Z:e"ji                  dJdKg#      dejj                  e jl                  fd=ed>ed,ed&ed9eddfdL       Z;e"ji                  dMg dN#      dddddejj                  e jl                  fd%edOee+dz   ejZ                  dP
      f   d)ed*e.d+e/d,ed&ed9eddfdQ       Z<e"ji                  dRg dS#      ejj                  dddd$de jl                  fd%edTee=e)    ejp                  dU
      f   d&edVedWee)dz   ejZ                  dX
      f   dYee)dz   ejZ                  dZ
      f   d[ee, ejZ                  d\
      f   d,ed9eddfd]       Z>e'ji                  d!d^d_g#      ddejj                  d$e jl                  fd%edee) ejp                  d`
      f   dVed,ed&ed-ee, ejZ                  da
      f   d9eddfdb       Z?e'ji                  dAdcg#      dejj                  e jl                  fd%edee) ejp                  dd
      f   d,ed&ed9eddfde       Z@e&ji                  d!dfdgg#      dddejj                  e jl                  fd%edee) ejp                  dh
      f   diee)dz   ejZ                  djdkdl
      f   dVed,ed&ed9eddfdm       ZAe&ji                  dndog#      dejj                  e jl                  fd%ed,ed&ed9eddf
dp       ZBe&ji                  dAdqg#      d$dejj                  e jl                  fd%edee) ejp                  dr
      f   dEee, ejZ                  dFdGds
      f   d,ed&ed9eddfdt       ZCy)uae  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   )
EnvFileOptEnvOptFormatWithAutoOpt
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)OutputFormatWithAutooutzManage repos on the Hub.)helpT)invoke_without_commandctxreturnc                 N    | j                   dk(  rt        j                  d       y y )Nrepoz/`hf repo` is deprecated in favor of `hf repos`.)	info_namer   warning)r    s    j/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/huggingface_hub/cli/repos.py_repos_callbackr'   <   s     
}}E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y)GatedChoicesautomanualfalseN)__name__
__module____qualname__r.   r/   r0    r(   r&   r-   r-   H   s    DFEr(   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:/data)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.hardwarestorage
sleep_timesecretssecrets_fileenvenv_filevolumeformatc                 8   t        |      }|j                  | |j                  |rdn	|rdn|rdnd|||||	|
|t        t	        ||            t        t	        ||            t        |            }t        j                  d|j                  t        |             y)	zCreate a new repo on the Hub.r=   r:   r;   r<   N)r7   r8   
visibilityr=   r>   r?   r9   space_hardwarespace_storagespace_sleep_timespace_secretsspace_variablesspace_volumeszRepo created)r7   url)
r   create_repovaluer   r   r   r   resultr7   str)r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   apirepo_urls                       r&   repo_createrY   v   s    Z 5
!C// '9XT][cg+#/g|0TU1-X2NO#F+  H JJ~x'7'7S]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                 8   t        |      }|j                  | ||j                  |rdn	|rdn|rdnd||||	|
t        t	        ||            t        t	        ||            t        |            }t        j                  d| |j                  t        |             y)	z7Duplicate a repo on the Hub (model, dataset, or Space).rJ   r:   r;   r<   N)r[   r\   r8   rK   r=   r>   rL   rM   rN   rO   rP   rQ   zRepo duplicated)r[   r\   rR   )
r   duplicate_reporT   r   r   r   r   rU   r7   rV   )r[   r\   r8   r:   r;   r<   r=   r>   r@   rA   rB   rC   rD   rE   rF   rG   rH   rW   rX   s                      r&   repo_duplicater_      s    L 5
!C!!// '9XT][cg#/g|0TU1-X2NO#F+ " H JJ '9I9IsS[}]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	                  | |j                  |       t        j
                  d|        y	)
z>Delete a repo from the Hub. This is an irreversible operation.z$You are about to permanently delete  'z'. Proceed?rb   rJ   )r7   r8   ra   zRepo deletedr7   N)r   confirmrT   r   delete_reporU   )r7   r8   r=   ra   rb   rH   rW   s          r&   repo_deleteri      sa    , KK6y6Gr'R]^dgh
5
!COO//  
 JJ~w/r(   movez;hf repos move old-namespace/my-model new-namespace/my-modelc                     t        |      }|j                  | ||j                         t        j                  d| |       y)z8Move a repository from a namespace to another namespace.rJ   )r[   r\   r8   z
Repo moved)r[   r\   N)r   	move_reporT   r   rU   )r[   r\   r=   r8   rH   rW   s         r&   	repo_moverm     s>     5
!CMM//  
 JJ|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        |      }|j                  | |dn|t        j                  u rdn|j                  |rdn	|rdn|rdnd|j                         t        j                  d| 	       y)
z$Update the settings of a repository.rJ   NFr:   r;   r<   )r7   ro   rK   r8   zRepo settings updatedrf   )r   update_repo_settingsr-   r0   rT   r   rU   )	r7   ro   r:   r;   r<   r=   r8   rH   rW   s	            r&   repo_settingsrr      sl    0 5
!C}t5L<N<N3N%TYT_T_ '9XT][cg//	   JJ&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                  || |j                  ||||      }
t        j                  d| |
       y)z$Delete files from a repo on the Hub.rJ   )delete_patternsr7   r8   rt   ru   rv   rw   zFiles deleted)r7   
commit_urlN)r   delete_filesrT   r   rU   )r7   rs   r8   rt   ru   rv   rw   r=   rH   rW   rR   s              r&   repo_delete_filesr|   B  sO    P 5
!C


 //%-  C JJ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                  | |||j                  |       t        j                  d||j                  |        y)z*Create a new branch for a repo on the Hub.rJ   )r7   r+   rt   r8   r>   zBranch createdr+   r8   r7   N)r   create_branchrT   r   rU   )r7   r+   rt   r=   r8   r>   rH   rW   s           r&   branch_creater   w  sN    6 5
!C//   JJ)//SZ[r(   z#hf repos branch delete my-model devz!The name of the branch to delete.c                     t        |      }|j                  | ||j                         t        j                  d||j                  |        y)z'Delete a branch from a repo on the Hub.rJ   )r7   r+   r8   zBranch deletedr~   N)r   delete_branchrT   r   rU   )r7   r+   r=   r8   rH   rW   s         r&   branch_deleter     sH     5
!C//  
 JJ)//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        |      }	 |j                  | ||||       t        j                  d|||        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.rJ   )r7   r)   tag_messagert   r8   rd   ' not found.Nz
Revision 'i  Tag 'z' already exists on ''.zTag createdr)   r8   r7   )rT   r   
create_tagr   r   
capitalizer	   r   responsestatus_coder   rU   )
r7   r)   r   rt   r=   r8   rH   repo_type_strrW   es
             r&   
tag_creater     s    : OOM
5
!C	wCWxcpq JJ}#P # V-2245RyMNTUU  CH:\:;B ::!!S(U3%'<WIRHIqPs/   A
 
	C A33C?BC-CCz	list | lszhf repos tag list my-modelc                 h   |j                   }t        |      }	 |j                  | |      }|j                  D cg c]&  }|j                  |j                  |j                  d( }	}t        j                  |	       y# t        $ r%}t	        |j                          d|  d      |d}~ww xY wc c}w )zList tags for a repo.rJ   )r7   r8   rd   r   N)r*   target_commitref)rT   r   list_repo_refsr   r   r   tagsr*   r   r   r   table)
r7   r=   r8   rH   r   rW   refsr   titemss
             r&   tag_listr     s     OOM
5
!CV!!']!K X\W`W`aRSaffqquuMaEaIIe # V-2245RyMNTUUVas   A> +B/>	B, B''B,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	        |      }	 |j                  | ||       t        j                  d|||        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 z on  zProceed?re   rJ   )r7   r)   r8   rd   r   Nr   z' not found on 'r   zTag deletedr   )rT   r   textrg   r   
delete_tagr   r   r   r	   rU   )	r7   r)   rb   r=   r8   rH   r   rW   r   s	            r&   
tag_deleter     s    , OOMHH+C5]O1WINOKK
$
5
!CHwC=I
 JJ}#P	 # V-2245RyMNTUU  Hse#3G9B?@aGHs$   A= =	C
 B&&C
2CC
)D__doc__enumtypingr   typerhuggingface_hubr   r   huggingface_hub.errorsr   r   r   r	   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _outputr   r   	repos_clicallbackContextr'   tag_cli
branch_cli	add_typerrV   Enumr-   boolOption	PublicOptProtectedOptSpaceHardwareOptSpaceStorageOptintSpaceSleepTimeOptcommandmodelr.   rY   Argumentr_   ri   rm   rr   listr|   r   r   r   r   r   r4   r(   r&   <module>r      s      7 k k    & / 9:	 40G G4 G 1G
 A
B HI
 	  G%  ( 	  JX  .3		  4KELLS	 4KELLe DELL^  4ELL A $JELLj     &^^ 	" 	 	!%#$(#' 4 9 9C4L4L4L d
X	
	4L 4L 4L 4L 4L @	
	4L& !d
 C	
	'4L2 34L4 54L6 "74L8 94L: !;4L< 
=4L> ?4L@ A4LB C4LD 
E4L4Ln    	%^^" 	!%#$(#' 4 9 97-^-^d
r	
	-^ -^ -^ -^ -^ -^ @	
	-^& '-^( )-^* "+-^, --^. !/-^0 
1-^2 3-^4 5-^6 7-^8 
9-^-^` 8'A&BC &^^ 	 	 4 9 9%000 0 P	
		0 
6	
	
0$ %0& 
'0 D0> 6%b$cd %^^ 4 9 9;;; ; 	;
 ; 
; e;"    	"%^^ 4 9 999t7	
	9 9 9 9 9 9 9 
994     &^^  	 	 	 4 9 9;*A*AS	k	
	*A *A *A d
L	
	*A  "d
;	
	!*A, J	
	-*A8 9*A: ;*A< 
=*A*AZ -?   !%^^ 	 4 9 9#\\4	
	\ \ \ \ R	
	\" #\$ 
%\\> H(M'NO %^^ 4 9 9\\4	
	\ \ \ \ 
\ P\, 	+>  , 	 %^^ 4 9 9'"Q"Q	1	
	
"Q d
8	
	"Q  !"Q" #"Q$ %"Q& '"Q( 
)"Q"QJ 	(D'EF %^^ 4 9 9	  	
 
 G" 	%H$IJ  	%^^ 4 9 9%QQ	1	
	
Q 
5	
	
Q  !Q" #Q$ %Q& 
'Q KQr(   