Skip to content

Commit

Permalink
Fix error where Vertex endpoints with the same name is not deduped (#…
Browse files Browse the repository at this point in the history
…4514)

* Fix error where Vertex endpoints with the same name is not deduped

PiperOrigin-RevId: 409465659

* Update README.md

* Update RELEASE.md

Co-authored-by: tfx-team <tensorflow-extended-nonhuman@googlegroups.com>
  • Loading branch information
rtg0795 and tfx-copybara authored Dec 7, 2021
1 parent b55ab2e commit 7fa8695
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ but other *untested* combinations may also work.
tfx | apache-beam[gcp] | ml-metadata | pyarrow | tensorflow | tensorflow-data-validation | tensorflow-metadata | tensorflow-model-analysis | tensorflow-serving-api | tensorflow-transform | tfx-bsl
------------------------------------------------------------------------- | ---------------- | ----------- | ------- | ----------------- | -------------------------- | ------------------- | ------------------------- | ---------------------- | -------------------- | -------
[GitHub master](https://github.com/tensorflow/tfx/blob/master/RELEASE.md) | 2.32.0 | 1.3.0 | 2.0.0 | nightly (1.x/2.x) | 1.3.0 | 1.2.0 | 0.34.1 | 2.6.0 | 1.3.0 | 1.3.0
1.3.4 | 2.32.0 | 1.3.0 | 2.0.0 | 1.15.0 / 2.6.0 | 1.3.0 | 1.2.0 | 0.34.1 | 2.6.0 | 1.3.0 | 1.3.0
1.3.3 | 2.32.0 | 1.3.0 | 2.0.0 | 1.15.0 / 2.6.0 | 1.3.0 | 1.2.0 | 0.34.1 | 2.6.0 | 1.3.0 | 1.3.0
1.3.2 | 2.32.0 | 1.3.0 | 2.0.0 | 1.15.0 / 2.6.0 | 1.3.0 | 1.2.0 | 0.34.1 | 2.6.0 | 1.3.0 | 1.3.0
1.3.1 | 2.32.0 | 1.3.0 | 2.0.0 | 1.15.0 / 2.6.0 | 1.3.0 | 1.2.0 | 0.34.1 | 2.6.0 | 1.3.0 | 1.3.0
Expand Down
7 changes: 4 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Version 1.3.3
# Version 1.3.4

## Major Features and Improvements

* N/A

## Breaking Changes

### For Pipeline Authors

* N/A
Expand All @@ -17,8 +19,7 @@
* N/A

## Bug Fixes and Other Changes

* Depends on `tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,<2.7`.
* Fixed error where Vertex Endpoints of the same name is not deduped

## Documentation Updates

Expand Down
24 changes: 13 additions & 11 deletions tfx/extensions/google_cloud_ai_platform/prediction_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,21 +500,23 @@ def create_model_for_aip_prediction_if_not_exist(
Raises:
RuntimeError if endpoint creation failed.
"""
endpoint_name = ai_platform_serving_args['endpoint_name']
endpoint_labels = {**ai_platform_serving_args.get('labels', {}),
**labels}
endpoint = None
endpoint_name = ai_platform_serving_args['endpoint_name']
try:
endpoint = aiplatform.Endpoint.create(
display_name=endpoint_name, labels=endpoint_labels)
except errors.HttpError as e:
# If the error is to create an already existing endpoint,
# it's ok to ignore.
if e.resp.status == 409:
logging.warn('Endpoint %s already exists', endpoint_name)
else:
self._get_endpoint(ai_platform_serving_args)
except RuntimeError:
# Endpoint doesn't exist
endpoint_labels = {**ai_platform_serving_args.get('labels', {}),
**labels}
try:
endpoint = aiplatform.Endpoint.create(
display_name=endpoint_name, labels=endpoint_labels)
except errors.HttpError as e:
raise RuntimeError(
'Creating endpoint in AI Platform failed.') from e
else:
logging.warn('Endpoint %s already exists', endpoint_name)

return endpoint is not None

def delete_model_from_aip_if_exists(
Expand Down
12 changes: 7 additions & 5 deletions tfx/extensions/google_cloud_ai_platform/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _setUpVertexPredictionMocks(self):

self._mock_endpoint_list = mock.Mock()
aiplatform.Endpoint.list = self._mock_endpoint_list
self._mock_endpoint_list.return_value = [self._mock_endpoint]
self._mock_endpoint_list.return_value = []

self._mock_model_upload = mock.Mock()
aiplatform.Model.upload = self._mock_model_upload
Expand Down Expand Up @@ -642,6 +642,7 @@ def testDeleteModelForAIPPrediction(self, mock_discovery):

def testDeployModelForVertexPrediction(self):
self._setUpVertexPredictionMocks()
self._mock_endpoint_list.side_effect = [[], [self._mock_endpoint]]

runner.deploy_model_for_aip_prediction(
serving_path=self._serving_path,
Expand Down Expand Up @@ -673,6 +674,7 @@ def testDeployModelForVertexPrediction(self):

def testDeployModelForVertexPredictionError(self):
self._setUpVertexPredictionMocks()
self._mock_endpoint_list.side_effect = [[], [self._mock_endpoint]]

self._mock_model_deploy.side_effect = errors.HttpError(
httplib2.Response(info={'status': 429}), b'')
Expand Down Expand Up @@ -715,11 +717,9 @@ def testCreateVertexModel(self):
ai_platform_serving_args=self._ai_platform_serving_args_vertex,
enable_vertex=True))

def testCreateVertexEndpointCreateError(self):
def testCreateVertexEndpointCreateErrorAlreadyExist(self):
self._setUpVertexPredictionMocks()

self._mock_endpoint_create.side_effect = (
errors.HttpError(httplib2.Response(info={'status': 409}), b''))
self._mock_endpoint_list.return_value = [self._mock_endpoint]

self.assertFalse(
runner.create_model_for_aip_prediction_if_not_exist(
Expand All @@ -729,6 +729,7 @@ def testCreateVertexEndpointCreateError(self):

def testDeployModelForVertexPredictionWithCustomRegion(self):
self._setUpVertexPredictionMocks()
self._mock_endpoint_list.side_effect = [[], [self._mock_endpoint]]

self._mock_init = mock.Mock()
aiplatform.init = self._mock_init
Expand All @@ -751,6 +752,7 @@ def testDeployModelForVertexPredictionWithCustomRegion(self):

def testDeployModelForVertexPredictionWithCustomMachineType(self):
self._setUpVertexPredictionMocks()
self._mock_endpoint_list.side_effect = [[], [self._mock_endpoint]]

self._ai_platform_serving_args_vertex[
'machine_type'] = 'custom_machine_type'
Expand Down
2 changes: 1 addition & 1 deletion tfx/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""Contains the version string of TFX."""

# Note that setup.py uses this version.
__version__ = '1.3.3'
__version__ = '1.3.4'

0 comments on commit 7fa8695

Please sign in to comment.