o
    im                  
   @   s   d dl Z d dlmZ d dlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ dZ		dd	ed
ee deeedf defddZdS )    N)Path)OptionalUnion   )HUGGINGFACE_HUB_CACHE)cached_download
hf_hub_url)HfApi__repo_idrevision	cache_dirreturnc                 C   s   |du rt }t|trt|}t }|j| |d}tj|| 	dt
d |j }|jD ]=}t| |j|jd}tjj|jd }tjtj||}	tj|	dd t|||d}
tj|
d	 rit|
d	  q,|S )
a  
    Downloads 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.

    An alternative would be to just clone a repo but this would require that
    the user always has git and git-lfs installed, and properly configured.

    Note: at some point maybe this format of storage should actually replace
    the flat storage structure we've used so far (initially from allennlp
    if I remember correctly).

    Return:
        Local folder path (string) of repo snapshot
    N)r   r   /.)filenamer   T)exist_ok)r   force_filenamez.lock)r   
isinstancer   strr	   
model_infoospathjoinreplaceREPO_ID_SEPARATORshasiblingsr   	rfilenamesplitdirnamemakedirsr   existsremove)r   r   r   _apir   storage_folder
model_fileurlrelative_filepathnested_dirnamer    r*   \/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/huggingface_hub/snapshot_download.pysnapshot_download   s2   


r,   )NN)r   pathlibr   typingr   r   	constantsr   file_downloadr   r   hf_apir	   r   r   r,   r*   r*   r*   r+   <module>   s$    