+
    &j#                         R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIH	t	 ^ RI
Ht ^RIHtHtHt ^RIHt ^RIHt ]P(                  ! ]4      tR R	 ltR
 R ltR R ltR R ltR# )a  
Implementation of a custom transfer agent for the transfer type "multipart" for
git-lfs.

Inspired by:
github.com/cbartz/git-lfs-swift-transfer-agent/blob/master/git_lfs_swift_transfer.py

Spec is: github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md


To launch debugger while developing:

``` [lfs "customtransfer.multipart"]
path = /path/to/huggingface_hub/.venv/bin/python args = -m debugpy --listen 5678
--wait-for-client
/path/to/huggingface_hub/src/huggingface_hub/commands/huggingface_cli.py
lfs-multipart-upload ```N)	Annotated)CLIError)LFS_MULTIPART_UPLOAD_COMMAND)get_sessionhf_raise_for_statuslogging)SliceFileObj)outc                l    V ^8  d   QhR\         \        \        P                  ! RR7      3,          RR/# )   pathz/Local path to repository you want to configure.)helpreturnN)r   strtyperArgument)formats   "o/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/huggingface_hub/cli/lfs.py__annotate__r   &   s>     D D
B	
	D 
D    c                ~   \         P                  P                  V 4      p\         P                  P                  V4      '       g   \	        R4      h\
        P                  ! RP                  4       RVR7       \
        P                  ! R\         2P                  4       RVR7       \        P                  ! RVR7       R# )	z
Configure your repository to enable upload of files > 5GB.

This command sets up git-lfs to use the custom multipart transfer agent
which enables efficient uploading of large files in chunks.
z)This does not look like a valid git repo.z/git config lfs.customtransfer.multipart.path hfT)checkcwdz-git config lfs.customtransfer.multipart.args z Local repo set up for largefiles)r   N)osr   abspathisdirr   
subprocessrunsplitr   r	   result)r   
local_paths   & r   lfs_enable_largefilesr!   &   s     &J77==$$BCCNN9??A
 NN
78T7UV\\^
 JJ1
Cr   c                $    V ^8  d   QhR\         /# )r   msgdict)r   s   "r   r   r   D   s      4 r   c                    \         P                  ! V 4      R,           p\        P                  P	                  V4       \        P                  P                  4        R# )z-Write out the message in Line delimited JSON.
N)jsondumpssysstdoutwriteflush)r#   msg_strs   & r   	write_msgr/   D   s6    jjo$GJJWJJr   c                2    V ^8  d   QhR\         R,          /# r   r   Nr$   )r   s   "r   r   r   K   s      $+ r   c                 Z   \         P                  ! \        P                  P	                  4       P                  4       4      p RV P                  R4      V P                  R4      39   d   R# V P                  R4      R9  d,   \        P                  R4       \        P                  ! ^4       V # )z$Read Line delimited JSON from stdin.	terminatetypeeventNzReceived unexpected message)downloadupload)
r(   loadsr*   stdinreadlinestripgetloggercriticalexit)r#   s    r   read_msgr@   K   sv    
**SYY'')//1
2Cswwv(899
www5556Jr   c                    V ^8  d   QhRR/# r1    )r   s   "r   r   r   Z   s     V5 V5d V5r   c                    \         P                  ! \        P                  P	                  4       P                  4       4      p V P                  R4      R8X  d   V P                  R4      R8X  g(   \        RR^ RR//4       \        P                  ! ^4       \        / 4        \        4       pVf   \        P                  ! ^ 4       VR
,          pVR,          pVR,          R,          pVR,          R,          p\        VP                  R4      4      p\        VP                  4       4      p\        RRR
VR^R^ /4       . p\        VR4      ;_uu_ 4       p	\        V4       F  w  r\!        V	W,          VR7      ;_uu_ 4       p\#        4       P%                  WR7      p\'        V4       VP)                  RVP*                  P                  R4      RV
^,           /4       \        RRR
VRV
^,           V,          RV/4       R	R	R	4       K  	  R	R	R	4       \#        4       P-                  VR
VRV/R7      p\'        V4       \        RRR
V/4       EK    + '       g   i     K  ; i  + '       g   i     L`; i)zInternal git-lfs custom transfer agent for multipart uploads.

This function implements the custom transfer protocol for git-lfs multipart uploads.
Handles chunked uploads of large files to Hugging Face Hub.
r5   init	operationr7   errorcodemessagezWrong lfs init operationNoidr   actionhrefheader
chunk_sizeprogress
bytesSoFarbytesSinceLastrb)	seek_from
read_limit)dataetag
partNumberparts)r(   complete)r(   r8   r*   r9   r:   r;   r<   r/   r?   r@   intpoplistvaluesopen	enumerater   r   putr   appendheaderspost)init_msgr#   rI   filepathcompletion_urlrL   rM   presigned_urlsrW   fileipresigned_urlrT   rs                 r   lfs_multipart_uploadrk   Z   s/    zz#)),,.4467HLL!V+[0IX0U7VR4NOPQ bM j;
 HHQK%jv;Xv.Xx(L12
$($9
 	sa !		
 (D!!T$-n$= !n)  #))-)CA'*LL"AIIMM&$9(!a% #Z!3(1q5J*>,j	  %> "4 Ms  
 	A7Js34C   "!s%   -I?A<I;II	II/	)__doc__r(   r   r   r*   typingr   r   huggingface_hub.errorsr   huggingface_hub.lfsr   utilsr   r   r   
utils._lfsr   _outputr	   
get_logger__name__r=   r!   r/   r@   rk   rB   r   r   <module>ru      sX   $  	  
   + < = = %  
		H	%D<V5r   