o
    Ďi                     @   s   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	 d dl
mZ d dlmZmZ d dlmZ e eZg d	Z	dd
dddededB dedB dedB def
ddZ			dd
ddedededB dedee eB dB dedB ddfddZdS )    N)ApiBlobType)registry)normalize_patternsupload_files_and_directories)parse_model_handle)EXTRA_CONSOLE_BLOCK)create_model_if_missing create_model_instance_or_version)sign_with_sigstore)z.git/z*/.git/z.cache/z.huggingface/Fforce_download
output_dirhandlepathr   r   returnc                C   s@   t | }tjd|  di td tj||||d\}}|S )a  Download model files.

    Args:
        handle: (string) the model handle.
        path: (string) Optional path to a file within the model bundle.
        force_download: (bool) Optional flag to force download a model, even if it's cached or already in output_dir.
        output_dir: (string) Optional output directory for direct download, bypassing the default cache.

    Returns:
        A string representing the path to the requested model files.
    zDownloading Model:  ...)extrar   )r   loggerinfoto_urlr   r   model_resolver)r   r   r   r   h_ r   L/home/jeff/fluffinator/venv/lib/python3.10/site-packages/kagglehub/models.pymodel_download   s   
r    sigstorelocal_model_dirlicense_nameversion_notesignore_patternsr   c          
      C   s   t | }td|  d | rd}t|t|j|j z	|r(t	||}W n t
y7   d}t
|dw t|tjtt|dd}	t||	|||d dS )	a%  Upload model files.

    Args:
        handle: (str) the model handle.
        local_model_dir: (str) path to a file in a local directory.
        license_name: (str) model license.
        version_notes: (str, optional) model versions.
        ignore_patterns (str or list[str], optional):
            Additional ignore patterns to DEFAULT_IGNORE_PATTERNS.
            Files matching any of the patterns are not uploaded.
            Patterns are standard wildcards that can be matched by
            https://docs.python.org/3/library/fnmatch.html.
            Use a pattern ending with "/" to ignore the whole dir,
            e.g., ".git/" is equivalent to ".git/*".
        sigstore: (bool, optional)
            Creates a trasparent ledger on sigstore. User must be an admin/editor of the model.
    zUploading Model r   z/The model handle should not include the versionzThe 'model_upload(...sign=True)' function requires the 'kagglehub[signing]' extras. Install them with 'pip install kagglehub[signing]'N)default
additional)	item_typer"   r   )r   r   r   r   is_versioned
ValueErrorr   ownermodelr
   ImportErrorr   r   MODELr   DEFAULT_IGNORE_PATTERNSr	   )
r   r   r    r!   r"   r   r   is_versioned_exceptionimport_warning_messagetokensr   r   r   model_upload/   s*   

	
r0   )N)Nr   N)logging&kagglesdk.blobs.types.blob_api_servicer   	kagglehubr   kagglehub.gcs_uploadr   r   kagglehub.handler   kagglehub.loggerr   kagglehub.models_helpersr   r	   kagglehub.signingr
   	getLogger__name__r   r,   strboolr   listr0   r   r   r   r   <module>   sZ    

 