o
    }o™i  ã                   @  sF   d dl mZ d dlZd dlZd dlmZ erd dlmZ ddd„ZdS )é    )ÚannotationsN)ÚTYPE_CHECKING)ÚArtifactStoreÚartifact_storer   Ú	file_pathÚstrÚartifact_idÚreturnÚNonec              	   C  s   t j |¡rtd|› ƒ‚|  |¡,}t|dƒ}t ||¡ W d  ƒ n1 s)w   Y  W d  ƒ dS W d  ƒ dS 1 sAw   Y  dS )a  Download an artifact from the artifact store.

    Args:
        artifact_store:
            An artifact store.
        file_path:
            A path to save the downloaded artifact.
        artifact_id:
            The identifier of the artifact to download.
    zFile already exists: ÚwbN)ÚosÚpathÚexistsÚFileExistsErrorÚopen_readerÚopenÚshutilÚcopyfileobj)r   r   r   ÚreaderÚwriter© r   úN/home/ubuntu/.local/lib/python3.10/site-packages/optuna/artifacts/_download.pyÚdownload_artifact   s
   Pÿr   )r   r   r   r   r   r   r	   r
   )	Ú
__future__r   r   r   Útypingr   Úoptuna.artifacts._protocolr   r   r   r   r   r   Ú<module>   s    