
    ߔ9i>"                         d Z ddlZddlmZmZ ddlmZmZ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mZ  G d
 de      Zy)a  Contains command to download files from the Hub with the CLI.

Usage:
    huggingface-cli download --help

    # Download file
    huggingface-cli download gpt2 config.json

    # Download entire repo
    huggingface-cli download fffiloni/zeroscope --repo-type=space --revision=refs/pr/78

    # Download repo with filters
    huggingface-cli download gpt2 --include="*.safetensors"

    # Download with token
    huggingface-cli download Wauplin/private-model --token=hf_***

    # Download quietly (no progress bar, no warnings, only the returned path)
    huggingface-cli download gpt2 config.json --quiet

    # Download to local dir
    huggingface-cli download gpt2 --local-dir=./models/gpt2
    N)	Namespace_SubParsersAction)ListLiteralOptionalUnion)logging)snapshot_download)BaseHuggingfaceCLICommand)hf_hub_download)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)
DownloadCommandparserc                    | j                  dd      }|j                  dt        d       |j                  dt        dd	
       |j                  dg ddd       |j                  dt        d       |j                  ddt        d       |j                  ddt        d       |j                  dt        d       |j                  dt        d       |j                  dg ddd       |j                  dd d!"       |j                  d#d d$"       |j                  d%t        d&       |j                  d'd d("       |j                  t        )       y )*NdownloadzDownload files from the Hub)helprepo_idz<ID of the repo to download from (e.g. `username/repo-name`).)typer   	filenames*z>Files to download (e.g. `config.json`, `data/metadata.jsonl`).)r   nargsr   z--repo-type)modeldatasetspacer   z/Type of repo to download from (e.g. `dataset`).)choicesdefaultr   z
--revisionzPAn optional Git revision id which can be a branch name, a tag, or a commit hash.z	--includez)Glob patterns to match files to download.)r   r   r   z	--excludez0Glob patterns to exclude from files to download.z--cache-dirz9Path to the directory where to save the downloaded files.z--local-dirzIf set, the downloaded file will be placed under this directory either as a symlink (default) or a regular file. Check out https://huggingface.co/docs/huggingface_hub/guides/download#download-files-to-local-folder for more details.z--local-dir-use-symlinks)autoTrueFalser   aw  To be used with `local_dir`. If set to 'auto', the cache directory will be used and the file will be either duplicated or symlinked to the local directory depending on its size. It set to `True`, a symlink will be created, no matter the file size. If set to `False`, the file will either be duplicated from cache (if already exists) or downloaded from the Hub and not cached.z--force-download
store_truezFIf True, the files will be downloaded even if they are already cached.)actionr   z--resume-downloadz2If True, resume a previously interrupted download.z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokensz--quietzWIf True, progress bars are disabled and only the path to the download files is printed.)func)
add_parseradd_argumentstrset_defaultsr   )r   download_parsers     k/var/www/html/backtest/airagagent/rag_env/lib/python3.12/site-packages/huggingface_hub/commands/download.pyregister_subcommandz#DownloadCommand.register_subcommand2   s    ++J=Z+[$$C&d 	% 	
 	$$c3s 	% 	
 	$$1B	 	% 	
 	$$c 	% 	

 	$$s3^ 	% 	
 	$$s3e 	% 	
 	$$*e 	% 	
 	$$	 	% 		
 	$$&-h 	% 
	
 	$$Y 	% 	

 	$$;o 	% 	
 	$$C&q 	% 	
 	$$j 	% 	

 	$$/$:    argsreturnNc                 R   |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _
        |j                  | _        |  |j                  j                         }|dk(  rd| _        y |dk(  rd| _        y |dk(  rd| _        y t        d|j                   d      )NtrueTfalseFr   'za' is not a valid value for `local_dir_use_symlinks`. It must be either 'auto', 'True' or 'False'.)tokenr   r   	repo_typerevisionincludeexclude	cache_dir	local_dirforce_downloadresume_downloadquietlocal_dir_use_symlinkslower
ValueError)selfr-   use_symlinks_lowercases      r*   __init__zDownloadCommand.__init__v   s    ZZ
 LL$(NN"nn'+}},0LL,0LL(,(,$($7$7%)%9%9::
 	!%!<!<!B!B!D!V+*.D'#w.*/D'#v-*0D'D//0 1. . 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	_downloadr   r	   set_verbosity_infoset_verbosity_warning)r@   s    r*   runzDownloadCommand.run   s    ::!#((* (%%h/dnn&'( !"&&($.."#))+( !"s   /B//Cc                    t        | j                        dkD  rr| j                  -t        | j                        dkD  rt        j                  d       | j
                  -t        | j
                        dkD  rt        j                  d       t        | j                        dk(  r}t        | j                  | j                  | j                  | j                  d   | j                  | j                  | j                  | j                  | j                  | j                  d      S t        | j                        dk(  r| j                  }| j
                  }n| j                  }d }t!        | j                  | j                  | j                  ||| j                  | j                  | j                  | j                  | j                  | j                  d      S )Nr   z?Ignoring `--include` since filenames have being explicitly set.z?Ignoring `--exclude` since filenames have being explicitly set.   zhuggingface-cli)r   r4   r5   filenamer8   r;   r:   r3   r9   r=   library_name)r   r4   r5   allow_patternsignore_patternsr;   r:   r8   r3   r9   r=   rP   )lenr   r6   rE   warnr7   r   r   r4   r5   r8   r;   r:   r3   r9   r=   r
   )r@   rQ   rR   s      r*   rI   zDownloadCommand._download   sc   t~~"||'C,=,A_`||'C,=,A_` t~~!#"..*.. $ 4 4#22jj..'+'B'B.   A%!\\N"llO!^^N"O LLnn]])+ 00..nn**nn#'#>#>*
 	
r,   )r.   N)__name__
__module____qualname__staticmethodr   r+   r   rB   rL   r'   rI    r,   r*   r   r   1   sD    A;$5 A; A;FY 4 :
,-
3 -
r,   r   )__doc__rE   argparser   r   typingr   r   r   r   huggingface_hubr	   "huggingface_hub._snapshot_downloadr
   huggingface_hub.commandsr   huggingface_hub.file_downloadr   huggingface_hub.utilsr   r   r   rY   r,   r*   <module>rb      s6   .  1 1 1 # @ > 9 M[
/ [
r,   