
    -jip	                        % S SK Jr  S SKrS SKJr  S SKrS SKJr  S SKJ	r	  \(       a  S SKJ
r
   " S S5      r\(       a  S S	KJr  \" S
5      rS\S'   gg)    )annotationsN)Path)TYPE_CHECKING)ArtifactNotFound)BinaryIOc                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)FileSystemArtifactStore   a!  An artifact store for file systems.

Args:
    base_path:
        The base path to a directory to store artifacts.

Example:
    .. code-block:: python

        import os

        import optuna
        from optuna.artifacts import FileSystemArtifactStore
        from optuna.artifacts import upload_artifact


        base_path = "./artifacts"
        os.makedirs(base_path, exist_ok=True)
        artifact_store = FileSystemArtifactStore(base_path=base_path)


        def objective(trial: optuna.Trial) -> float:
            ... = trial.suggest_float("x", -10, 10)
            file_path = generate_example(...)
            upload_artifact(
                artifact_store=artifact_store,
                file_path=file_path,
                study_or_trial=trial,
            )
            return ...
c                P    [        U[        5      (       a  [        U5      nXl        g )N)
isinstancestrr   
_base_path)self	base_paths     V/home/james-whalen/.local/lib/python3.13/site-packages/optuna/artifacts/_filesystem.py__init__ FileSystemArtifactStore.__init__0   s    i%%YI#    c                    [         R                  R                  U R                  U5      n [	        US5      nU$ ! [
         a  n[        S5      UeS nAff = f)Nrb	not found)ospathjoinr   openFileNotFoundErrorr   )r   artifact_idfilepathfes        r   open_reader#FileSystemArtifactStore.open_reader6   sQ    77<<=	7Xt$A  ! 	7";/Q6	7s   : 
AAAc                    [         R                  R                  U R                  U5      n[	        US5       n[
        R                  " X$5        S S S 5        g ! , (       d  f       g = f)Nwb)r   r   r   r   r   shutilcopyfileobj)r   r   content_bodyr   r   s        r   writeFileSystemArtifactStore.write>   s@    77<<=(D!Q|/ "!!s   A
A%c                    [         R                  R                  U R                  U5      n [         R                  " U5        g ! [
         a  n[        S5      UeS nAff = f)Nr   )r   r   r   r   remover   r   )r   r   r   r    s       r   r+   FileSystemArtifactStore.removeC   sH    77<<=	7IIh  	7";/Q6	7s   A 
AAA)r   N)r   z
str | PathreturnNone)r   r   r-   r   )r   r   r'   r   r-   r.   )r   r   r-   r.   )
__name__
__module____qualname____firstlineno____doc__r   r!   r(   r+   __static_attributes__ r   r   r	   r	      s    @$0
7r   r	   )ArtifactStore r6   _)
__future__r   r   pathlibr   r%   typingr   optuna.artifacts.exceptionsr   r   r	   optuna.artifacts._protocolr6   r8   __annotations__r5   r   r   <module>r?      sH    " 	     8 97 97x  9.r2A}2 r   