GeezerVison is showing github.com — fix: EntityType RPC update returns the updated EntityType - not an LRO. · googleapis/python-aiplatform@8f9c714
File treeExpand file treeCollapse file tree Open diff view settings google/cloud/aiplatform/featurestore
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform/featurestore/_entity_type.py +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -249,18 +249,15 @@ def update( | 249 | 249 | self, | 250 | 250 | ) | 251 | 251 |
| 252 | | - update_entity_type_lro = self.api_client.update_entity_type( | | 252 | + updated_entity_type = self.api_client.update_entity_type( | 253 | 253 | entity_type=gapic_entity_type, | 254 | 254 | update_mask=update_mask, | 255 | 255 | metadata=request_metadata, | 256 | 256 | timeout=update_request_timeout, | 257 | 257 | ) | 258 | 258 |
| 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 | 264 | 261 |
| 265 | 262 | _LOGGER.log_action_completed_against_resource("entityType", "updated", self) | 266 | 263 |
| |
Collapse file Copy file name to clipboardExpand all lines: tests/system/aiplatform/test_featurestore.py +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 | _TEST_FEATURESTORE_ID = "movie_prediction" | 37 | 37 | _TEST_USER_ENTITY_TYPE_ID = "users" | 38 | 38 | _TEST_MOVIE_ENTITY_TYPE_ID = "movies" | | 39 | +_TEST_MOVIE_ENTITY_TYPE_UPDATE_LABELS = {"my_key_update": "my_value_update"} | 39 | 40 |
| 40 | 41 | _TEST_USER_AGE_FEATURE_ID = "age" | 41 | 42 | _TEST_USER_GENDER_FEATURE_ID = "gender" | @@ -129,6 +130,15 @@ def test_create_get_list_entity_types(self, shared_state): | 129 | 130 | entity_type.resource_name for entity_type in list_entity_types | 130 | 131 | ] | 131 | 132 |
| | 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 | + | 132 | 142 | def test_create_get_list_features(self, shared_state): | 133 | 143 |
| 134 | 144 | assert shared_state["user_entity_type"] | |
Collapse file Copy file name to clipboardExpand all lines: tests/unit/aiplatform/test_featurestores.py +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -591,8 +591,10 @@ def update_entity_type_mock(): | 591 | 591 | with patch.object( | 592 | 592 | featurestore_service_client.FeaturestoreServiceClient, "update_entity_type" | 593 | 593 | ) 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 | + ) | 596 | 598 | yield update_entity_type_mock | 597 | 599 |
| 598 | 600 |
| @@ -2104,6 +2106,8 @@ def test_update_entity_type(self, update_entity_type_mock): | 2104 | 2106 | timeout=None, | 2105 | 2107 | ) | 2106 | 2108 |
| | 2109 | + assert my_entity_type.labels == _TEST_LABELS_UPDATE | | 2110 | + | 2107 | 2111 | @pytest.mark.parametrize( | 2108 | 2112 | "featurestore_name", [_TEST_FEATURESTORE_NAME, _TEST_FEATURESTORE_ID] | 2109 | 2113 | ) | |
|