
    -ji
                       % S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  \(       a  S SKJr  \	" 5        rS SKrSSS5        \" S	5       " S
 S5      5       r\(       a  S SKJr  \" S5      rS\S'   gg! , (       d  f       N?= f)    )annotations)BytesIO)TYPE_CHECKING)experimental_class)
try_import)ArtifactNotFound)BinaryIONz3.4.0c                  P    \ rS rSrSr S	     S
S jjrSS jrSS jrSS jrSr	g)GCSArtifactStore   a  An artifact backend for Google Cloud Storage (GCS).

Args:
    bucket_name:
        The name of the bucket to store artifacts.

    client:
        A google-cloud-storage ``Client`` to use for storage operations. If not specified, a
        new client will be created with default settings.

Example:
    .. code-block:: python

        import optuna
        from optuna.artifacts import GCSArtifactStore, upload_artifact


        artifact_backend = GCSArtifactStore("my-bucket")


        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 ...

    Before running this code, you will have to install ``gcloud`` and run

    .. code-block:: bash

        gcloud auth application-default login

    so that the Cloud Storage library can automatically find the credential.
Nc                    [         R                  5         Xl        U=(       d(    [        R                  R
                  R                  5       U l        U R                  R                  U5      U l	        g N)
_importscheckbucket_namegooglecloudstorageClientclientbucket
bucket_obj)selfr   r   s      O/home/james-whalen/.local/lib/python3.13/site-packages/optuna/artifacts/_gcs.py__init__GCSArtifactStore.__init__;   sI    
 	&= 4 4 ; ; =++,,[9    c                    U R                   R                  U5      nUc  [        SU R                   SU S35      eUR	                  5       n[        U5      $ )NzArtifact storage with bucket: z, artifact_id: z was not found)r   get_blobr   r   download_as_bytesr   )r   artifact_idblobbodys       r   open_readerGCSArtifactStore.open_readerE   sc    ''4<"01A1A0B/R]Q^ _  
 %%'t}r   c                |    U R                   R                  U5      nUR                  5       nUR                  U5        g r   )r   r"   readupload_from_string)r   r!   content_bodyr"   datas        r   writeGCSArtifactStore.writeQ   s2    ##K0  "%r   c                :    U R                   R                  U5        g r   )r   delete_blob)r   r!   s     r   removeGCSArtifactStore.removeV   s    ##K0r   )r   r   r   r   )r   strr   z"google.cloud.storage.Client | NonereturnNone)r!   r1   r2   
'BinaryIO')r!   r1   r)   r4   r2   r3   )r!   r1   r2   r3   )
__name__
__module____qualname____firstlineno____doc__r   r$   r+   r/   __static_attributes__ r   r   r   r      s=    %T 6::: 3: 
	:
&
1r   r   )ArtifactStore r<   _)
__future__r   ior   typingr   optuna._experimentalr   optuna._importsr   optuna.artifacts.exceptionsr   r	   r   google.cloud.storager   r   optuna.artifacts._protocolr<   r>   __annotations__r;   r   r   <module>rH      sw    "    3 & 8 \X  GD1 D1 D1N  9'+A}+ Y \s   A88
B