+
    U\i|B                     >   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 ^ RIHtHtHtHtHtHtHtHt ^ RIHt ^ RIHt ^R	IHtHtHtHtHtH t H!t!H"t" ^R
I#H$t$ ^RI%H&t&H't' ^RI(H)t) ]'       d   ^RI*H+t+ ] PX                  ! ]-4      t.]P^                  ! R4      t0Rt1RRRR/t2] ! R R4      4       t3]"R/R R ll4       t4 ! R R]4      t5 ! R R]4      t6R0R R llt7R R lt8R R  lt9R! R" lt:R# R$ lt;R% R& lt<R' R( lt=R) R* lt>R+ R, lt?R- R. lt@R# )1z.Git LFS related type definitions and utilitiesN)	dataclass)ceil)getsize)Path)TYPE_CHECKINGBinaryIODictIterableListOptionalTuple	TypedDict)unquote)	constants)build_hf_headersfix_hf_endpoint_in_urlget_sessionhf_raise_for_statushttp_backoffloggingtqdmvalidate_hf_hub_args)SliceFileObj)sha256sha_fileobj)is_tqdm_disabled)CommitOperationAddz^[0-9a-f]{40}$zlfs-multipart-uploadAcceptzapplication/vnd.git-lfs+jsonzContent-Typec                      a  ] tR t^<t o Rt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tV 3R lt	R	t
V tR
# )
UploadInfoa<  
Dataclass holding required information to determine whether a blob
should be uploaded to the hub using the LFS protocol or the regular protocol

Args:
    sha256 (`bytes`):
        SHA256 hash of the blob
    size (`int`):
        Size in bytes of the blob
    sample (`bytes`):
        First 512 bytes of the blob
c                    < V ^8  d   QhRS[ /# )   pathstr)format__classdict__s   "k/Users/agent/.cache/uv/archive-v0/6ZL4-8mCcRNgGE9wi6M6J/lib/python3.14/site-packages/huggingface_hub/lfs.py__annotate__UploadInfo.__annotate__P   s     9 9S 9    c                    \        V4      p\        P                  ! VR 4      ;_uu_ 4       pVP                  R4      R,          p\	        V4      pRRR4       V ! VXXR7      #   + '       g   i     L; i)rb   Ni   NNsizer   sample)r   ioopenpeekr   )clsr"   r0   filer1   shas   &&    r'   	from_pathUploadInfo.from_pathO   sY    t}WWT4  DYYs^D)Fd#C ! S88 ! s   $A""A2	c                    < V ^8  d   QhRS[ /# )r!   data)bytes)r%   r&   s   "r'   r(   r)   X   s     B Be Br*   c                j    \        V4      P                  4       pV ! \        V4      VR ,          VR7      # )r.   )r0   r1   r   )r   digestlen)r5   r;   r7   s   && r'   
from_bytesUploadInfo.from_bytesW   s+    Tl!!#D	$t*SAAr*   c                    < V ^8  d   QhRS[ /# )r!   fileobj)r   )r%   r&   s   "r'   r(   r)   ]   s     9 98 9r*   c                    VP                  R 4      pVP                  ^ \        P                  4       \	        V4      pVP                  4       pVP                  ^ \        P                  4       V ! WCVR7      # )r-   r/   )readseekr2   SEEK_SETr   tell)r5   rC   r1   r7   r0   s   &&   r'   from_fileobjUploadInfo.from_fileobj\   sV    c"Q$'"||~Q$88r*   c                >   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   # )r!   r   r0   r1   )r<   int)r%   r&   s   "r'   r(   r)   <   s)      M   I! " M# r*    N)__name__
__module____qualname____firstlineno____doc__classmethodr8   r@   rI   __annotate_func____static_attributes____classdictcell__r&   s   @r'   r   r   <   sP     " 9 9 B B 9 9C  r*   r   c                   V ^8  d   QhR\         \        ,          R\        \        ,          R\        R\        R\        \        ,          R\        \        ,          R\        \        \        \        3,          ,          R\        \
        \        ,          ,          R	\        \
        \        ,          \
        \        ,          \        \        ,          3,          /	# )
r!   upload_infostoken	repo_typerepo_idrevisionendpointheaders	transfersreturn)r	   r   r   r$   r   r
   r   dict)r%   s   "r'   r(   r(   g   s     S S:&SC=S S 	S
 smS smS d38n%S S	"S 4:tDz8C=01Sr*   c                n   Ve   TM\         P                  pRpV\         P                  9   d   \         P                  V,          pV RV V R2p	RRRVe   TMRR	.R
V  U
u. uF+  p
RV
P                  P	                  4       RV
P
                  /NK-  	  up
RR/pVe   R\        V4      /VR&   / \        C\        VR7      CT;'       g    / Cp\        4       P                  WVR7      p\        V4       VP                  4       pVP                  R
R4      p\        V\        4      '       g   \!        R4      hVP                  R4      p\        V\"        4      '       d   TMRpV Uu. uF  pRV9  g   K  \%        V4      NK  	  upV Uu. uF  pRV9   g   K  \'        V4      NK  	  upV3# u up
i u upi u upi )a]  
Requests the LFS batch endpoint to retrieve upload instructions

Learn more: https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md

Args:
    upload_infos (`Iterable` of `UploadInfo`):
        `UploadInfo` for the files that are being uploaded, typically obtained
        from `CommitOperationAdd.upload_info`
    repo_type (`str`):
        Type of the repo to upload to: `"model"`, `"dataset"` or `"space"`.
    repo_id (`str`):
        A namespace (user or an organization) and a repo name separated
        by a `/`.
    revision (`str`, *optional*):
        The git revision to upload to.
    headers (`dict`, *optional*):
        Additional headers to include in the request
    transfers (`list`, *optional*):
        List of transfer methods to use. Defaults to ["basic", "multipart"].

Returns:
    `LfsBatchInfo`: 3-tuple:
        - First element is the list of upload instructions from the server
        - Second element is a list of errors, if any
        - Third element is the chosen transfer adapter if provided by the server (e.g. "basic", "multipart", "xet")

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If an argument is invalid or the server response is malformed.
    [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
        If the server returned an error.
N /z.git/info/lfs/objects/batch	operationuploadr`   basic	multipartobjectsoidr0   	hash_algor   nameref)rZ   r_   jsonzMalformed response from servertransfererror)r   ENDPOINTREPO_TYPES_URL_PREFIXESr   hexr0   r   LFS_HEADERSr   r   postr   rp   get
isinstancelist
ValueErrorr$   _validate_batch_actions_validate_batch_error)rY   rZ   r[   r\   r]   r^   r_   r`   
url_prefix	batch_urlrg   payloadresp
batch_inforj   chosen_transferobjs   &&&&&&&&         r'   post_lfs_batch_infor   f   s   X $/xY5G5GHJI55566yA
*Aj\'2MNIX)"7Yg{=S
 '

 ' v}}((* '
 	XG  '("34


' ==bG
 =iwGDJnnY-Ggt$$9:: nnZ0O)3OS)I)IotO 29O#G3<N	%	 	%O/6Iw'S.	#	s	#wI 9
: 	PIs    1F(#	F-1F-	F2F2c                   ,   a  ] tR t^t o V 3R ltRtV tR# )PayloadPartTc                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r!   
partNumberetag)rL   r$   )r%   r&   s   "r'   r(   PayloadPartT.__annotate__   s     O 
I r*   rM   N)rN   rO   rP   rQ   rT   rU   rV   rW   s   @r'   r   r      s      r*   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )CompletionPayloadTz?Payload that will be sent to the Hub when uploading multi-part.c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # )r!   rk   parts)r$   r
   r   )r%   r&   s   "r'   r(   CompletionPayloadT.__annotate__   s#      
H  	 r*   rM   N)rN   rO   rP   rQ   rR   rT   rU   rV   rW   s   @r'   r   r      s     I  r*   r   c                    V ^8  d   QhRRR\         R\        \        ,          R\        \         \        \        3,          ,          R\        \        ,          RR/# )	r!   rf   r   lfs_batch_actionrZ   r_   r^   ra   N)r   r   r$   )r%   s   "r'   r(   r(      si     CA CA#CACA C=CA d38n%	CA
 smCA 
CAr*   c                |   \        V4       VP                  R4      pVf&   \        P                  RV P                   R24       R# VR,          R,          p\        V4       VR,          P                  R4      pVe   \        V4       VP                  R/ 4      pVP                  R4      p	\        VR	,          VR
7      p
V	e    \        V	4      p	\        YYR7       M\        W
R7       Ve   \        V4       \        VR	,          V4      p\        4       P                  V\        W#R7      RV P                  P                   P#                  4       RV P                  P$                  /R7      p\'        V4       \        P                  V P                   R24       R#   \        \        3 d    \        RT	 R24      hi ; i)a7  
Handles uploading a given object to the Hub with the LFS protocol.

Can be a No-op if the content of the file is already present on the hub large file storage.

Args:
    operation (`CommitOperationAdd`):
        The add operation triggering this upload.
    lfs_batch_action (`dict`):
        Upload instructions from the LFS batch endpoint for this object. See [`~utils.lfs.post_lfs_batch_info`] for
        more details.
    headers (`dict`, *optional*):
        Headers to include in the request, including authentication and user agent headers.

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If `lfs_batch_action` is improperly formatted
    [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
        If the upload resulted in an error
actionsNzContent of file z. is already present upstream - skipping uploadrg   verifyheader
chunk_sizehref)r^   zTMalformed response from LFS batch endpoint: `chunk_size` should be an integer. Got 'z'.)rf   r   r   
upload_url)rf   r   )rZ   r_   rk   r0   ro   z: Upload successful)r|   rx   loggerdebugpath_in_repo_validate_lfs_actionr   rL   r{   	TypeError_upload_multi_part_upload_single_partr   rw   r   upload_infor   ru   r0   r   )rf   r   rZ   r_   r^   r   upload_actionverify_actionr   r   r   
verify_urlverify_resps   &&&&&        r'   
lfs_uploadr      s   8 ,-""9-G'	(>(>'??mno %Y/9M'$Y/33H=M ]+ x,FL)J'f(=QJ	ZJ
 	Y*liG  ]++M&,A8L
!m(($5B..5599;VYEZEZE_E_` ) 

 	K(
LLI**++>?@% I& 	fgqfrrtu 	s   F !F;c                $    V ^8  d   QhR\         /# )r!   
lfs_actionrb   )r%   s   "r'   r(   r(     s      T r*   c                    \        V P                  R4      \        4      '       d9   V P                  R4      e1   \        V P                  R4      \        4      '       g   \	        R4      hV # ).validates response from the LFS batch endpointr   r   z"lfs_action is improperly formatted)ry   rx   r$   rb   r{   )r   s   &r'   r   r     sQ     	:>>&)3//^^H%-JNN8<TVZ1[1[=>>r*   c                $    V ^8  d   QhR\         /# )r!   lfs_batch_actionsr   )r%   s   "r'   r(   r(     s      t r*   c                p   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R/ 4      P                  R4      pV P                  R/ 4      P                  R4      pVe   \        V4       Ve   \        V4       V # )r   rk   r0   z)lfs_batch_actions is improperly formattedr   rg   r   )ry   rx   r$   rL   r{   r   )r   r   r   s   &  r'   r|   r|     s    (,,U3S99jIZI^I^_eIfhk>l>lDEE%)))R8<<XFM%)))R8<<XFM ]+ ]+r*   c                $    V ^8  d   QhR\         /# )r!   lfs_batch_errorr   )r%   s   "r'   r(   r(   '  s      4 r*   c                   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R4      p\        V\
        4      '       dK   \        VP                  R4      \        4      '       d&   \        VP                  R4      \        4      '       g   \	        R4      hV # )r   rk   r0   z'lfs_batch_error is improperly formattedrr   messagecode)ry   rx   r$   rL   r{   rb   )r   
error_infos   & r'   r}   r}   '  s    **51377JGZGZ[aGbdg<h<hBCC $$W-J:t$$z~~i0#66z~~f-s33BCCr*   c                ,    V ^8  d   QhRRR\         RR/# )r!   rf   r   r   ra   Nr#   )r%   s   "r'   r(   r(   5  s"     & &#7 &S &T &r*   c                    V P                  RR7      ;_uu_ 4       p\        RWR7      p\        V4       RRR4       R#   + '       g   i     R# ; i)ax  
Uploads `fileobj` as a single PUT HTTP request (basic LFS transfer protocol)

Args:
    upload_url (`str`):
        The URL to PUT the file to.
    fileobj:
        The file-like object holding the data to upload.

Returns: `requests.Response`

Raises:
 [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
    If the upload resulted in an error.
T	with_tqdmPUTr;   N)as_filer   r   )rf   r   rC   responses   &&  r'   r   r   5  s=      
		T		*	*gz@H% 
+	*	*	*s	   >A	c          
      D    V ^8  d   QhRRR\         R\        R\        RR/# )r!   rf   r   r   r   r   ra   N)r   rL   r$   )r%   s   "r'   r(   r(   K  s3      (  ("6  (  (RU  (cf  (ko  (r*   c                    \        WP                  VR7      p\        P                  p\        P                  '       dY   \	        V P
                  \        4      '       g9   \	        V P
                  \        4      '       g   \        P                  ! R4       RpV'       d   \        WVR7      M\        WVR7      p\        4       P                  V\        W`P                  P                  P!                  4       4      \"        R7      p\%        V4       R# )z8
Uploads file using HF multipart LFS transfer protocol.
)r   r   r   zlhf_transfer is enabled but does not support uploading from bytes or BinaryIO, falling back to regular uploadF)rf   sorted_parts_urlsr   )rp   r_   N)_get_sorted_parts_urlsr   r   HF_HUB_ENABLE_HF_TRANSFERry   path_or_fileobjr$   r   warningswarn_upload_parts_hf_transfer_upload_parts_iterativelyr   rw   _get_completion_payloadr   ru   rv   r   )rf   r   r   r   r   use_hf_transferresponse_headerscompletion_ress   &&&&    r'   r   r   K  s    
 /fJ_J_lvw  99O+++944c::944d;;	
    	"Igqr&lvw  !]''$%57L7L7S7S7W7W7YZ ( N
 'r*   c          	      ^    V ^8  d   QhR\         R\        R\        R\        \        ,          /# )r!   r   r   r   ra   )r   r   rL   r
   r$   )r%   s   "r'   r(   r(   n  s/     # #4 #j #c #VZ[^V_ #r*   c           
      ~   \        V P                  4        UUu. uF=  w  r4VP                  4       '       g   K  \        V4      ^ 8  g   K/  \	        V^
4      V3NK?  	  uppR R7       UUu. uF  w  rTVNK	  	  ppp\        V4      pV\        VP                  V,          4      8w  d   \        R4      hV# u uppi u uppi )    c                     V ^ ,          # )r   rM   )ts   &r'   <lambda>(_get_sorted_parts_urls.<locals>.<lambda>w  s    !A$r*   )keyz0Invalid server response to upload large LFS file)sorteditemsisdigitr?   rL   r   r0   r{   )r   r   r   part_numr   _sorted_part_upload_urls	num_partss   &&&     r'   r   r   n  s     $ -3LLN,:(H##% 0*-h-!*; 0Xr"J/,:
 


MA 	
  
 +,ID))J677KLL""
s   B3
B3

B3
*B9c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r!   r   rk   ra   )r
   r   r$   r   )r%   s   "r'   r(   r(     s&     ( (d4j (s (GY (r*   c                     . p\        V 4       FU  w  r4VP                  R 4      pVe   VR8X  d   \        RV RV^,            24      hVP                  RV^,           R V/4       KW  	  RVRV/# )r   rd   zInvalid etag (`z`) returned for part r   rk   r   )	enumeraterx   r{   append)r   rk   r   part_numberr   r   s   &&    r'   r   r     s     "E()9:zz&!<42:tf4I+XY/IZ[\\kAo	
	  ; 3''r*   c          	      l    V ^8  d   QhRRR\         \        ,          R\        R\         \        ,          /# r!   rf   r   r   r   ra   r
   r$   rL   r   )r%   s   "r'   r(   r(     s4      #8<S	OR	$Zr*   c                 x   . pV P                  R R7      ;_uu_ 4       p\        V4       F]  w  rV\        VW%,          VR7      ;_uu_ 4       p\        RWgR7      p\	        V4       VP                  VP                  4       RRR4       K_  	  RRR4       V#   + '       g   i     K|  ; i  + '       g   i     T# ; i)Tr   )	seek_from
read_limitr   r   N)r   r   r   r   r   r   r_   )	rf   r   r   r_   rC   part_idxpart_upload_urlfileobj_slicepart_upload_ress	   &&&      r'   r   r     s     G			T		*	*g)23D)E%H$/%  ".uo"Z#O4667  *F 
+ N   
+	* Ns#   -B(
4B>B(B%	B((B9	c          	      l    V ^8  d   QhRRR\         \        ,          R\        R\         \        ,          /# r   r   )r%   s   "r'   r(   r(     s4     1 1#18<S	1OR1	$Z1r*   c                     ^ RI Hp R\        P
                  ! T4      P                  9   pT'       g   \        P                  ! R4       T P                  P                  pT P                  p\        T4      ^(8  d	   RTRR  2p\        RRT^ T\        \        P!                  4       4      R	R
7      ;_uu_ 4       p T! RRT P"                  RTRTR^R^R^/T'       d   RTP$                  /M/ B pT'       g   TP%                  T4       TuuRRR4       #   \         d    \        R4      hi ; i  \&         d   p	\)        R4      T	hRp	?	ii ; i  + '       g   i     R# ; i)r   )multipart_uploadzFast uploading using 'hf_transfer' is enabled (HF_HUB_ENABLE_HF_TRANSFER=1) but 'hf_transfer' package is not available in your environment. Try `pip install hf_transfer`.callbackzYou are using an outdated version of `hf_transfer`. Consider upgrading to latest version to enable progress bars using `pip install -U hf_transfer`.u   (…)NBTzhuggingface_hub.lfs_upload)unit
unit_scaletotalinitialdescdisablerm   	file_path
parts_urlsr   	max_filesparallel_failuresmax_retriesz~An error occurred while uploading using `hf_transfer`. Consider disabling HF_HUB_ENABLE_HF_TRANSFER for better error handling.irM   )hf_transferr   ImportErrorr{   inspect	signature
parametersr   r   r   r0   r   r?   r   r   r   getEffectiveLevelr   update	ExceptionRuntimeError)
rf   r   r   r   supports_callbackr   r   progressoutputes
   &&&       r'   r   r     s   
0 #g&7&78H&I&T&TT c	
 !!&&E!!D
4y2~tCDzl#	 !9!9!;<)
 
 
	% #33, & 	
 #&  5FJ02F !OOE"5
 
#  
Q
 	

H  	* 	'
 
 
sA   D 8E:4D-.E6ED*-E	8EE		EE	)NNNN)NNN)ArR   r   r2   rer   dataclassesr   mathr   os.pathr   pathlibr   typingr   r   r   r	   r
   r   r   r   urllib.parser   huggingface_hubr   utilsr   r   r   r   r   r   r   r   
utils._lfsr   	utils.shar   r   
utils.tqdmr   _commit_apir   
get_loggerrN   r   compile	OID_REGEXLFS_MULTIPART_UPLOAD_COMMANDrv   r   r   r   r   r   r   r|   r}   r   r   r   r   r   r   rM   r*   r'   <module>r     s   5  	 	  !    \ \ \   %	 	 	 % * ( /			H	%JJ()	5  ,2 &9 &9 &9R S Sl9 
 CAL&, (F#$($1r*   