wL idZddlZddlmZmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZdd lmZmZe j&eZGd d e Zy) 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) Namespace_SubParsersAction)ListOptional)logging)snapshot_download)BaseHuggingfaceCLICommand)hf_hub_download)disable_progress_barsenable_progress_barscFeZdZedefdZdeddfdZd dZde fdZ y) DownloadCommandparserc|jdd}|jdtd|jdtdd |jd gd d d|jdtd|jddtd|jddtd|jdtd|jdtd|jddd|jdtd |jd!dd"|jd#td$d%&|j t 'y)(NdownloadzDownload files from the Hub)helprepo_idzFiles to download (e.g. `config.json`, `data/metadata.jsonl`).)rnargsrz --repo-type)modeldatasetspacerz4Type of repo to download from (defaults to 'model').)choicesdefaultrz --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.)rrrz --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--force-download store_truezFIf True, the files will be downloaded even if they are already cached.)actionrz--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-workerszEMaximum number of workers to use for downloading files. Default is 8.)rrr)func) add_parser add_argumentstrint set_defaultsr)rdownload_parsers b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/cli/download.pyregister_subcommandz#DownloadCommand.register_subcommand6s ++J=Z+[$$ C&d %  $$ c3s %  $$ 1G % $$ c % $$ s3^ %  $$ s3e %  $$ *e %  $$  %  $$ Y % $$ C&q %  $$ j % $$ X % $$/$:argsreturnNc|j|_|j|_|j|_|j|_|j|_|j |_|j |_|j|_|j|_|j|_ |j|_ |j|_ y)N) tokenrr repo_typerevisionincludeexclude cache_dir local_dirforce_downloadquiet max_workers)selfr*s r'__init__zDownloadCommand.__init__qsZZ  LL $(NN"nn'+}} ,0LL ,0LL (,(,$($7$7:: $ 0 0r)c|jr`ttj5tjdt |j dddtytjt |j tjy#1swYtyxYw)Nignore) r5r warningscatch_warnings simplefilterprint _downloadr rset_verbosity_infoset_verbosity_warning)r7s r'runzDownloadCommand.runs :: ! #((* (%%h/dnn&' ( ! "  & & ( $.." #  ) ) + ( ! "s /B//Cc ^t|jdkDrr|j-t|jdkDrtjd|j -t|j dkDrtjdt|jdk(rgt |j|j|j|jd|j|j|j|jd St|jdk(r|j}|j }n|j}d}t|j|j|j|||j|j|j|jd|j S)Nrz?Ignoring `--include` since filenames have being explicitly set.z?Ignoring `--exclude` since filenames have being explicitly set.zhuggingface-cli) rr.r/filenamer2r4r-r3 library_name) rr.r/allow_patternsignore_patternsr4r2r-r3rFr6)lenrr0r;warnr1r rr.r/r2r4r-r3rr6)r7rGrHs r'r?zDownloadCommand._downloadsH t~~  "||'C ,=,A _`||'C ,=,A _` t~~ ! #" ..*..#22jj...   A %!\\N"llO!^^N"O LLnn]])+..nn**nn*((  r))r+N) __name__ __module__ __qualname__ staticmethodrr(rr8rBr#r?r)r'rr5sA8;$58;8;t 1Y 14 1 ,* 3* r)r)__doc__r;argparserrtypingrrhuggingface_hubr"huggingface_hub._snapshot_downloadrhuggingface_hub.commandsr huggingface_hub.file_downloadr huggingface_hub.utilsr r get_loggerrKloggerrrOr)r'rZsG01!#@>9M   H %@ /@ r)