
    IThu8                         S r SSKrSSKrSSKrSSKJrJr  SSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  \R6                  " \5      r " S S\5      rg)aa  Contains command to upload a repo or file with the CLI.

Usage:
    # Upload file (implicit)
    huggingface-cli upload my-cool-model ./my-cool-model.safetensors

    # Upload file (explicit)
    huggingface-cli upload my-cool-model ./my-cool-model.safetensors  model.safetensors

    # Upload directory (implicit). If `my-cool-model/` is a directory it will be uploaded, otherwise an exception is raised.
    huggingface-cli upload my-cool-model

    # Upload directory (explicit)
    huggingface-cli upload my-cool-model ./models/my-cool-model .

    # Upload filtered directory (example: tensorboard logs except for the last run)
    huggingface-cli upload my-cool-model ./model/training /logs --include "*.tfevents.*" --exclude "*20230905*"

    # Upload with wildcard
    huggingface-cli upload my-cool-model "./model/training/*.safetensors"

    # Upload private dataset
    huggingface-cli upload Wauplin/my-cool-dataset ./data . --repo-type=dataset --private

    # Upload with token
    huggingface-cli upload Wauplin/my-cool-model --token=hf_****

    # Sync local Space with Hub (upload new files, delete removed files)
    huggingface-cli upload Wauplin/space-example --repo-type=space --exclude="/logs/*" --delete="*" --commit-message="Sync local Space with Hub"

    # Schedule commits every 30 minutes
    huggingface-cli upload Wauplin/my-cool-model --every=30
    N)	Namespace_SubParsersAction)ListOptional)logging)CommitScheduler)BaseHuggingfaceCLICommand)HF_HUB_ENABLE_HF_TRANSFER)RevisionNotFoundError)HfApi)disable_progress_barsenable_progress_bars)is_xet_availablec                   V    \ rS rSr\S\4S j5       rS\SS4S jrSS jr	S\
4S	 jrS
rg)UploadCommandD   parserc                    U R                  SSS9nUR                  S[        SS9  UR                  SSS	S
9  UR                  SSSS
9  UR                  S/ SQSSS9  UR                  S[        SS9  UR                  SSSS9  UR                  SS[        SS9  UR                  SS[        SS9  UR                  SS[        SS9  UR                  S [        S!S9  UR                  S"[        S#S9  UR                  S$SS%S9  UR                  S&[        S'S9  UR                  S([        S)S9  UR                  S*SS+S9  UR	                  [
        S,9  g )-Nuploadz.Upload a file or a folder to a repo on the Hub)helprepo_idz<The ID of the repo to upload to (e.g. `username/repo-name`).)typer   
local_path?zkLocal path to the file or folder to upload. Wildcard patterns are supported. Defaults to current directory.)nargsr   path_in_repoz\Path of the file or folder in the repo. Defaults to the relative path of the file or folder.z--repo-type)modeldatasetspacer   z/Type of the repo to upload to (e.g. `dataset`).)choicesdefaultr   z
--revisionzAn optional Git revision to push to. It can be a branch name or a PR reference. If revision does not exist and `--create-pr` is not set, a branch will be automatically created.z	--private
store_truezfWhether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already exists.)actionr   z	--include*z'Glob patterns to match files to upload.)r   r   r   z	--excludez.Glob patterns to exclude from files to upload.z--deletezDGlob patterns for file to be deleted from the repo while committing.z--commit-messagez9The summary / title / first line of the generated commit.z--commit-descriptionz(The description of the generated commit.z--create-prz0Whether to upload content as a new Pull Request.z--everyzNIf set, a background job is scheduled to create commits every `every` minutes.z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokensz--quietzWIf True, progress bars are disabled and only the path to the uploaded files is printed.)func)
add_parseradd_argumentstrfloatset_defaultsr   )r   upload_parsers     W/var/www/auris/envauris/lib/python3.13/site-packages/huggingface_hub/commands/upload.pyregister_subcommand!UploadCommand.register_subcommandE   s   ))(9i)j""C&d 	# 	
 	""~ 	# 	

 	""o 	# 	

 	""1B	 	# 	
 	""_	 	# 	
 	""	 	# 	
 	"";cJs"t""s3c 	# 	
 	""W	 	# 	
 	""S/j 	# 	
 	""#9Jt"u"",5g 	# 	
 	""a 	# 	

 	""C&q 	# 	
 	""j 	# 	

 	"""6    argsreturnNc                 F  ^ TR                   U l         TR                  U l        TR                  U l        TR                  U l        TR                  U l        TR
                  U l        TR                  U l        TR                  U l        TR                  U l        TR                  U l	        [        TR                  SS9U l        TR                  U l        TR                  b)  TR                  S::  a  [        STR                   S35      eTR                  U l        TR                   R!                  S5      S   nU   U   TR"                  bz  [%        U4S jS	 5       5      (       a`  TR                  b  [        S
5      eTR&                  b  TR&                  S:w  a  [        S5      eSU l        TR"                  U l        SU l        g TR"                  c1  [(        R*                  R-                  U5      (       a  X l        X l        g TR"                  c2  [(        R*                  R/                  U5      (       a  X l        SU l        g TR"                  c  [        SU S35      eTR&                  cn  [(        R*                  R-                  TR"                  5      (       a@  TR"                  U l        [(        R*                  R1                  TR"                  5      U l        g TR&                  c  TR"                  U l        SU l        g TR"                  U l        TR&                  U l        g )Nzhuggingface-cli)tokenlibrary_namer   z'`every` must be a positive value (got 'z')/c              3   @   >#    U  H  oTR                   ;   v   M     g 7f)N)r   ).0cr0   s     r,   	<genexpr>)UploadCommand.__init__.<locals>.<genexpr>   s     .]_DOO/C_s   )r$   r   [zICannot set `--include` when passing a `local_path` containing a wildcard..zLCannot set `path_in_repo` when passing a `local_path` containing a wildcard.'zD' is not a local file or folder. Please set `local_path` explicitly.)r   	repo_typerevisionprivateincludeexcludedeletecommit_messagecommit_description	create_prr   r3   apiquietevery
ValueErrorsplitr   anyr   ospathisfileisdirbasename)selfr0   	repo_names    ` r,   __init__UploadCommand.__init__   sS    LL(,'+}}!\\,0LL,0LL+/;;-1-@-@151H1H#~~djj?PQ::
 ::!djjAoFtzzlRTUVV&*jj
 ++C04	??&3.]_.]+]+]||' !lmm  ,1B1Bc1I !opp!DO??DL #D__$	)B)B'O )__$y)A)A'O #D__$ q+opqq&277>>$//+J+J"ooDO " 0 0 AD&"ooDO #D #ooDO $ 1 1Dr/   c                    U R                   (       ab  [        5         [        R                  " 5          [        R                  " S5        [        U R                  5       5        S S S 5        [        5         g [        R                  " 5         [        U R                  5       5        [        R                  " 5         g ! , (       d  f       N]= f)Nignore)rI   r   warningscatch_warningssimplefilterprint_uploadr   r   set_verbosity_infoset_verbosity_warning)rS   s    r,   runUploadCommand.run   ss    ::!#((*%%h/dlln% + !"&&($,,.!))+ +*s   0B88
Cc                 F   [         R                  R                  U R                  5      (       a  U R                  b/  [        U R                  5      S:  a  [        R                  " S5        U R                  b/  [        U R                  5      S:  a  [        R                  " S5        U R                  b/  [        U R                  5      S:  a  [        R                  " S5        [        5       (       d   [        (       d  [        R                  S5        U R                  Gb  [         R                  R                  U R                  5      (       a  [         R                  R                  U R                  5      nU R                   R#                  U R                  5      (       a#  U R                   S [        U R                  5      *  OU R                   nU R                  /n/ nO~U R                  nU R                   nU R                  =(       d    / nU R                  =(       d    / nU R                  b/  [        U R                  5      S:  a  [        R                  " S5        [%        UU R&                  U R(                  U R*                  UUUU R,                  U R                  U R.                  S9
n[1        SU R                   S	UR&                   S
35          [2        R4                  " S5        M  [         R                  R                  U R                  5      (       dG  [         R                  R;                  U R                  5      (       d  [=        SU R                   S35      eU R.                  R?                  U R&                  U R(                  SU R,                  U R(                  S:X  a  SOS S9R&                  nU R*                  b@  U R@                  (       d/   U R.                  RC                  X`R(                  U R*                  S9  [         R                  R                  U R                  5      (       af  U R.                  RI                  U R                  U R                   UU R(                  U R*                  U RJ                  U RL                  U R@                  S9$ U R.                  RO                  U R                  U R                   UU R(                  U R*                  U RJ                  U RL                  U R@                  U R                  U R                  U R                  S9$ ! [6         a    UR9                  5          gf = f! [D         aV    [        R                  SU R*                   S35        U R.                  RG                  X`R(                  U R*                  SS9   GNf = f)Nr   z5Ignoring `--include` since a single file is uploaded.z5Ignoring `--exclude` since a single file is uploaded.z4Ignoring `--delete` since a single file is uploaded.zConsider using `hf_transfer` for faster uploads. This solution comes with some limitations. See https://huggingface.co/docs/huggingface_hub/hf_transfer for more details.z:Ignoring `--delete` when uploading with scheduled commits.)
folder_pathr   r?   r@   allow_patternsignore_patternsr   rA   rJ   hf_apizScheduling commits every z minutes to r=   Td   zStopped scheduled commits.zNo such file or directory: 'z'.r   gradio)r   r?   exist_okrA   	space_sdk)r   r?   r@   zBranch 'z' not found. Creating it...)r   r?   branchri   )path_or_fileobjr   r   r?   r@   rE   rF   rG   )rc   r   r   r?   r@   rE   rF   rG   rd   re   delete_patterns)(rN   rO   rP   r   rB   lenrY   warnrC   rD   r   r
   loggerinforJ   dirnamer   endswithr   r   r?   r@   rA   rH   r\   timesleepKeyboardInterruptstoprQ   FileNotFoundErrorcreate_reporG   	repo_infor   create_branchupload_filerE   rF   upload_folder)rS   rc   r   rd   re   	schedulerr   s          r,   r]   UploadCommand._upload   s5   77>>$//**||'C,=,AUV||'C,=,AUV{{&3t{{+;a+?TU!!*C*CKK] ::!ww~~doo.. ggoodoo> ((11$//BB %%&=T__)=(=>** 
 #'//!2"$"oo#00!%!3"&,,"4";;*s4;;/?!/CMM"^_''..- /)jjxxI -djj\iFWFWEXXYZ[4JJsO  ww~~doo..rww}}T__7U7U#&B4??BSSU$VWW((&&LLnnLL"&..G";h ' 
 ' 	 ==$T^^w""7nnW[WdWd"e 77>>$//**88'' $!....#22#'#:#:.. ( 	 	 88)) OO!....#22#'#:#:..#|| $ $ *  S % 4 34* ) wht}}o5PQR&&w..Y]YfYfqu&vws%   T  .U   T=<T= AV V )rH   rF   rE   rG   rD   rJ   rC   rB   r   r   rA   rI   r   r?   r@   )r1   N)__name__
__module____qualname____firstlineno__staticmethodr   r-   r   rU   r`   r(   r]   __static_attributes__ r/   r,   r   r   D   sG    C7$5 C7 C7J92Y 924 92v
,h hr/   r   )__doc__rN   rt   rY   argparser   r   typingr   r   huggingface_hubr   !huggingface_hub._commit_schedulerr   huggingface_hub.commandsr	   huggingface_hub.constantsr
   huggingface_hub.errorsr   huggingface_hub.hf_apir   huggingface_hub.utilsr   r   huggingface_hub.utils._runtimer   
get_loggerr   rp   r   r   r/   r,   <module>r      sU    D 
   1 ! # = > ? 8 ( M ; 
		H	%v- vr/   