+
    QV-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   "Úh/Volumes/fast/ai/experiments/ui-tars-smoke/.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Ü�7‰7�=‰=˜×$Ò$ÜÐBÓCÐCÜ‡N‚NØ9×?Ñ?ÓAØØõô
 ‡N‚NØ
7Ô8TÐ7UÐV×\Ñ\Ó^ØØõô
 ‡J‚JÐ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   € ä�jŠj˜‹o Õ$€GÜ‡J�J×Ñ�WÔÜ‡J�J×ÑÖ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   € ä
�*Š*”S—Y‘Y×'Ñ'Ó)×/Ñ/Ó1Ó
2€Cà�s—w‘w˜v“¨¯©°Ó(8Ð9Ô9áà
‡w�wˆwÓÐ5Ô5Ü�‰Ð5Ô6Ü�Š�Œà€Jr   c                ó   € V ^8„  d   QhRR/# r1   © )r   s   "r   r   r   Z   s   € ÷ V5ñ V5˜dñ 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%                  W¼R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)zÐInternal 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/  € ô �zŠzœ#Ÿ)™)×,Ñ,Ó.×4Ñ4Ó6Ó7€HØ�L‰L˜Ó! VÔ+°·±¸[Ó0IÈXÔ0UÜ�7˜V R¨Ð4NÐOÐPÔQÜ�Š�Œô ˆb„Mð Ü‹jˆØŠ;ô
 �HŠH�QŒKà�%�jˆØ�v•;ˆØ˜X� vÕ.ˆØ�X•˜xÕ(ˆÜ˜Ÿ™ LÓ1Ó2ˆ
Ü$(¨¯©«Ó$9ˆô
 	à˜Ø�sØ˜aØ  !ð	ô	
ð ˆÜ�(˜D×!Ô! TÜ$-¨nÖ$=Ñ �Ü!ØØ�nØ)÷õ ð Ü#›×)Ñ)¨-Ð)ÓC�AÜ'¨Ô*Ø—L‘Là" A§I¡I§M¡M°&Ó$9Ø(¨!¨a­%ðôô à# ZØ! 3Ø(¨1¨q­5°JÕ*>Ø,¨jð	ô÷ñ ñ %>÷ "ô4 ‹M×ÑØà�sØ˜ðð ó 
ˆô 	˜AÔä�7˜J¨¨sÐ3×4÷C÷ ð ú÷ "×!ú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   