Skip to content

feature: Use gca_resource as repr and provide informative repr if asynchronous#291

Merged
sasha-gitg merged 2 commits into
googleapis:devfrom
sasha-gitg:add_repr
Apr 7, 2021
Merged

feature: Use gca_resource as repr and provide informative repr if asynchronous#291
sasha-gitg merged 2 commits into
googleapis:devfrom
sasha-gitg:add_repr

Conversation

@sasha-gitg
Copy link
Copy Markdown
Member

@sasha-gitg sasha-gitg commented Apr 6, 2021

Fixes b/182290998 🦕

@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 6, 2021
@sasha-gitg sasha-gitg changed the title feature: Use gca_resource as repr and provide informative repr if asy… feature: Use gca_resource as repr and provide informative repr if asynchronous Apr 6, 2021
Copy link
Copy Markdown
Contributor

@vinnysenthil vinnysenthil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one comment covering some concerns

Comment thread google/cloud/aiplatform/base.py Outdated
return self._gca_resource.display_name

def __repr__(self) -> str:
return repr(self._gca_resource)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we eventually replace this with a prettier representation when time permits?

Another concern is users trying to access fields shown in _gca_resource, for example:

ds = aiplatform.Dataset('7529226928591470592')
ds
name: "projects/580378083368/locations/us-central1/datasets/7529226928591470592"
display_name: "test_dataset_display_name"
metadata_schema_uri: "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml"
create_time {
  seconds: 1617354353
  nanos: 956444000
}
update_time {
  seconds: 1617354361
  nanos: 707254000
}
etag: "AMEw9yMYcQqy2DwtHCx2ObYHK52UFD7YsBNGZnYRA-d7Fnau376JsgwTnBkrqtBb8CXk"
labels {
  key: "aiplatform.googleapis.com/dataset_metadata_schema"
  value: "IMAGE"
}
metadata {
  struct_value {
    fields {
      key: "dataItemSchemaUri"
      value {
        string_value: "gs://google-cloud-aiplatform/schema/dataset/dataitem/image_1.0.0.yaml"
      }
    }
    fields {
      key: "gcsBucket"
      value {
        string_value: "cloud-ai-platform-62f88573-082b-416d-a1b7-e47dcc520767"
      }
    }
  }
}
ds.labels

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-7ef790277785> in <module>
----> 1 ds.labels

AttributeError: 'Dataset' object has no attribute 'labels'

@sasha-gitg sasha-gitg merged commit acd0a7c into googleapis:dev Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants