Skip to content

Commit

Permalink
feat: Added the VertexAiResourceNoun.to_dict() method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ark-kun committed Aug 4, 2021
1 parent 193ef7d commit a46a0be
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions google/cloud/aiplatform/base.py
Expand Up @@ -44,6 +44,7 @@
from google.cloud.aiplatform import initializer
from google.cloud.aiplatform import utils
from google.cloud.aiplatform.compat.types import encryption_spec as gca_encryption_spec
from google.protobuf import json_format

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

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

def to_dict(self) -> dict:
"""Returns the resource proto as a dictionary."""
return json_format.MessageToDict(self.gca_resource._pb)


def optional_sync(
construct_object_on_arg: Optional[str] = None,
Expand Down

0 comments on commit a46a0be

Please sign in to comment.