wL i&?.dddlZddlmZddlmZmZmZmZmZm Z m Z ddl Z ddl m ZddlmZddlmZddlmZmZmZmZmZdd lmZmZmZdd lmZmZm Z m!Z!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'ddl#m Z(e&jRe*Z+d Z,e'ddddddddejZd dd dddddddddde.dee.dee.de e.edfde e.edfdee.dee.dee ee.fdeede/de0dee e0e.fde0dee ee.e.fdee ee.e.fd e1d!ee ed"eee.e.fd#ee.d$e e0edfd%ee0d&e.f,d'Z2y)(N)Path)DictIterableListLiteralOptionalTypeUnion)tqdm) thread_map) constants)GatedRepoErrorHfHubHTTPErrorLocalEntryNotFoundErrorRepositoryNotFoundErrorRevisionNotFoundError)REGEX_COMMIT_HASHhf_hub_downloadrepo_folder_name) DatasetInfoHfApi ModelInfoRepoFile SpaceInfo)OfflineModeIsEnabledfilter_repo_objectsloggingvalidate_hf_hub_argsiPFauto) repo_typerevision cache_dir local_dir library_namelibrary_version user_agentproxies etag_timeoutforce_downloadtokenlocal_files_onlyallow_patternsignore_patterns max_workers tqdm_classheadersendpointlocal_dir_use_symlinksresume_downloadrepo_idr"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5returncB  $tj|tj}ttr t dtj vr(tddt tj tjjt}t }d}d}| s |j|}|d$t/j0|r|$ndtjj|d|}tjj3|r$t5|5}|j7$ddd$DBtjj|d $}tjj3|r|Sit j9rNt;j=r5t>jAd d |d t jCS| r tEd t|t(r tEd|t|tFtHfs)t|tJr|jLjNdk(r|tEd||jPJd|jR$|jRDcgc]}|jTc}ng}|jRduxs6tW|jRdk(xstW|jRtXkD}|r1t>j[dd|j]d|D}t_|| |}|sta|}dtW|d} nd} |jP$tjj|d $}|$k7r|tjj|d|} tjbtjje|dt5|d5}|jg$dddd t f$  fd! }"tjjr|D] }#|"|# ntm|"|| ||xstn"(t tjjqS|S#tjj tjj"f$rtjj$tjj&t(f$r }|}Yd}~;d}~wt*$rtj,$r }|}Yd}~bd}~wwxYw#1swYxYwcc}w#1swYExYw#th$r'}!t>jAd|d|!dYd}!~!sd}!~!wwxYw)#a(Download repo files. Download a whole snapshot of a repo's files at the specified revision. This is useful when you want all files from a repo, because you don't know which ones you will need a priori. All files are nested inside a folder in order to keep their actual filename relative to that folder. You can also filter which files to download using `allow_patterns` and `ignore_patterns`. If `local_dir` is provided, the file structure from the repo will be replicated in this location. When using this option, the `cache_dir` will not be used and a `.cache/huggingface/` folder will be created at the root of `local_dir` to store some metadata related to the downloaded files. While this mechanism is not as robust as the main cache-system, it's optimized for regularly pulling the latest version of a repository. An alternative would be to clone the repo but this requires git and git-lfs to be installed and properly configured. It is also not possible to filter which files to download when cloning a repository using git. Args: repo_id (`str`): A user or an organization name and a repo name separated by a `/`. repo_type (`str`, *optional*): Set to `"dataset"` or `"space"` if downloading from a dataset or space, `None` or `"model"` if downloading from a model. Default is `None`. revision (`str`, *optional*): An optional Git revision id which can be a branch name, a tag, or a commit hash. cache_dir (`str`, `Path`, *optional*): Path to the folder where cached files are stored. local_dir (`str` or `Path`, *optional*): If provided, the downloaded files will be placed under this directory. library_name (`str`, *optional*): The name of the library to which the object corresponds. library_version (`str`, *optional*): The version of the library. user_agent (`str`, `dict`, *optional*): The user-agent info in the form of a dictionary or a string. proxies (`dict`, *optional*): Dictionary mapping protocol to the URL of the proxy passed to `requests.request`. etag_timeout (`float`, *optional*, defaults to `10`): When fetching ETag, how many seconds to wait for the server to send data before giving up which is passed to `requests.request`. force_download (`bool`, *optional*, defaults to `False`): Whether the file should be downloaded even if it already exists in the local cache. token (`str`, `bool`, *optional*): A token to be used for the download. - If `True`, the token is read from the HuggingFace config folder. - If a string, it's used as the authentication token. headers (`dict`, *optional*): Additional headers to include in the request. Those headers take precedence over the others. local_files_only (`bool`, *optional*, defaults to `False`): If `True`, avoid downloading the file and return the path to the local cached file if it exists. allow_patterns (`List[str]` or `str`, *optional*): If provided, only files matching at least one pattern are downloaded. ignore_patterns (`List[str]` or `str`, *optional*): If provided, files matching any of the patterns are not downloaded. max_workers (`int`, *optional*): Number of concurrent threads to download files (1 thread = 1 file download). Defaults to 8. tqdm_class (`tqdm`, *optional*): If provided, overwrites the default behavior for the progress bar. Passed argument must inherit from `tqdm.auto.tqdm` or at least mimic its behavior. Note that the `tqdm_class` is not passed to each individual download. Defaults to the custom HF progress bar that can be disabled by setting `HF_HUB_DISABLE_PROGRESS_BARS` environment variable. Returns: `str`: folder path of the repo snapshot. Raises: [`~utils.RepositoryNotFoundError`] If the repository to download from cannot be found. This may be because it doesn't exist, or because it is set to `private` and you do not have access. [`~utils.RevisionNotFoundError`] If the revision to download from cannot be found. [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError) If `token=True` and the token cannot be found. [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError) if ETag cannot be determined. [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) if some parameter value is invalid. NmodelzInvalid repo type: z. Accepted repo types are: )r6r")r&r'r(r3r2r,)r6r"r#refs snapshotszReturning existing local_dir `z<` as remote repo cannot be accessed in `snapshot_download` (z).zCannot find an appropriate cached snapshot folder for the specified revision on the local disk and outgoing traffic has been disabled. To enable repo look-ups and downloads online, pass 'local_files_only=False' as input.zCannot find an appropriate cached snapshot folder for the specified revision on the local disk and outgoing traffic has been disabled. To enable repo look-ups and downloads online, set 'HF_HUB_OFFLINE=0' as environment variable.izAn error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.z8Repo info returned from server must have a revision sha.rzaNumber of files in the repo is unreliable. Using `list_repo_tree` to ensure all files are listed.c3TK|] }t|tr|j"yw)N) isinstancer rfilename).0fs h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/_snapshot_download.py z$snapshot_download..s& !X& KK s&(T)r6 recursiver#r")itemsr.r/z Fetching z fileszFetching ... files)exist_okwz+Ignored error while writing commit hash to z: . repo_filecxt fid|d dddd d dd d d d d dddS)Nfilenamer"r#r3r$r%r4r&r'r(r)r*r5r+r,r2)r)rHr$ commit_hashr3r*r+r2r&r'r%r4r)r6r"r5r,r(s rA_inner_hf_hub_downloadz1snapshot_download.._inner_hf_hub_download1s     !        $: & , "  & , * ! "#  )descr0r1)9r HF_HUB_CACHEDEFAULT_REVISIONr=rstr REPO_TYPES ValueErrorospathjoinrr repo_inforequests exceptionsSSLError ProxyErrorConnectionErrorTimeoutrr HTTPErrorrmatchexistsopenreadis_diranyiterdirloggerwarningresolverrrrresponse status_codeshasiblingsr>lenVERY_LARGE_REPO_THRESHOLDinfolist_repo_treerlistmakedirsdirnamewriteOSErrorHF_HUB_ENABLE_HF_TRANSFERr hf_tqdmrealpath)%r6r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5storage_folderapirWapi_call_errorerrorref_pathr@snapshot_folder repo_filesunreliable_nb_filesfiltered_repo_files tqdm_descerLfilerKs%`` ````````` ```` @rAsnapshot_downloadrs`X** --)T" N   ,,,.yk9TUXYbYmYmUnTopqqWW\\)-=gYb-cdN !'  CAEI*.N   gU] ^IF  " "8 ,"Kww||NFHEHww~~h'(^+q"#&&(K+  "y'8 ggll>; TOww~~o.'&  YI!c)*;*;*=&>4YK?{}K|LLNO9,,.// )5  (< =)>"  " )@.(Q R ~~ 6>;R;R;^;^be;e! *""  " == $`&`` $NWM_M_Mki6H6H I IqsJd" ? y!! "a ' ? y!! "%> >  o  ''4RZfo'p *=%'* "#67$7 89@ ( --Kggll>; LO;77<<A [ KK1D Ah$ % $ % #   ***( )D "4 ( )  " #!,W  277##I.// c##,,h.A.A.L.LM      / /    ' '   #N $  !! #N  8++f!JJ % % [ NNH RTUVTWWXY Z Z [shR% U:U AU. U!U.%A3U T  U ?UU U!U+&U.. V7VV)3rTpathlibrtypingrrrrrr r rX tqdm.autor base_tqdmtqdm.contrib.concurrentr rerrorsrrrrr file_downloadrrrhf_apirrrrrutilsrrrrrw get_logger__name__rfrnDEFAULT_ETAG_TIMEOUTrQfloatboolintrrMrArs< GGG'.POFF[["   H %! $"(,(,"&%)-1"#88 (,"6:7;,0(,";A&*/z z}zsm z S$_% z S$_% z3-zc]ztSy)*zd^zzz E$)$ %zzU49c>23z eDIsN34!z"#z$i)%z&d38n %'z(sm)z,"$"78-z.d^/z0 1zzrM