From 999af5588005e7b29451bdbf9252265187ca992d Mon Sep 17 00:00:00 2001 From: Liang Wu Date: Tue, 11 Nov 2025 17:01:16 -0800 Subject: [PATCH] chore: Defer import of `google.cloud.storage` in `GCSArtifactService` The `google.cloud.storage` module is now imported within the `__init__` method of `GCSArtifactService`, rather than at the top level. This avoids importing the potentially heavy `storage` module unless an instance of `GCSArtifactService` is actually created. Co-authored-by: Liang Wu PiperOrigin-RevId: 831124463 --- src/google/adk/artifacts/gcs_artifact_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/google/adk/artifacts/gcs_artifact_service.py b/src/google/adk/artifacts/gcs_artifact_service.py index 1963f815..fc18dab6 100644 --- a/src/google/adk/artifacts/gcs_artifact_service.py +++ b/src/google/adk/artifacts/gcs_artifact_service.py @@ -27,7 +27,6 @@ import logging from typing import Any from typing import Optional -from google.cloud import storage from google.genai import types from typing_extensions import override @@ -47,6 +46,8 @@ class GcsArtifactService(BaseArtifactService): bucket_name: The name of the bucket to use. **kwargs: Keyword arguments to pass to the Google Cloud Storage client. """ + from google.cloud import storage + self.bucket_name = bucket_name self.storage_client = storage.Client(**kwargs) self.bucket = self.storage_client.bucket(self.bucket_name)