Skip to content

Commit 8f9c714

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: EntityType RPC update returns the updated EntityType - not an LRO.
PiperOrigin-RevId: 527003565
1 parent 0b3dac9 commit 8f9c714

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

google/cloud/aiplatform/featurestore/_entity_type.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,15 @@ def update(
249249
self,
250250
)
251251

252-
update_entity_type_lro = self.api_client.update_entity_type(
252+
updated_entity_type = self.api_client.update_entity_type(
253253
entity_type=gapic_entity_type,
254254
update_mask=update_mask,
255255
metadata=request_metadata,
256256
timeout=update_request_timeout,
257257
)
258258

259-
_LOGGER.log_action_started_against_resource_with_lro(
260-
"Update", "entityType", self.__class__, update_entity_type_lro
261-
)
262-
263-
update_entity_type_lro.result()
259+
# Update underlying resource with response data.
260+
self._gca_resource = updated_entity_type
264261

265262
_LOGGER.log_action_completed_against_resource("entityType", "updated", self)
266263

tests/system/aiplatform/test_featurestore.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
_TEST_FEATURESTORE_ID = "movie_prediction"
3737
_TEST_USER_ENTITY_TYPE_ID = "users"
3838
_TEST_MOVIE_ENTITY_TYPE_ID = "movies"
39+
_TEST_MOVIE_ENTITY_TYPE_UPDATE_LABELS = {"my_key_update": "my_value_update"}
3940

4041
_TEST_USER_AGE_FEATURE_ID = "age"
4142
_TEST_USER_GENDER_FEATURE_ID = "gender"
@@ -129,6 +130,15 @@ def test_create_get_list_entity_types(self, shared_state):
129130
entity_type.resource_name for entity_type in list_entity_types
130131
]
131132

133+
# Update information about the movie entity type.
134+
assert movie_entity_type.labels != _TEST_MOVIE_ENTITY_TYPE_UPDATE_LABELS
135+
136+
movie_entity_type.update(
137+
labels=_TEST_MOVIE_ENTITY_TYPE_UPDATE_LABELS,
138+
)
139+
140+
assert movie_entity_type.labels == _TEST_MOVIE_ENTITY_TYPE_UPDATE_LABELS
141+
132142
def test_create_get_list_features(self, shared_state):
133143

134144
assert shared_state["user_entity_type"]

tests/unit/aiplatform/test_featurestores.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,10 @@ def update_entity_type_mock():
591591
with patch.object(
592592
featurestore_service_client.FeaturestoreServiceClient, "update_entity_type"
593593
) as update_entity_type_mock:
594-
update_entity_type_lro_mock = mock.Mock(operation.Operation)
595-
update_entity_type_mock.return_value = update_entity_type_lro_mock
594+
update_entity_type_mock.return_value = gca_entity_type.EntityType(
595+
name=_TEST_ENTITY_TYPE_NAME,
596+
labels=_TEST_LABELS_UPDATE,
597+
)
596598
yield update_entity_type_mock
597599

598600

@@ -2104,6 +2106,8 @@ def test_update_entity_type(self, update_entity_type_mock):
21042106
timeout=None,
21052107
)
21062108

2109+
assert my_entity_type.labels == _TEST_LABELS_UPDATE
2110+
21072111
@pytest.mark.parametrize(
21082112
"featurestore_name", [_TEST_FEATURESTORE_NAME, _TEST_FEATURESTORE_ID]
21092113
)

0 commit comments

Comments
 (0)