L i UddlmZddlmZddlmZddlmZddlm Z ddl m Z erddlm Z e 5Z ddlZddded Gd d Zerdd lmZed Zded<yy#1swY5xYw)) annotations)BytesIO) TYPE_CHECKING)experimental_class) try_import)ArtifactNotFound)BinaryIONz3.4.0c>eZdZdZ d ddZd dZd dZd dZy) 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. Nctj||_|xs(tjj j |_|jj||_ yN) _importscheck bucket_namegooglecloudstorageClientclientbucket bucket_obj)selfrrs [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/artifacts/_gcs.py__init__zGCSArtifactStore.__init__;sK &= 4 4 ; ; = ++,,[9c|jj|}|td|jd|d|j }t |S)NzArtifact storage with bucket: z, artifact_id: z was not found)rget_blobrrdownload_as_bytesr)r artifact_idblobbodys r open_readerzGCSArtifactStore.open_readerEsc'' 4 <"01A1A0B/R]Q^_  %%'t}rc||jj|}|j}|j|yr )rr readupload_from_string)rr content_bodyr datas rwritezGCSArtifactStore.writeQs2##K0  " %rc:|jj|yr )r delete_blob)rrs rremovezGCSArtifactStore.removeVs ##K0rr )rstrrz"google.cloud.storage.Client | NonereturnNone)rr,r- 'BinaryIO')rr,r&r/r-r.)rr,r-r.)__name__ __module__ __qualname____doc__rr"r(r+rrr r s=%T6:::3:  : & 1rr ) ArtifactStorer5_) __future__riortypingroptuna._experimentalroptuna._importsroptuna.artifacts.exceptionsrr rgoogle.cloud.storagerr optuna.artifacts._protocolr5r7__annotations__r4rrrAs" 3&8\ X GD1D1D1N9'+A}+ Y  s A..A7