Skip to content

Commit 3ed4acd

Browse files
authored
Added the VertexAiResourceNoun.to_dict() method
This method allows getting the resource metadata as a standard Python dictionary. Without this method, any user who would want to do this would have to access private fields.
1 parent 193ef7d commit 3ed4acd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

google/cloud/aiplatform/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from google.cloud.aiplatform import initializer
4545
from google.cloud.aiplatform import utils
4646
from google.cloud.aiplatform.compat.types import encryption_spec as gca_encryption_spec
47+
from google.protobuf import json_format
4748

4849
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
4950

@@ -607,6 +608,10 @@ def _assert_gca_resource_is_available(self) -> None:
607608
def __repr__(self) -> str:
608609
return f"{object.__repr__(self)} \nresource name: {self.resource_name}"
609610

611+
def to_dict(self) -> dict:
612+
"""Returns the resource proto as a dictionary."""
613+
return json_format.MessageToDict(self.gca_resource._pb)
614+
610615

611616
def optional_sync(
612617
construct_object_on_arg: Optional[str] = None,

0 commit comments

Comments
 (0)