Ë
    °ëjX5  ã                   óÒ   — d Z ddlZddlZddlZddlmZmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ  ej2                  e«      Z G d„ de«      Zy)aû  Contains command to upload a repo or file with the CLI.

Usage:
    # Upload file (implicit)
    huggingface-cli upload my-cool-model ./my-cool-model.safetensors

    # Upload file (explicit)
    huggingface-cli upload my-cool-model ./my-cool-model.safetensors  model.safetensors

    # Upload directory (implicit). If `my-cool-model/` is a directory it will be uploaded, otherwise an exception is raised.
    huggingface-cli upload my-cool-model

    # Upload directory (explicit)
    huggingface-cli upload my-cool-model ./models/my-cool-model .

    # Upload filtered directory (example: tensorboard logs except for the last run)
    huggingface-cli upload my-cool-model ./model/training /logs --include "*.tfevents.*" --exclude "*20230905*"

    # Upload private dataset
    huggingface-cli upload Wauplin/my-cool-dataset ./data . --repo-type=dataset --private

    # Upload with token
    huggingface-cli upload Wauplin/my-cool-model --token=hf_****

    # Sync local Space with Hub (upload new files, delete removed files)
    huggingface-cli upload Wauplin/space-example --repo-type=space --exclude="/logs/*" --delete="*" --commit-message="Sync local Space with Hub"

    # Schedule commits every 30 minutes
    huggingface-cli upload Wauplin/my-cool-model --every=30
é    N)Ú	NamespaceÚ_SubParsersAction)ÚListÚOptional)Úlogging)ÚCommitScheduler)ÚBaseHuggingfaceCLICommand)ÚHF_HUB_ENABLE_HF_TRANSFER)ÚRevisionNotFoundError)ÚHfApi)Údisable_progress_barsÚenable_progress_barsc                   óF   — e Zd Zedefd„«       Zdeddfd„Zd	d„Zde	fd„Z
y)
ÚUploadCommandÚparserc                 ó  — | j                  dd¬«      }|j                  dt        d¬«       |j                  ddd	¬
«       |j                  ddd¬
«       |j                  dg d¢dd¬«       |j                  dt        d¬«       |j                  ddd¬«       |j                  ddt        d¬«       |j                  ddt        d¬«       |j                  ddt        d¬«       |j                  d t        d!¬«       |j                  d"t        d#¬«       |j                  d$dd%¬«       |j                  d&t        d'¬«       |j                  d(t        d)¬«       |j                  d*dd+¬«       |j	                  t
        ¬,«       y )-NÚuploadz.Upload a file or a folder to a repo on the Hub)ÚhelpÚrepo_idz<The ID of the repo to upload to (e.g. `username/repo-name`).)Útyper   Ú
local_pathú?zJLocal path to the file or folder to upload. Defaults to current directory.)Únargsr   Úpath_in_repoz\Path of the file or folder in the repo. Defaults to the relative path of the file or folder.z--repo-type)ÚmodelÚdatasetÚspacer   z/Type of the repo to upload to (e.g. `dataset`).)ÚchoicesÚdefaultr   z
--revisionz°An optional Git revision to push to. It can be a branch name or a PR reference. If revision does not exist and `--create-pr` is not set, a branch will be automatically created.z	--privateÚ
store_truezfWhether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already exists.)Úactionr   z	--includeÚ*z'Glob patterns to match files to upload.)r   r   r   z	--excludez.Glob patterns to exclude from files to upload.z--deletezDGlob patterns for file to be deleted from the repo while committing.z--commit-messagez9The summary / title / first line of the generated commit.z--commit-descriptionz(The description of the generated commit.z--create-prz0Whether to upload content as a new Pull Request.z--everyzNIf set, a background job is scheduled to create commits every `every` minutes.z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokensz--quietzWIf True, progress bars are disabled and only the path to the uploaded files is printed.)Úfunc)Ú
add_parserÚadd_argumentÚstrÚfloatÚset_defaultsr   )r   Úupload_parsers     úl/home/oem/CyberBrain26-unified/dev-env/.venv/lib/python3.12/site-packages/huggingface_hub/commands/upload.pyÚregister_subcommandz!UploadCommand.register_subcommandA   så  € à×)Ñ)¨(Ð9iÐ)ÓjˆØ×"Ñ"ØœCÐ&dð 	#ô 	
ð 	×"Ñ"Ø Ð*vð 	#ô 	
ð 	×"Ñ"ØØØoð 	#ô 	
ð
 	×"Ñ"ØÚ1ØØBð	 	#ô 	
ð 	×"Ñ"ØÜð_ð	 	#ô 	
ð 	×"Ñ"ØØðð	 	#ô 	
ð 	×"Ñ" ;°cÄÐJsÐ"ÔtØ×"Ñ"Ø˜s¬Ð3cð 	#ô 	
ð 	×"Ñ"ØØÜØWð	 	#ô 	
ð 	×"Ñ"Ø¤SÐ/jð 	#ô 	
ð 	×"Ñ"Ð#9ÄÐJtÐ"ÔuØ×"Ñ"Ø ,Ð5gð 	#ô 	
ð 	×"Ñ"ØÜØað 	#ô 	
ð
 	×"Ñ"ØœCÐ&qð 	#ô 	
ð 	×"Ñ"ØØØjð 	#ô 	
ð
 	×"Ñ"¬Ð"Õ6ó    ÚargsÚreturnNc                 ó  — |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _	        t        |j                  d¬«      | _        |j                  | _        |j                  �(|j                  dk  rt        d|j                  › d�«      ‚|j                  | _        |j                   j!                  d«      d   }|  |  |j"                  €.t$        j&                  j)                  |«      r|| _        || _        y |j"                  €.t$        j&                  j-                  |«      r|| _        d| _        y |j"                  €t        d	|› d
�«      ‚|j*                  €it$        j&                  j)                  |j"                  «      r@|j"                  | _        t$        j&                  j/                  |j"                  «      | _        y |j*                  €|j"                  | _        d| _        y |j"                  | _        |j*                  | _        y )Nzhuggingface-cli)ÚtokenÚlibrary_namer   z'`every` must be a positive value (got 'z')ú/éÿÿÿÿú.ú'zD' is not a local file or folder. Please set `local_path` explicitly.)r   Ú	repo_typeÚrevisionÚprivateÚincludeÚexcludeÚdeleteÚcommit_messageÚcommit_descriptionÚ	create_prr   r0   ÚapiÚquietÚeveryÚ
ValueErrorÚsplitr   ÚosÚpathÚisfiler   ÚisdirÚbasename)Úselfr-   Ú	repo_names      r*   Ú__init__zUploadCommand.__init__…   sà  € Ø ŸL™LˆŒØ(,¯©ˆŒØ'+§}¡}ˆŒØ!Ÿ\™\ˆŒà,0¯L©LˆŒØ,0¯L©LˆŒØ+/¯;©;ˆŒà-1×-@Ñ-@ˆÔØ15×1HÑ1HˆÔØ#Ÿ~™~ˆŒÜ d§j¡jÐ?PÔQˆŒØŸ:™:ˆŒ
ð �:‰:Ð! d§j¡j°A¢oÜÐFÀtÇzÁzÀlÐRTÐUÓVÐVØ&*§j¡jˆŒ
ð Ÿ™×+Ñ+¨CÓ0°Ñ4ˆ	ÙÙØ�?‰?Ð"¤r§w¡w§~¡~°iÔ'@à'ˆDŒOØ )ˆDÕØ�_‰_Ð$¬¯©¯©°yÔ)Aà'ˆDŒOØ #ˆDÕØ�_‰_Ð$ô ˜q  Ð+oÐpÓqÐqØ×ÑÐ&¬2¯7©7¯>©>¸$¿/¹/Ô+Jà"Ÿo™oˆDŒOÜ "§¡× 0Ñ 0°·±Ó AˆDÕØ×ÑÐ&à"Ÿo™oˆDŒOØ #ˆDÕð #Ÿo™oˆDŒOØ $× 1Ñ 1ˆDÕr,   c                 óŠ  — | j                   r`t        «        t        j                  «       5  t        j                  d«       t        | j                  «       «       d d d «       t        «        y t        j                  «        t        | j                  «       «       t        j                  «        y # 1 sw Y   t        «        y xY w)NÚignore)r@   r   ÚwarningsÚcatch_warningsÚsimplefilterÚprintÚ_uploadr   r   Úset_verbosity_infoÚset_verbosity_warning)rI   s    r*   ÚrunzUploadCommand.run·   s}   € Ø�:Š:Ü!Ô#Ü×(Ñ(Ó*ñ &Ü×%Ñ% hÔ/Ü�d—l‘l“nÔ%÷&ô !Õ"ä×&Ñ&Ô(Ü�$—,‘,“.Ô!Ü×)Ñ)Õ+÷&ô !Õ"ús   «/B/Â/Cc                 óÆ
  — t         j                  j                  | j                  «      r«| j                  �-t        | j                  «      dkD  rt        j                  d«       | j                  �-t        | j                  «      dkD  rt        j                  d«       | j                  �-t        | j                  «      dkD  rt        j                  d«       t        st        j                  d«       | j                  ��¶t         j                  j                  | j                  «      r�t         j                  j                  | j                  «      }| j                  j!                  | j                  «      r#| j                  d t        | j                  «        n| j                  }| j                  g}g }nq| j                  }| j                  }| j                  xs g }| j                  xs g }| j                  �-t        | j                  «      dkD  rt        j                  d«       t#        || j$                  | j&                  | j(                  |||| j*                  | j                  | j,                  ¬«
      }t/        d| j                  › d	|j$                  › d
�«       	 	 t1        j2                  d«       Œt         j                  j                  | j                  «      sBt         j                  j9                  | j                  «      st;        d| j                  › d�«      ‚| j,                  j=                  | j$                  | j&                  d| j*                  | j&                  dk(  rdnd ¬«      j$                  }| j(                  �?| j>                  s3	 | j,                  jA                  || j&                  | j(                  ¬«       t         j                  j                  | j                  «      ri| j,                  jG                  | j                  | j                  || j&                  | j(                  | jH                  | jJ                  | j>                  ¬«      S | j,                  jM                  | j                  | j                  || j&                  | j(                  | jH                  | jJ                  | j>                  | j                  | j                  | j                  ¬«      S # t4        $ r |j7                  «        Y yw xY w# tB        $ rZ t        j                  d| j(                  › d�«       | j,                  jE                  || j&                  | j(                  d¬«       Y �Œ�w xY w)Nr   z5Ignoring `--include` since a single file is uploaded.z5Ignoring `--exclude` since a single file is uploaded.z4Ignoring `--delete` since a single file is uploaded.z©Consider using `hf_transfer` for faster uploads. This solution comes with some limitations. See https://huggingface.co/docs/huggingface_hub/hf_transfer for more details.z:Ignoring `--delete` when uploading with scheduled commits.)
Úfolder_pathr   r6   r7   Úallow_patternsÚignore_patternsr   r8   rA   Úhf_apizScheduling commits every z minutes to r4   Téd   zStopped scheduled commits.zNo such file or directory: 'z'.r   Úgradio)r   r6   Úexist_okr8   Ú	space_sdk)r   r6   r7   zBranch 'z' not found. Creating it...)r   r6   Úbranchr]   )Úpath_or_fileobjr   r   r6   r7   r<   r=   r>   )rW   r   r   r6   r7   r<   r=   r>   rX   rY   Údelete_patterns)'rD   rE   rF   r   r9   ÚlenrN   Úwarnr:   r;   r
   ÚloggerÚinforA   Údirnamer   Úendswithr   r   r6   r7   r8   r?   rQ   ÚtimeÚsleepÚKeyboardInterruptÚstoprG   ÚFileNotFoundErrorÚcreate_repor>   Ú	repo_infor   Úcreate_branchÚupload_filer<   r=   Úupload_folder)rI   rW   r   rX   rY   Ú	schedulerr   s          r*   rR   zUploadCommand._uploadÃ   s  € Ü�7‰7�>‰>˜$Ÿ/™/Ô*Ø�|‰|Ð'¬C°·±Ó,=ÀÒ,AÜ—‘ÐUÔVØ�|‰|Ð'¬C°·±Ó,=ÀÒ,AÜ—‘ÐUÔVØ�{‰{Ð&¬3¨t¯{©{Ó+;¸aÒ+?Ü—‘ÐTÔUå(Ü�K‰Kð]ôð �:‰:Ñ!Ü�w‰w�~‰~˜dŸo™oÔ.ä Ÿg™gŸo™o¨d¯o©oÓ>�ð ×(Ñ(×1Ñ1°$·/±/ÔBð ×%Ñ%Ð&=¬¨T¯_©_Ó)=Ð(=Ñ>à×*Ñ*ð ð
 #'§/¡/Ð!2�Ø"$‘à"Ÿo™o�Ø#×0Ñ0�Ø!%§¡Ò!3°�Ø"&§,¡,Ò"4°"�Ø—;‘;Ð*¬s°4·;±;Ó/?À!Ò/CÜ—M‘MÐ"^Ô_ä'Ø'ØŸ™ØŸ.™.ØŸ™Ø-Ø /Ø)ØŸ™Ø—j‘jØ—x‘xôˆIô Ð-¨d¯j©j¨\¸Ài×FWÑFWÐEXÐXYÐZÔ[ð4ØÜ—J‘J˜s”Oð ô �w‰w�~‰~˜dŸo™oÔ.´r·w±w·}±}ÀTÇ_Á_Ô7UÜ#Ð&BÀ4Ç?Á?ÐBSÐSUÐ$VÓWÐWØ—(‘(×&Ñ&Ø—L‘LØ—n‘nØØ—L‘LØ"&§.¡.°GÒ";‘hÀð 'ó 
÷ ‰'ð 	ð �=‰=Ð$¨T¯^ª^ðwØ—‘×"Ñ"¨7¸d¿n¹nÐW[×WdÑWdÐ"Ôeô �7‰7�>‰>˜$Ÿ/™/Ô*Ø—8‘8×'Ñ'Ø $§¡Ø!×.Ñ.ØØŸ.™.ØŸ™Ø#×2Ñ2Ø#'×#:Ñ#:ØŸ.™.ð (ó 	ð 	ð —8‘8×)Ñ)Ø ŸO™OØ!×.Ñ.ØØŸ.™.ØŸ™Ø#×2Ñ2Ø#'×#:Ñ#:ØŸ.™.Ø#Ÿ|™|Ø $§¡Ø $§¡ð *ó ð øôS %ò 4Ø—‘Ô Ù3ð4ûô* )ò wÜ—‘˜h t§}¡} oÐ5PÐQÔRØ—‘×&Ñ&¨wÀ$Ç.Á.ÐY]×YfÑYfÐquÐ&×vðwús%   ÊS Î2S= ÓS:Ó9S:Ó=AU ÕU )r.   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r+   r   rK   rU   r&   rR   © r,   r*   r   r   @   sG   „ ØðA7Ð$5ò A7ó ðA7ðF02˜Yð 02¨4ó 02ód
,ðh˜ô hr,   r   )Ú__doc__rD   rh   rN   Úargparser   r   Útypingr   r   Úhuggingface_hubr   Ú!huggingface_hub._commit_schedulerr   Úhuggingface_hub.commandsr	   Úhuggingface_hub.constantsr
   Úhuggingface_hub.errorsr   Úhuggingface_hub.hf_apir   Úhuggingface_hub.utilsr   r   Ú
get_loggerrs   rd   r   rw   r,   r*   ú<module>rƒ      sS   ðñó> 
Û Û ß 1ß !å #Ý =Ý >Ý ?Ý 8Ý (ß Mð 
ˆ×	Ñ	˜HÓ	%€ôkÐ-õ kr,   