
    Nj                         d dl Z d dlmZ d dlZd dlmZ  e j                  e      Zdede	dz  de	de
de	dz  d	dfd
Zde	d	edz  fdZy)    N)Path)HF_HUB_CACHEfolder_path	subfolderrepo_idprivatetokenreturnc                     t        j                  ||      st        j                  |||       t        j                  || ||       t        j                  d|        y)ah  Push a model folder to the huggingface hub, including model card.

    :param folder_path: The path to the folder.
    :param subfolder: The subfolder to push to.
        If None, the folder will be pushed to the root of the repo.
    :param repo_id: The repo name.
    :param private: Whether the repo is private.
    :param token: The huggingface token.
    )r   r	   )r	   r   )r   r   r	   path_in_repozPushed model to N)huggingface_hubrepo_existscreate_repoupload_folderloggerinfo)r   r   r   r   r	   s        i/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/model2vec/persistence/hf.pypush_folder_to_hubr   
   sR     &&weD##G5'J !!'{RWfop
KK"7),-    model_idc                 2   | j                  d      dk7  ryt        t              }| j                  dd      }|d| z  dz  }|j	                         sy|j                         D cg c]  }|j                         s| }}|syt        |d       }|S c c}w )	zGets the latest model path for a given identifier from the hugging face hub cache.

    Returns None if there is no cached model. In this case, the model will be downloaded.
    /   Nz--zmodels--	snapshotsc                 6    | j                         j                  S )N)statst_mtime)ps    r   <lambda>z-maybe_get_cached_model_path.<locals>.<lambda>6   s    16683D3Dr   )key)countr   r   replaceexistsiterdiris_dirmax)r   	cache_dir
normalizedrepo_dirr   r   latest_snapshots          r   maybe_get_cached_model_pathr+      s     ~~ca\"I!!#t,JXj\22[@H?? %,,.=.q!((*.I= ))DEO >s   %B;B)loggingpathlibr   r   huggingface_hub.constantsr   	getLogger__name__r   strboolr   r+    r   r   <module>r4      sy       2			8	$.."%*.7:.EI.RUX\R\.	.*# $+ r   