
    ^j6,                        d Z ddlZddl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 ddlmZ dd	lmZmZmZmZmZmZmZ dd
lmZmZ ddlmZ  e	j<                  e      Z g dZ!	 	 	 	 	 	 	 	 	 	 	 	 	 d(dedee"dz   ed      f   dee"dz   ed      f   dedededee#e"   dz   ed      f   dee#e"   dz   ed      f   dee#e"   dz   ed      f   dee"dz   ed      f   dee"dz   ed      f   d ee$ ed!      f   d"ee%dz   ed#      f   d$ed%dfd&Z&de"de"dz  de"dz  de#e"   dz  d%e'e"e"e#e"   dz  f   f
d'Z(y))z7Contains command to upload a repo or file with the CLI.    N)	Annotated)	constantslogging)CommitScheduler)CLIErrorRevisionNotFoundError)parse_hf_uri   )
PrivateOpt	RepoIdArgRepoTypeRepoTypeOptionalOptRevisionOptTokenOpt
get_hf_api)ArgumentOption)out)zhf upload my-cool-model . .z:hf upload Wauplin/my-cool-model ./models/model.safetensorszChf upload Wauplin/my-cool-dataset ./data /train --repo-type=datasetzrhf upload Wauplin/my-cool-model ./models . --commit-message="Epoch 34/50" --commit-description="Val accuracy: 68%"z?hf upload bigcode/the-stack . . --repo-type dataset --create-prrepo_id
local_pathzkLocal path to the file or folder to upload. Wildcard patterns are supported. Defaults to current directory.)helppath_in_repoz\Path of the file or folder in the repo. Defaults to the relative path of the file or folder.	repo_typerevisionprivateincludez'Glob patterns to match files to upload.excludez.Glob patterns to exclude from files to upload.deletezDGlob patterns for file to be deleted from the repo while committing.commit_messagez9The summary / title / first line of the generated commit.commit_descriptionz(The description of the generated commit.	create_prz0Whether to upload content as a new Pull Request.everyzNIf set, a background job is scheduled to create commits every `every` minutes.tokenreturnc                    	
 dk  rt        j                  dd       j                  t        j                        r|t        d  d      t        d  d      t               }|j                  rt        d	      |j                  |j                  |j                  c |j                  rI|t        d
|j                   d| d      |j                  }n|xs t        j                  j                  t        |      t!         |||      \  dt"        f
	 fd} |       }t%        j&                  d|       y)zLUpload a file or a folder to the Hub. Recommended for single-commit uploads.Nr   z --every must be a positive valuer"   )
param_hintz3'--repo-type' cannot be used with an 'hf://' URI ('z').z2'--revision' cannot be used with an 'hf://' URI ('z@Buckets are not supported by `hf upload`. Use `hf sync` instead.z)Cannot combine a path in the hf:// URI ('z&') with the `path_in_repo` argument (')r#   )r   r   r   r   r$   c                     t         j                  j                        r3t              dkD  r%t	        t
              rt        j                  d       #t              dkD  rt        j                  d       
#t        
      dkD  rt        j                  d       t         j                  j                        rGt         j                  j                        } j                        rd t                n}g}g }n-} }}}
#t        
      dkD  rt        j                  d       t        | |||
      }t        j                  d d|j                   d	       	 	 t        j                  d       t         j                  j                        s.t         j                  j%                        st'        d d      j)                  d
dk(  rdnd       j                  }	s	 j+                  |       t         j                  j                        rj5                  |	      S j7                  |	
      S # t         $ r |j#                          Y yw xY w# t,        $ r1 t.        j1                  d d       j3                  |d
       Y w xY w)Nr   z3Ignoring --include since a single file is uploaded.z3Ignoring --exclude since a single file is uploaded.z2Ignoring --delete since a single file is uploaded.z8Ignoring --delete when uploading with scheduled commits.)
folder_pathr   r   r   allow_patternsignore_patternsr   r   r"   hf_apizScheduling commits every z minutes to .Td   zStopped scheduled commits.zNo such file or directory: 'z'.spacegradio)r   r   exist_okr   	space_sdk)r   r   r   zBranch 'z' not found. Creating it...)r   r   branchr0   )path_or_fileobjr   r   r   r   r   r    r!   )r(   r   r   r   r   r   r    r!   r)   r*   delete_patterns)ospathisfilelen
isinstancelistwarningswarndirnameendswithr   r   textr   timesleepKeyboardInterruptstopisdirFileNotFoundErrorcreate_repo	repo_infor   loggerinfocreate_branchupload_fileupload_folder)r(   pir)   r*   	schedulercreatedapir    r   r!   r   r"   r   r   r   repo_type_strresolved_includeresolved_local_pathresolved_path_in_repor   s         e/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/huggingface_hub/cli/upload.py
run_uploadzupload.<locals>.run_upload   s   77>>-.+4D0E0IjYikoNpST"s7|a'7ST!c&kAoRS  ww~~12 ggoo.AB -556IJ **ES1D-E,EF. 
 #6!6"$1*!1")%#f+/MM"\]'''!- /I HH0|IDUDUCVVWXY4JJsO  ww~~12277==I\;]#&BCVBWWY$Z[[//#"/7":h " 
 ' 	 	lgQYZ 77>>-.?? 32'!-#5# # 	 	   +.#)1+#" ! 
 	
Q % 4 34* ) lhxj0KLM!!']S[fj!kls$   1I) J )JJ7KKUploaded)url)clickBadParameter
startswithr   HF_PROTOCOLr   r	   	is_bucketidtyper   r   r   modelvaluer   _resolve_upload_pathsstrr   result)r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   urirV   rd   rP   rQ   rR   rS   rT   s   `   `` ``````    @@@@@rU   uploadrf   5   sz   ~ UaZ  !CPWXX )//0 PQXPYY\]^^OPWyX[\]]7#==]^^+.66388S\\('?@P@P?QQw  yE  xF  FI  J  ++L"4hnn;;
5
!C DYJ\SZD@.0@c
 c
 c
 c
J \FJJzv&    c                    | j                  d      d   }|}9t        fddD              r%|t        d      ||dk7  rt        d      ddgfS $t        j                  j                  |      r|||fS $t        j                  j                  |      r|d|fS t        d| d	      |At        j                  j                        r"t        j                  j                        |fS |d|fS ||fS )
N/c              3   &   K   | ]  }|v  
 y w)N ).0cr   s     rU   	<genexpr>z(_resolve_upload_paths.<locals>.<genexpr>  s     %O!a:o%Os   )*?[z9Cannot set --include when local_path contains a wildcard.r,   z<Cannot set path_in_repo when local_path contains a wildcard.'zB' is not a local file or folder. Please set local_path explicitly.)splitany
ValueErrorr5   r6   r7   rD   basename)r   r   r   r   	repo_namerR   s    `    rU   rb   rb      s     c"2&I#%O%O"OXYY#(;[\\J%%bggnnY7)%555bggmmI6#///1YK'ijkkz :277++J79III3 000|%555rg   )NNNNNNNNNNFNN))__doc__r5   r@   r;   typingr   rY   huggingface_hubr   r   !huggingface_hub._commit_schedulerr   huggingface_hub.errorsr   r   huggingface_hub.utilsr	   
_cli_utilsr   r   r   r   r   r   r   
_frameworkr   r   _outputr   
get_logger__name__rH   UPLOAD_EXAMPLESrc   r:   boolfloatrf   tuplerb   rl   rg   rU   <module>r      s   > 	     . = B .   )  
		H	%  	 	%)  	 	 	 	 	 	 	wG'G'd
~	
	G' d
o	
	G' #G' G'  !G'" S	D:	
	#G'. S	DA	
	/G': S	DW	
	;G'F d
L	
	GG'R "d
;	
	SG'^ C	
	_G'j a	
	kG'v wG'x 
yG'T66!$t6;>:6PTUXPY\`P`6
3T#Y%%&6rg   