+
    Pj0                         R t ^ RIt^ RIt^ RIt^ RIt^ RIH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 ^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)Argument)outc                V    V ^8  d   QhR\         \        \        RR7      3,          RR/# )   pathz/Local path to repository you want to configure.)helpreturnN)r   strr	   )formats   "p/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.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   C   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.   C   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   J   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?   J   sv    
**SYY'')//1
2Cswwv(899
www5556Jr   c                    V ^8  d   QhRR/# r0    )r   s   "r   r   r   Y   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.
r4   init	operationr6   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'   r7   r)   r8   r9   r:   r;   r.   r>   r?   intpoplistvaluesopen	enumerater   r   putr   appendheaderspost)init_msgr"   rH   filepathcompletion_urlrK   rL   presigned_urlsrV   fileipresigned_urlrS   rs                 r   lfs_multipart_uploadrj   Y   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   huggingface_hub.errorsr   huggingface_hub.lfsr   utilsr   r   r   
utils._lfsr   
_frameworkr	   _outputr
   
get_logger__name__r<   r    r.   r?   rj   rA   r   r   <module>ru      sX   $  	  
  + < = = %    
		H	%D<V5r   