
    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mZ  e	j        e          Z G d
 de          ZdS )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Optional)logging)snapshot_download)BaseHuggingfaceCLICommand)hf_hub_download)disable_progress_barsenable_progress_barsc                   N    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
dS )
DownloadCommandparserc                 v   |                      dd          }|                    dt          d           |                    dt          dd	
           |                    dg ddd           |                    dt          d           |                    ddt          d           |                    ddt          d           |                    dt          d           |                    dt          d           |                    dg dd           |                    dd d!"           |                    d#d d$"           |                    d%t          d&           |                    d'd d("           |                    d)t          d*d+,           |                    t
          -           d S ).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   z4Type of repo to download from (defaults to 'model').)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. 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FalsezWDeprecated and ignored. Downloading to a local directory does not use symlinks anymore.)r   r   z--force-download
store_truezFIf True, the files will be downloaded even if they are already cached.)actionr   z--resume-downloadzDeprecated and ignored. Downloading a file to local dir always attempts to resume previously interrupted downloads (unless hf-transfer is enabled).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.z--max-workers   zEMaximum number of workers to use for downloading files. Default is 8.)r   r   r   )func)
add_parseradd_argumentstrintset_defaultsr   )r   download_parsers     ]/var/www/html/ai-engine/env/lib/python3.11/site-packages/huggingface_hub/commands/download.pyregister_subcommandz#DownloadCommand.register_subcommand6   s    ++J=Z+[[$$C&d 	% 	
 	
 	
 	$$c3s 	% 	
 	
 	
 	$$111G	 	% 	
 	
 	
 	$$c 	% 	
 	
 	

 	$$s3^ 	% 	
 	
 	
 	$$s3e 	% 	
 	
 	
 	$$*e 	% 	
 	
 	
 	$$	 	% 	
 	
 	
 	$$&---k 	% 	
 	
 	

 	$$Y 	% 	
 	
 	

 	$$ g 	% 	
 	
 	

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

 	$$X	 	% 	
 	
 	
 	$$/$:::::    argsreturnNc                    |j         | _         |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j	        | _	        |j
        pd | _
        |j        | _        |j        | _        |j        t          j        dt                      d S d S )NzbIgnoring --local-dir-use-symlinks. Downloading to a local directory does not use symlinks anymore.)tokenr   r   	repo_typerevisionincludeexclude	cache_dir	local_dirforce_downloadresume_downloadquietmax_workerslocal_dir_use_symlinkswarningswarnFutureWarning)selfr-   s     r*   __init__zDownloadCommand.__init__{   s    Z
 L$(N"n'+},0L,0L(,(,$($7/3/C/Kt:
 $ 0&2Mt     32r,   c                    | j         r~t                       t          j                    5  t          j        d           t          |                                            d d d            n# 1 swxY w Y   t                       d S t          j	                     t          |                                            t          j
                     d S )Nignore)r9   r   r<   catch_warningssimplefilterprint	_downloadr   r   set_verbosity_infoset_verbosity_warning)r?   s    r*   runzDownloadCommand.run   s    : 		,!###(** ( (%h///dnn&&'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( !"""""&((($..""###)+++++s   6A++A/2A/c                    t          | j                  dk    rf| j        ,t          | j                  dk    rt          j        d           | j        ,t          | j                  dk    rt          j        d           t          | j                  dk    rLt          | j        | j        | j	        | j        d         | 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        d| j                  S )Nr   z?Ignoring `--include` since filenames have being explicitly set.z?Ignoring `--exclude` since filenames have being explicitly set.   zhuggingface-cli)
r   r1   r2   filenamer5   r8   r7   r0   r6   library_name)r   r1   r2   allow_patternsignore_patternsr8   r7   r5   r0   r6   rM   r:   )lenr   r3   r<   r=   r4   r
   r   r1   r2   r5   r8   r7   r0   r6   r   r:   )r?   rN   rO   s      r*   rF   zDownloadCommand._download   sY   t~""|'C,=,=,A,A_```|'C,=,=,A,A_``` t~!##".*. $ 4#2j..      A%%!\N"lOO!^N"O Ln])+ 0.n*n*(
 
 
 	
r,   )r.   N)__name__
__module____qualname__staticmethodr   r+   r   r@   rI   r&   rF    r,   r*   r   r   5   s        B;$5 B; B; B; \B;HY 4    *
, 
, 
, 
,,
3 ,
 ,
 ,
 ,
 ,
 ,
r,   r   )__doc__r<   argparser   r   typingr   r   huggingface_hubr   "huggingface_hub._snapshot_downloadr   huggingface_hub.commandsr	   huggingface_hub.file_downloadr
   huggingface_hub.utilsr   r   
get_loggerrQ   loggerr   rU   r,   r*   <module>r`      s    0  1 1 1 1 1 1 1 1 ! ! ! ! ! ! ! ! # # # # # # @ @ @ @ @ @ > > > > > > 9 9 9 9 9 9 M M M M M M M M 
	H	%	%S
 S
 S
 S
 S
/ S
 S
 S
 S
 S
r,   