Skip to content

Commit 999af55

Browse files
wuliang229copybara-github
authored andcommitted
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 <wuliang@google.com> PiperOrigin-RevId: 831124463
1 parent 22ca7ee commit 999af55

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/google/adk/artifacts/gcs_artifact_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from typing import Any
2828
from typing import Optional
2929

30-
from google.cloud import storage
3130
from google.genai import types
3231
from typing_extensions import override
3332

@@ -47,6 +46,8 @@ def __init__(self, bucket_name: str, **kwargs):
4746
bucket_name: The name of the bucket to use.
4847
**kwargs: Keyword arguments to pass to the Google Cloud Storage client.
4948
"""
49+
from google.cloud import storage
50+
5051
self.bucket_name = bucket_name
5152
self.storage_client = storage.Client(**kwargs)
5253
self.bucket = self.storage_client.bucket(self.bucket_name)

0 commit comments

Comments
 (0)