
    5pjBq                        S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSK
Jr  SSKJr  SSKJrJrJrJrJr  SSKJr  SS	KJrJr  SS
KJrJrJrJrJr  \(       a  SSKJ r J!r!  \RD                  " \#5      r$Sr%/ SQr&Sr'Sr(Sr)Sr*\+" 5       r,Sr-Sr.Sr/\-4S\0S\0S\1S\24S jjr3S\0S\24S jr4 " S S5      r5 " S S5      r6 " S  S!5      r7 " S" S#5      r8SSSS$SS%.S&S'S(\2S)\2S*\9\   S+\9\   S,\2S-\2S-  S.\2\:-  S-  S/\2S-  S0\:S1\2S-  SS24S3 jjr;g)4ac  Streamed, multi-commit upload of a folder on top of the Xet upload protocol.

How it works:

- The **coordinator** (caller's thread) walks the list of files and asks the Hub, 256 files at a
  time, what each file is (regular git blob, xet file, ignored). Regular files are accumulated
  directly; xet files are registered into a `XetSession` upload-commit, which chunks, deduplicates,
  retries and uploads them in the background while the coordinator keeps going. No Python-side
  sha256 computation: `hf_xet` computes it during chunking (single read pass over each file).
- Whenever enough files have accumulated (adaptive batch size), the batch is handed over to the
  **committer** thread which joins the xet uploads, drops unchanged files, and creates a git
  commit for the batch. While a batch is being committed, the coordinator is already uploading
  the next one.
- Interrupted uploads are resumable by simply re-running the same call: already-committed files
  are dropped (no-op detection against the remote oid) and already-uploaded chunks are
  deduplicated by the xet storage backend, transferring ~0 bytes.
    N)TYPE_CHECKINGAnyCallable)quote   )	constants)CommitOperationAddCommitOperationDelete_fetch_upload_modes_send_commit_warn_on_overwriting_operations)RepositoryNotFoundError)are_progress_bars_disabledlogging)XetTokenTypeabort_xet_sessionget_xet_sessionxet_connection_info_refresh_urlxet_headers_without_auth)
CommitInfoHfApi   )
   2   K   d   }         i  iX       g      D@g     r@i  @r         ?g      >@currenttotalwidthreturnc                 f    US::  a  SU-  $ [        [        X-  S5      U-  5      nSU-  SX#-
  -  -   $ )Nr   u   ░      ?u   █)intmin)r#   r$   r%   filleds       \/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/huggingface_hub/_upload_pipeline.py_barr-   U   sA    zu}W_c*U23F6>EU^444    nc                     S H>  n[        U 5      S:  a'  U S:  a	  U S U 3s  $ U S:  a	  U S U 3s  $ U S U 3s  $ U S-  n M@     U S S3$ )	N)BkBMBGBTBr    
   z.2fr   .1fz.0fPB)abs)r/   units     r,   _format_bytesr;   \   sq    -q6D=2vC''SC''WTF##	T	 . WB<r.   c                      \ rS rSrSrSrSS\S\SS4S jjrSS	 jr	SS
 jr
S\SS4S jrS\SS4S jrS\SS4S jrS\\   SS4S jrS\SS4S jrS\SS4S jrSS jrSS jrSS jrSS jrS\4S jrS\4S jrS\4S jrS\4S jrSrg) _LiveDisplayh   u*  Three-line live progress display on stderr::

    Preparing   ████████████████████  11,100 / 11,100 ✓
    Uploading   ██████████████░░░░░░  580 / 603 files  3.8GB · 19.7MB/s
    Committing  ██████████████████░░  10,800 / 11,100  14 commits

A small renderer thread redraws the three lines in-place every ~0.5 s on a TTY
(worker threads only update counters under a lock). When stderr is not a TTY,
it falls back to a periodic ``logger.info`` summary instead.

Disabling progress bars (e.g. agent output mode) only turns off the TTY renderer:
the non-TTY log summaries are gated by the logger verbosity alone, so consumers
tailing stderr during a long upload still see periodic progress.
   total_filesenabledr&   Nc                    Xl         U=(       a    [        R                  R                  5       U l        U R                  =(       d#    [
        R                  [        R                  5      U l	        [        R                  " 5       U l        SU l        [        R                  " 5       U l        S U l        SU l        SU l        SU l        [)        5       U l        SU l        SU l        SU l        SU l        SU l        S U l        g )NFr           )_totalsysstderrisatty_ttyloggerisEnabledForr   INFO_active	threadingLock_lock_drawnEvent_stop_event_thread	_prepared_ignored
_xet_totalset	_xet_done
_committed_nb_commits
_xet_bytes
_speed_ema_prev_bytes
_prev_time)selfr@   rA   s      r,   __init___LiveDisplay.__init__z   s    !3

 1 1 3	yyEF$7$7$E^^%
$??,04 #&5 (,r.   c                    U R                   (       d  g U R                  (       aM  [        R                  R	                  SU R
                  S S35        [        R                  R                  5         O$[        R                  SU R
                  S S35        [        R                  " U R                  SSS9U l        U R                  R                  5         g )NzFound ,z files to upload
z files to uploadzhf-upload-displayTtargetnamedaemon)rL   rH   rE   rF   writerD   flushrI   inforM   Thread_render_looprS   startr_   s    r,   rm   _LiveDisplay.start   s    ||99JJvdkk!_4FGHJJKK&Q/?@A ''t/@/@GZcghr.   c                    U R                   b4  U R                  R                  5         U R                   R                  5         U R                  (       a&  U R
                     U R                  5         S S S 5        g g ! , (       d  f       g = fN)rS   rR   rW   joinrH   rO   _redrawrn   s    r,   close_LiveDisplay.close   sW    <<#  "LL99  s   A::
Br/   c                 z    U R                      U =R                  U-  sl        S S S 5        g ! , (       d  f       g = frq   )rO   rT   r_   r/   s     r,   notify_prepared_LiveDisplay.notify_prepared   s!    ZZNNaN ZZ   ,
:c                 z    U R                      U =R                  U-  sl        S S S 5        g ! , (       d  f       g = frq   )rO   rU   rw   s     r,   notify_ignored_LiveDisplay.notify_ignored   s!    ZZMMQM ZZrz   c                 z    U R                      U =R                  U-  sl        S S S 5        g ! , (       d  f       g = frq   )rO   rV   rw   s     r,   notify_xet_registered"_LiveDisplay.notify_xet_registered   !    ZZOOq O ZZrz   namesc                     U R                      U R                  R                  U5        S S S 5        g ! , (       d  f       g = frq   )rO   rX   update)r_   r   s     r,   notify_xet_uploaded _LiveDisplay.notify_xet_uploaded   s%    ZZNN!!%( ZZs	   2
A c                 z    U R                      U =R                  U-  sl        S S S 5        g ! , (       d  f       g = frq   )rO   rY   rw   s     r,   notify_skipped_LiveDisplay.notify_skipped   r   rz   n_filesc                     U R                      U =R                  U-  sl        U =R                  S-  sl        S S S 5        g ! , (       d  f       g = f)Nr   )rO   rY   rZ   )r_   r   s     r,   notify_commit_LiveDisplay.notify_commit   s2    ZZOOw&O! ZZs   +A
Ac                 `   ^ ^ T R                   (       d  gSmS[        S[        SS4UU 4S jjnU$ )a3  Progress callback for one ``new_upload_commit``.

The byte counters in ``group_report`` are cumulative *per upload-commit* and several
upload-commits can be in flight at once (one finalizing, one filling), so each commit
gets its own closure tracking its own previous value; increments are summed globally.
Nr   group_reportitem_reportsr&   c                   > TR                      U R                  nT=R                  [        SUT-
  5      -  sl        UmUR	                  5        HV  nUR
                  S:  d  M  UR                  UR
                  :X  d  M1  TR                  R                  UR                  5        MX     S S S 5        g ! , (       d  f       g = fNr   )
rO   total_transfer_bytes_completedr[   maxvaluestotal_bytesbytes_completedrX   add	item_name)r   r   	completeditemprevr_   s       r,   callback/_LiveDisplay.new_xet_callback.<locals>.callback   s    (GG	3q)d*:#;; (//1D''!+0D0DHXHX0X**4>>: 2	 s   AB2$B2 )B22
C )rL   r   )r_   r   r   s   ` @r,   new_xet_callback_LiveDisplay.new_xet_callback   s:     ||	;3 	;c 	;d 	; 	; r.   c                    SnU R                   R                  [        5      (       d  U R                     U R	                  5         U R
                  (       a  U R                  5         OX[        R                  " 5       U-
  [        :  a8  [        R                  U R                  5       5        [        R                  " 5       nS S S 5        U R                   R                  [        5      (       d  M  g g ! , (       d  f       N6= f)NrC   )rR   wait_REFRESH_INTERVALrO   _update_speedrH   rs   time	monotonic_NON_TTY_LOG_INTERVALrI   rj   _summary)r_   last_logs     r,   rl   _LiveDisplay._render_loop   s    ""''(9::""$99LLN^^%04IIKK0#~~/H  ""''(9::s   BC..
C<c                 <   [         R                  " 5       nU R                  bc  XR                  :  aT  U R                  U R                  -
  XR                  -
  -  nU R
                  S:X  a  UOSU-  SU R
                  -  -   U l        Xl        U R                  U l        g )Nr   g333333?gffffff?)r   r   r^   r[   r]   r\   )r_   nowrates      r,   r   _LiveDisplay._update_speed   s{    nn??&3+@OOd&6&663;PQD&*oo&:dd
SSWSbSbMb@bDO??r.   c                    U R                   (       a-  [        R                  R                  SU R                   S35        [
        R                  " 5       R                  nU R                  5       U R                  5       U R                  5       4 HE  n[        U5      US-
  :  a  US US-
   S-   OUn[        R                  R                  SU S35        MG     [        R                  R                  5         SU l         g )	Nz[Ar      z...z[K
T)rP   rE   rF   rh   _N_LINESshutilget_terminal_sizecolumns_line_preparing_line_uploading_line_committinglenri   )r_   r%   line	truncateds       r,   rs   _LiveDisplay._redraw   s    ;;JJuT]]O156((*22))+T-A-A-CTEZEZE\]D58Y5J[uqy)E1PTIJJx	{"56 ^ 	

r.   c                     U R                   U R                  :  a  SOSnS[        U R                   U R                  5       SU R                   S SU R                  S U 3$ )N    ✓ z  Preparing     rc    / )rT   rD   r-   )r_   dones     r,   r   _LiveDisplay._line_preparing   s[    4;;6vBT^^T[[ AB"T^^TUDVVYZ^ZeZefgYhimhnoor.   c           	         U R                   S:X  a8  U R                  U R                  :  a  [        SS5      O[        SS5      nSU S3$ [	        U R
                  5      n/ nU R                  S:  a$  UR                  [        U R                  5      5        U R                  S:  a'  UR                  [        U R                  5       S35        U(       a  SSR                  U5       3OSnU R                  U R                  :  a  X R                   :  a  S	OSnS[        X R                   5       SUS
 SU R                   S
 SU U 3	$ )Nr   r   z  Uploading   z  -z/sr   u    · r   r   rc   r   z files)rV   rT   rD   r-   r   rX   r[   appendr;   r\   rr   )r_   barn_donepartsextrar   s         r,   r   _LiveDisplay._line_uploading   s   ??a $$++ =$q!*41:C#C5,,T^^$??QLLt78??QLLM$//:;2>?-2"V[['()4;;66__;TvZ\V__ =>b
#doo^_M``fglfmnrmsttr.   c                    U R                   U R                  -
  nU R                  S:  a  SU R                   S3OSnU R                  Us=:  a  S:  a  O  OSOSnS[	        U R                  U5       SU R                  S S	US U U 3$ )
Nr   r   z commitsr   r   r   z  Committing  rc   r   )rD   rU   rZ   rY   r-   )r_   	effectivecommits_strr   s       r,   r   _LiveDisplay._line_committing	  s    KK$--/	9=9I9IA9M4++,H5SUI99vrT$//9=>bQR@SSVW`abVcdocpqupvw	
r.   c                     SU R                   S SU R                  S S[        U R                  5      S SU R                  S S[        U R                  5       SU R                  S SU R                   S3$ )	NzUploading... rc   /z files checked, z uploaded (z transferred), z committed in z
 commit(s))	rT   rD   r   rX   rV   r;   r[   rY   rZ   rn   s    r,   r   _LiveDisplay._summary  sy    DNN1-Qt{{1o=M4>>"1%Qtq&9]SWSbSbEcDddsq!0@0@/AM	
r.   )rL   rY   rP   rU   rO   rZ   rT   r]   r^   r\   rR   rS   rD   rH   r[   rX   rV   )Tr&   N)r&   zCallable | None)__name__
__module____qualname____firstlineno____doc__r   r)   boolr`   rm   rt   rx   r|   r   liststrr   r   r   r   rl   r   rs   r   r   r   r   __static_attributes__ r.   r,   r=   r=   h   s     H-C -$ -$ -2	       !s !t !)c )t )! ! !"S "T "
2	0+p pu u
# 

# 
r.   r=   c                   Z    \ rS rSrSrSS jr\S\4S j5       rS\	S\SS4S	 jr
SS
 jrSrg)_CommitPaceri  zOAdaptive number of files per commit, to stay below server-side commit timeouts.r&   Nc                     [         U l        g rq   )INITIAL_COMMIT_SIZE_INDEX_indexrn   s    r,   r`   _CommitPacer.__init__  s	    /r.   c                 (    [         U R                     $ rq   )COMMIT_SIZE_SCALEr   rn   s    r,   re   _CommitPacer.target  s     --r.   durationnb_filesc                     U[         :  a>  X R                  :  a/  [        U R                  S-   [	        [
        5      S-
  5      U l        g U[         :  a  [        U R                  S-
  S5      U l        g g Nr   r   )TARGET_COMMIT_DURATIONre   r*   r   r   r   r   )r_   r   r   s      r,   record_success_CommitPacer.record_success#  sY    ,,[[1HdkkAos3D/E/IJDK..dkkAoq1DK /r.   c                 @    [        U R                  S-
  S5      U l        g r   )r   r   rn   s    r,   record_failure_CommitPacer.record_failure)  s    $++/1-r.   )r   r   )r   r   r   r   r   r`   propertyr)   re   floatr   r   r   r   r.   r,   r   r     sD    Y0 . . .2u 2 2 2.r.   r   c                   "    \ rS rSrSrSS jrSrg)_Batchi-  zSA group of files destined to a single git commit, with their in-flight xet uploads.Nc                 p    / U l         SU l        S U l        / U l        [        R
                  " 5       U l        g r   )opsregular_bytes
xet_commithandlesr   r   
created_atrn   s    r,   r`   _Batch.__init__0  s-    -/"##=?!%!1r.   )r   r   r   r   r   r   )r   r   r   r   r   r`   r   r   r.   r,   r   r   -  s
    ]2r.   r   c                      \ rS rSrSSS\S\S\\   S\\   S\S	\S
-  S\\-  S
-  S\S
-  S\S\S
-  SS
4S jr	SS jr
SS jrS\SS
4S jrS\SS
4S jrSS jrS\SS
4S jrS\\   SS
4S jrS\\   SS
4S jrSS jrSrg
)_UploadPipelinei8  apir   repo_id	repo_typeadd_operationsdelete_operationscommit_messagecommit_descriptionNtokenrevision	create_prparent_commitr&   c       
         
   Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        UR                  US9U l	        U	=(       d    [        R                  U l        Xl        Xl        [        U R                  SS9U l        U R                   U l        S U l        S U l        SU l        S U l        [-        5       U l        [0        R2                  " SS9U l        / U l        [8        R:                  " 5       U l        [?        [A        U5      [C        5       (       + S9U l"        [G        [H        RJ                  UUU R                   URL                  S9nU
(       a  US	-  n[O        5       U l(        UU R                  [S        U R                  5      S
.U l*        S U l+        U HQ  nURX                  S:X  d  M  UR[                  5        nUR]                  5       R_                  5       U l+        S S S 5          g    g ! , (       d  f       N= f)N)r  r   safer   r   )maxsize)r@   rA   )
token_typer   r   r  endpointz?create_pr=1)token_refresh_urltoken_refresh_headerscustom_headersz
.gitignore)0r   r   r   r  r  r  r  r  _build_hf_headersheadersr   DEFAULT_REVISIONr  r  r  r   base_revision_quotedcommit_revision_quotedpr_urlpr_revision
nb_commitslast_commit_infor   pacerqueueQueuebatch_queueerrorsrM   rQ   abort_eventr=   r   r   displayr   r   WRITEr  r   xet_sessionr   xet_commit_kwargsgitignore_contentpath_in_repoas_filereaddecode)r_   r   r   r   r  r  r  r  r  r  r  r  refresh_urlopfs                  r,   r`   _UploadPipeline.__init__9  s    ",!2,"4
,,5,9 >I$>$>"*
 %*$--b$A! '+&?&?#"&'+59!^
 ).A(>+-$??,#N0CQkQmMmn 6#))..\\
 >)K*,!,%)\\6t||D"
 .2 B,.ZZ\Q-.VVX__->D* "	 !!\s   $G44
H	c           	      $   [        / U R                  QU R                  Q5        [        R                  " U R
                  SSS9nUR                  5         U R                  R                  5          U R                  5          U R                  R                  5       (       a  UR                  SS9  O/U R                  R!                  ["        5        UR                  5         U R                  R%                  5         U R                  R                  5       (       a=  U R&                  b0  [(        R+                  SU R,                   SU R&                   S35        U R.                  (       a  U R.                  S	   eU R1                  5       $ ! [         a&    U R                  R                  5         [        5         e f = f! U R                  R                  5       (       a  UR                  SS9  O/U R                  R!                  ["        5        UR                  5         U R                  R%                  5         U R                  R                  5       (       a?  U R&                  b1  [(        R+                  SU R,                   SU R&                   S35        f f f = f)
Nzhf-upload-committerTrd   r6   timeoutzUpload to pull request zF did not complete. To resume into the same PR, re-run with `revision="z^"` (without `create_pr=True`). Re-running with `create_pr=True` would open a new pull request.r   )r   r  r  rM   rk   _committer_looprm   r!  _coordinator_loopBaseExceptionr   rW   r   is_setrr   r  put	_SENTINELrt   r  rI   warningr  r  _final_commit_info)r_   	committers     r,   run_UploadPipeline.run  s   '(W$*@*@(W4CVCV(WX$$D,@,@G\eij		""$ &&(( r*  $$Y/ LL &&((T-=-=-I-dkk] ;88<8H8H7I JLL
 ;;++a. &&((-  	  "	
 &&(( r*  $$Y/ LL &&((T-=-=-I-dkk] ;88<8H8H7I JLL .J(s   /F 0F44F7 7CJc                    SS K n[        5       n[        S[        U R                  5      [
        5       GHv  nU R                  R                  5       (       a  U R                  U5          g U R                  X3[
        -    n [        UU R                  U R                  U R                  U R                  U R                  R                  U R                   U R"                  S9  U R,                  R/                  [        U5      5        U GH  nUR0                  (       a@  [2        R5                  SUR6                   S35        U R,                  R9                  S5        MU  UR:                  S:X  a+  U=R<                  UR>                  R@                  -  sl        GOOURB                  cE  U RD                  RF                  " SSU R,                  RI                  5       0U RJ                  D6Ul!        UR>                  RL                  (       a$  UR>                  RN                  RQ                  5       OURR                  n[U        URV                  [X        5      (       a/  URB                  R[                  URV                  XR6                  S	9n	O-URB                  R]                  [_        URV                  5      US
9n	UR`                  Rc                  Xy45        U R,                  Re                  S5        URf                  Rc                  U5        [        URf                  5      U Rh                  Rj                  :  d]  UR<                  [l        :  dI  [n        Rp                  " 5       URr                  -
  [t        :  d  GMh  [        URf                  5      S:  d  GM  U Rw                  U5        [        5       nGM     GMy     U Rw                  U5        g ! [$         a  nSSKJn  UR+                  U5        e S nAff = f)Nr   )	additionsr   r   r  r  r  r  r%  r   )$_CREATE_COMMIT_NO_REPO_ERROR_MESSAGEzSkipping upload for 'z' (ignored by gitignore rules).regularprogress_callback)sha256rf   )rA  r   )<hf_xetr   ranger   r  PREUPLOAD_BATCH_SIZEr   r4  _abort_batchr   r   r   r  r  r   r  r  r%  r   hf_apir>  append_to_messager!  rx   _should_ignorerI   debugr&  r|   _upload_moder   upload_infosizer   r#  new_upload_commitr   r$  	is_hashedrA  hexCOMPUTE_SHA256
isinstancepath_or_fileobjbytesstart_upload_bytesstart_upload_filer   r   r   r   r   r  re   REGULAR_CONTENT_BYTES_BUDGETr   r   r   MAX_COMMIT_INTERVAL_enqueue)
r_   rB  batchrm   chunker>  r+  sha_arghandles
             r,   r2  !_UploadPipeline._coordinator_loop  s   1c$"5"568LME&&((!!%(''8L0LME##"nn LL LL!66!XX.."nn&*&<&<	 LL((U4$$LL#88IIh!ijLL//2??i/''2>>+>+>>'''/+/+;+;+M+M ,.2ll.K.K.M,QUQgQg,(
 >@^^=U=Ubnn33779[a[p[pG!""4"4e<<!&!1!1!D!D..w__ "E " "'!1!1!C!CCHZHZD[dk!C!lMM(("6LL66q9		  $ 		Ndjj&7&77**.JJ(5+;+;;>QQVYZ_ZcZcVdghVhMM%("HE? - Nl 	eM + H##$HI	s   ?A O  
O'
O""O'rY  c                 X   [        UR                  5      S:X  a*  U R                  S:X  a  [        U R                  5      S:  d  g U R                  R                  5       (       d   U R                  R                  USS9  g U R                  U5        g ! [        R                   a     Md  f = f)Nr   r(   r/  )r   r   r  r  r   r4  r  r5  r  FullrE  r_   rY  s     r,   rX  _UploadPipeline._enqueue  s    uyy>Q1(<TE[E[A\_`A`""))++  $$UC$8 	%  :: s   $B B)(B)c                 v    UR                   b   UR                   R                  5         g g ! [         a     g f = frq   )r   abort	Exceptionra  s     r,   rE  _UploadPipeline._abort_batch  s>    '  &&( (  s   + 
88c                 
     U R                   R                  SS9nU[        L a  g  U R                  R                  5       (       d  U R                  U5        OU R                  U5         Mj  ! [        R                   a%    U R                  R                  5       (       a   g  M  f = f! [         aP  nU R                  U5        U R                  R                  U5        U R                  R                  5          S nANS nAff = f)Nr"   r/  )r  getr  Emptyr   r4  r6  _process_batchrE  r3  r  r   rW   )r_   rY  r[  s      r,   r1  _UploadPipeline._committer_loop  s    ((,,S,9
 	!'''..00''.%%e,  ;; ##**,, ! '!!%(""1%  $$&&'s/   A, 0B( B( ,3B%$B%(
D2AC==Dc           
         UR                   Gb  UR                   R                  5         UR                   Hm  u  p#UR                  R                  (       dF  [
        R                  UR                  5       R                  R                  5      UR                  l	        SUl
        Mo     U R                  R                  UR                   VVs/ s HE  u  p$[        UR                  [
        5      (       d  [        UR                  5      OUR                   PMG     snn5        / nUR"                   H{  nUR$                  bZ  UR$                  UR&                  :X  a@  [(        R+                  SUR                    S35        U R                  R-                  S5        Mj  UR/                  U5        M}     [1        U5      S:  d)  U R2                  S:X  a,  [1        U R4                  5      S:  a  U R7                  U5        g g g s  snnf )NTzSkipping commit for 'z' (file unchanged).r   r   )r   wait_to_finishr   rK  rN  rS  fromhexresultxet_inforA  _is_uploadedr!  r   rQ  rR  r   r&  r   _remote_oid
_local_oidrI   rI  r   r   r   r  r  _commit_with_split)r_   rY  r+  r]  _ops_to_commits         r,   rj  _UploadPipeline._process_batch  s    '++-#mm
~~//,1MM&--/:R:R:Y:Y,ZBNN)"& ,
 LL,, "'!. 4>b>P>PRW3X3XC**+^`^m^mm!. ))B~~)bnn.M4R__4EEXYZ++A.  $  }!doo&:s4CYCY?Z]^?^##M2 @_&:#s   
AG7
r   c                     U R                  U5        g ! [         a  nU R                  R                  5         [	        U5      [
        S   ::  a  e [        R                  S[	        U5       SU< S35        U R                  R                  n[        S[	        U5      U5       H  nU R                  XXC-    5        M      S nAg S nAff = f)Nr   z
Commit of z files failed (z). Retrying in smaller chunks.)
_do_commitre  r  r   r   r   rI   r7  re   rC  rt  )r_   r   r[  re   rm   s        r,   rt  "_UploadPipeline._commit_with_split'  s    		EOOC  	EJJ%%'3x,Q//NNZCzEcdeZZ&&Fq#c(F3''EN(CD 4	Es    
CBCCc                    U R                   (       a  U R                  c  U R                  R                  U R                  U R
                  U R                  U R                  U R                  S9nUR                  c  [        S5      eUR                  U l        UR                  U l        [        UR                  SS9U l        [        U5      nU R                   S:X  a  [        U R"                  5      U-   nU R                   S:X  a  U R
                  OU R
                   SU R                   S-    S3n[$        R&                  " 5       n[)        U0 UU R                  =(       d    SU R                  U R                  U R*                  U R                  U R                  R,                  U R                   S:X  a  U R.                  OS S	S
9U l        [$        R&                  " 5       U-
  nU R2                  R5                  U[7        U5      5        U =R                   S-  sl        U H
  nS	Ul        M     U R:                  R=                  [7        U5      5        [>        RA                  S[7        U5       SUS SU R0                  RB                   35        g )N)r   titler  descriptionr   zCServer did not return a git reference for the created pull request.r   r
  r   z (part r   )T)
operationsfiles_to_copyr  r  r   r   r  r  r  r  retry_on_errorz
Committed z file(s) in r7   zs: )"r  r  r   create_pull_requestr   r  r  r  r   git_reference
ValueErrorurlr  r   r  r   r  r  r   r   r   r  r  r  r  r  r   r   _is_committedr!  r   rI   rI  
commit_url)r_   r   prr  r  t0r   r+  s           r,   ry  _UploadPipeline._do_commit3  s   >>d..6 --))jj 33.. . B ' !fgg&&DK!//D*/0@0@r*JD' $S	
??ad445
BJ $(??a#7D@S@S?TT[\`\k\kno\o[ppq=r 	 ^^ !-!)#66<"nnLLLL00XX&&0410D$,,$!
 >>#b(

!!(CH51B#B ""3s8,z#c(<~SI^I^IiIiHjklr.   c           	         SSK Jn  U R                  Gc   [        R	                  S5        U R
                  R                  U R                  U R                  U R                  U R                  S9nU R
                  R                  nU R                  [        R                  :w  a  U SU R                   S3nU" U SU R                   SUR                   3U R                  U R                   =(       d    SUR                  U R
                  R                  S	9$ U R"                  S:  a#  [        R%                  S
U R"                   S35        U R&                  by  U" U R                  R(                  U R                  R                  U R                  R                   U R                  R*                  U R&                  U R
                  R                  S9$ U R                  $ )Nr   )r   zPNo files have been modified since last commit. Skipping to prevent empty commit.)r   r   r  r  r   sz/commit/r   )r  r  r  oid	_endpointzUpload completed in z	 commits.)r  r  r  r  r  r  )rF  r   r  rI   r7  r   	repo_infor   r   r  r  r  r   REPO_TYPE_MODELshar  r  r  rj   r  r  r  )r_   r   rj   
url_prefixs       r,   r8  "_UploadPipeline._final_commit_infoj  s   &  ( NNmn88%%^b^h^h & D **J~~!:!:: *|1T^^,<A>
(\4<<.
K#22#'#:#:#@bHH((++  ??QKK.t.?yIJ;;"00;;#44CC#'#8#8#K#K))--{{((++  $$$r.   )r   r  r   r  r  r  r  r  r  r  r!  r  r%  r  r  r  r  r  r  r  r   r   r  r  r$  r#  )r&   r   r   )r   r   r   r   r   r   r	   r
   r   r`   r:  r2  r   rX  rE  r1  rj  rt  ry  r8  r   r   r.   r,   r   r   8  s4   GG 	G
 G /0G   56G G  $JG TzD G *G G TzG 
GR)B:x
!f 
! 
!& T '(3F 3t 3>
Ed+=&> 
E4 
E3md#56 3m4 3mn %r.   r   F)r  r  r  r  r  r   r   r   r   r  r  r  r  r  r  r  r  r   c       
         D    [        U UUUUUUUUU	U
S9R                  5       $ )zUpload a prepared list of operations through the streamed multi-commit pipeline.

Requires `hf_xet` to be installed. See module docstring for the architecture.
)
r   r   r  r  r  r  r  r  r  r  )r   r:  )r   r   r   r  r  r  r  r  r  r  r  s              r,   pipelined_uploadr    s;    & %+%-# 
cer.   )<r   r  r   rE   rM   r   typingr   r   r   urllib.parser   r   r   _commit_apir	   r
   r   r   r   r  r   utilsr   r   
utils._xetr   r   r   r   r   rF  r   r   
get_loggerr   rI   rD  r   r   r   rW  rV  objectr6  
_BAR_WIDTHr   r   r   r)   r   r-   r;   r=   r   r   r   r   r   r  r   r.   r,   <module>r     s  $   
   / /    , 6  )			H	%   E      1 H	 
   5? 5% 5 5c 53 5	U 	s 	n
 n
b. .(2 2R% R%z
 &*# $	  	
 +, 12  d
 : Dj  : r.   