o
    i                     @   s  d Z ddlZddlmZmZmZ ddlZddlmZ ddl	m
Z
 ddlmZmZ ddlmZmZmZmZ dd	lmZmZmZmZ eeZdejdddddd
d
dd
dfdedeeee  ejddf dededeeee  ejddf deeee  ejddf deee ejddf deee ejddf dee ejddf dee ejddf dedee ejd df d!ee!ejd"df d#dfd$d%Z"dS )&a_  Contains command to download files from the Hub with the CLI.

Usage:
    hf download --help

    # Download file
    hf download gpt2 config.json

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

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

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

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

    # Download to local dir
    hf download gpt2 --local-dir=./models/gpt2
    N)	AnnotatedOptionalUnion)logging)snapshot_download)DryRunFileInfohf_hub_download)_format_sizedisable_progress_barsenable_progress_barstabulate   )	RepoIdArgRepoTypeOptRevisionOptTokenOptF   repo_id	filenamesz>Files to download (e.g. `config.json`, `data/metadata.jsonl`).)help	repo_typerevisionincludez;Glob patterns to include from files to download. eg: *.jsonexcludez0Glob patterns to exclude from files to download.	cache_dirzDirectory where to save files.	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.force_downloadzFIf True, the files will be downloaded even if they are already cached.dry_runzAIf True, perform a dry run without actually downloading the file.tokenquietzWIf True, progress bars are disabled and only the path to the download files is printed.max_workerszEMaximum number of workers to use for downloading files. Default is 8.returnc                    s   dt tttt f f 	
fdd}dt tttt f ddfdd}|rSt  t  td ||  W d   n1 sIw   Y  t  dS ||  t	
  dS )	zDownload files from the Hub.r!   c                     s   d urng } t | dkr,d urt dkrtd d ur,t dkr,td t | dkrCt	j
| d  dd
S t | dkrN}}n| }d }t	j
|| ddS )Nr   z?Ignoring `--include` since filenames have being explicitly set.z?Ignoring `--exclude` since filenames have being explicitly set.r   zhuggingface-cli)
r   r   r   filenamer   r   r   r   library_namer   )r   r   r   allow_patternsignore_patternsr   r   r   r   r#   r    r   )lenwarningswarnr   valuer   )filenames_listr$   r%   r   r   r   r   r   r   r   r    r   r   r   r    b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/huggingface_hub/cli/download.pyrun_downloadu   sL   

zdownload.<locals>.run_downloadresultNc              
   S   s   t | trt|  d S t | tr| g} tdtdd | D  dt|  dttdd | D  d d	d
g}g }t| dd dD ]}||j	|j
rOt|jndg qAtt||d d S )Nz[dry-run] Will download c                 S   s   g | ]}|j r|qS r,   )will_download.0rr,   r,   r-   
<listcomp>   s    z3download.<locals>._print_result.<locals>.<listcomp>z files (out of z) totalling c                 s   s    | ]	}|j r|jV  qd S N)r0   	file_sizer1   r,   r,   r-   	<genexpr>   s    z2download.<locals>._print_result.<locals>.<genexpr>.FilezBytes to downloadc                 S   s   | j S r5   )r"   )xr,   r,   r-   <lambda>   s    z1download.<locals>._print_result.<locals>.<lambda>)key-)headers)
isinstancestrprintr   r&   r	   sumsortedappendr"   r0   r6   r   )r/   columnsitemsinfor,   r,   r-   _print_result   s   

:"zdownload.<locals>._print_resultignore)r   r@   r   listr
   r'   catch_warningssimplefilterr   r   set_verbosity_warning)r   r   r   r   r   r   r   r   r   r   r   r   r    r.   rH   r,   r+   r-   download7   s   6> /



rN   )#__doc__r'   typingr   r   r   typerhuggingface_hubr   "huggingface_hub._snapshot_downloadr   huggingface_hub.file_downloadr   r   huggingface_hub.utilsr	   r
   r   r   
_cli_utilsr   r   r   r   
get_logger__name__loggermodelrJ   r@   ArgumentOptionboolintrN   r,   r,   r,   r-   <module>   s   


	


"(./5;