Ë
    Úªgð  ã                   ó¦   — d 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  e	j$                  e«      Z G d„ de«      Zy)z7Contains command to upload a large folder with the CLI.é    N)Ú	NamespaceÚ_SubParsersAction)ÚListÚOptional)Úlogging)ÚBaseHuggingfaceCLICommand)ÚHfApi)Údisable_progress_barsé   )ÚANSIc                   ó:   — e Zd Zedefd„«       Zdeddfd„Zdd„Zy)	ÚUploadLargeFolderCommandÚparserc                 óN  — | j                  dd¬«      }|j                  dt        d¬«       |j                  dt        d¬«       |j                  d	g d
¢d¬«       |j                  dt        d¬«       |j                  dd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dd ¬«       |j	                  t
        ¬!«       y )"Nzupload-large-folderz*Upload a large 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_pathz+Local path to the file or folder to upload.z--repo-type)ÚmodelÚdatasetÚspacez/Type of the repo to upload to (e.g. `dataset`).)Úchoicesr   z
--revisionzOAn optional Git revision to push to. It can be a branch name or a PR reference.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.)Únargsr   r   z	--excludez.Glob patterns to exclude from files to upload.z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokensz--num-workersz:Number of workers to use to hash, upload and commit files.z--no-reportz)Whether to disable regular status report.z	--no-barsz!Whether to disable progress bars.)Úfunc)Ú
add_parserÚadd_argumentÚstrÚintÚset_defaultsr   )r   Ú	subparsers     úa/var/www/openai/venv/lib/python3.12/site-packages/huggingface_hub/commands/upload_large_folder.pyÚregister_subcommandz,UploadLargeFolderCommand.register_subcommand!   sN  € à×%Ñ%Ð&;ÐBnÐ%Óoˆ	Ø×ÑØœCÐ&dð 	ô 	
ð 	×Ñ˜|´#Ð<iÐÔjØ×ÑØÚ1ØBð 	ô 	
ð
 	×ÑØÜØcð 	ô 	
ð
 	×ÑØØàxð	 	ô 	
ð 	×Ñ˜{°#¼CÐFoÐÔpØ×Ñ˜{°#¼CÐFvÐÔwØ×ÑØœCÐ&qð 	ô 	
ð 	×ÑØ¤#Ð,hð 	ô 	
ð 	×Ñ˜}°\ÐHsÐÔtØ×Ñ˜{°<ÐFiÐÔjØ×ÑÔ$<ÐÕ=ó    ÚargsÚreturnNc                 óø  — |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        t        |j                  d¬«      | _	        |j                  | _
        |j                  | _        |j                  | _        t        j                  j                  | j                  «      st!        d«      ‚y )Nzhuggingface-cli)ÚtokenÚlibrary_namez+Large upload is only supported for folders.)r   r   Ú	repo_typeÚrevisionÚprivateÚincludeÚexcluder	   r*   ÚapiÚnum_workersÚ	no_reportÚno_barsÚosÚpathÚisdirÚ
ValueError)Úselfr'   s     r$   Ú__init__z!UploadLargeFolderCommand.__init__E   s«   € Ø ŸL™LˆŒØ#Ÿ™ˆŒØ"Ÿn™nˆŒØ'+§}¡}ˆŒØ!Ÿ\™\ˆŒà,0¯L©LˆŒØ,0¯L©LˆŒä d§j¡jÐ?PÔQˆŒà*.×*:Ñ*:ˆÔØ#Ÿ~™~ˆŒØ!Ÿ\™\ˆŒäw‰w}‰}˜TŸ_™_Ô-ÜÐJÓKÐKð .r&   c                 ó®  — t        j                  «        t        t        j                  d| j
                  › d«      «       | j                  r
t        «        | j                  j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                   | j"                   ¬«	       y )Na®  You are about to upload a large folder to the Hub using `huggingface-cli upload-large-folder`. This is a new feature so feedback is very welcome!

A few things to keep in mind:
  - Repository limits still apply: https://huggingface.co/docs/hub/repositories-recommendations
  - Do not start several processes in parallel.
  - You can interrupt and resume the process at any time. The script will pick up where it left off except for partially uploaded files that would have to be entirely reuploaded.
  - Do not upload the same folder to several repositories. If you need to do so, you must delete the `./.cache/huggingface/` folder first.

Some temporary metadata will be stored under `a·  /.cache/huggingface`.
  - You must not modify those files manually.
  - You must not delete the `./.cache/huggingface/` folder while a process is running.
  - You can delete the `./.cache/huggingface/` folder to reinitialize the upload state when process is not running. Files will have to be hashed and preuploaded again, except for already committed files.

If the process output is to verbose, you can disable the progress bars with `--no-bars`. You can also entirely disable the status report with `--no-report`.

For more details, run `huggingface-cli upload-large-folder --help` or check the documentation at https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-large-folder.)	r   Úfolder_pathr,   r-   r.   Úallow_patternsÚignore_patternsr2   Úprint_report)r   Úset_verbosity_infoÚprintr   Úyellowr   r4   r
   r1   Úupload_large_folderr   r,   r-   r.   r/   r0   r2   r3   )r9   s    r$   ÚrunzUploadLargeFolderCommand.runX   s­   € Ü×"Ñ"Ô$äÜK‰Kð
Að BFÇÁÐ@Qð 	Rcðcóô	
ð2 <Š<Ü!Ô#à‰×$Ñ$Ø—L‘LØŸ™Ø—n‘nØ—]‘]Ø—L‘LØŸ<™<Ø ŸL™LØ×(Ñ(Ø!Ÿ^™^Ð+ð 	%õ 
	
r&   )r(   N)	Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r%   r   r:   rD   © r&   r$   r   r       s8   „ Øð!>Ð$5ò !>ó ð!>ðFL˜Yð L¨4ó Lô&)
r&   r   )Ú__doc__r5   Úargparser   r   Útypingr   r   Úhuggingface_hubr   Úhuggingface_hub.commandsr   Úhuggingface_hub.hf_apir	   Úhuggingface_hub.utilsr
   Ú
_cli_utilsr   Ú
get_loggerrE   Úloggerr   rI   r&   r$   Ú<module>rT      sE   ðñ >ã 	ß 1ß !å #Ý >Ý (Ý 7å ð 
ˆ×	Ñ	˜HÓ	%€ôa
Ð8õ a
r&   