
    (^i
                        U d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ erd dlmZ  e	       5 Zd dlZddd        ed	       G d
 d             Zerd dlmZ  ed      Zded<   yy# 1 sw Y   5xY w)    )annotations)BytesIO)TYPE_CHECKING)experimental_class)
try_import)ArtifactNotFound)BinaryIONz3.4.0c                  >    e Zd ZdZ	 d	 	 	 	 	 ddZd	dZd
dZddZy)GCSArtifactStorea|  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                    t         j                          || _        |xs( t        j                  j
                  j                         | _        | j                  j                  |      | _	        y N)
_importscheckbucket_namegooglecloudstorageClientclientbucket
bucket_obj)selfr   r   s      V/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/artifacts/_gcs.py__init__zGCSArtifactStore.__init__;   sK    
 	&= 4 4 ; ; =++,,[9    c                    | j                   j                  |      }|t        d| j                   d| d      |j	                         }t        |      S )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_readerzGCSArtifactStore.open_readerE   sc    ''4<"01A1A0B/R]Q^ _  
 %%'t}r   c                |    | j                   j                  |      }|j                         }|j                  |       y r   )r   r    readupload_from_string)r   r   content_bodyr    datas        r   writezGCSArtifactStore.writeQ   s2    ##K0  "%r   c                :    | j                   j                  |       y r   )r   delete_blob)r   r   s     r   removezGCSArtifactStore.removeV   s    ##K0r   r   )r   strr   z"google.cloud.storage.Client | NonereturnNone)r   r,   r-   
'BinaryIO')r   r,   r&   r/   r-   r.   )r   r,   r-   r.   )__name__
__module____qualname____doc__r   r"   r(   r+    r   r   r   r      s=    %T 6::: 3: 
	:
&
1r   r   )ArtifactStore r5   _)
__future__r   ior   typingr   optuna._experimentalr   optuna._importsr   optuna.artifacts.exceptionsr   r	   r   google.cloud.storager   r   optuna.artifacts._protocolr5   r7   __annotations__r4   r   r   <module>rA      s    "    3 & 8 \  X  GD1 D1 D1N  9'+A}+ Y   s   A..A7