Skip to content

Commit

Permalink
feat: Add PrivateEndpoint class and HTTP methods (#1033)
Browse files Browse the repository at this point in the history
* Add `network` to SDK initializer

* Add urllib3 to library requirements

* Fix network init() docstrings

* Update Model/Endpoint docs to use top namespace

* Add core Private Endpoint wrapper

* Drop logs, add URI props

* Lint, update typing for Prediction class

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Add bug refs, test stubs, minor fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* test commit

* adding examples, slight changes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding deployed model check:
q

* adding deployed model check

* minor changes, adding error catching for explanations

* testing to get other fields

* removing edge case

* adding print statement for debugging explain

* using GET instead of POST for explain

* using GET instead of POST for explain

* using GET instead of POST for explain

* removing explain for now, adding model id

* removing explain for now, adding model id

* removing explain for now, adding model id

* cleaned and added docstrings

* adding explain back

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* removing explain until working

* cleaning up docstrings

* create test done, working on predict

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* added unit tests for PrivateEndpoint

* test debugging

* fixing unit tests

* adding fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* formatting encryption_spec_key_name

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fixing comments

* adjusting traffic for private endpoint

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adjusting traffic for private endpoint

* adjusting traffic for private endpoint

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding fixes

* added delete for private Endpoint

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fixing traffic percentage

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* using network instead of class, moving exceptions

* cleaning up docstrings

* adding fixes, delete testing

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding fixes

* adding Raises section to private Endpoint docstrings

* added private Endpoint check in init, added to testing

* added private Endpoint check in init, added to testing

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding try/except inside functions, fixing tests, misc fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* reverting _validate_deploy_args method

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fixed type hint

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* lint issue

* lint issue

* adding system tests

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding system test changes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding shared_state to system test

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* trying outside import

* putting imports back inside

* added system test changes

* added system test changes

* adding fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fixing system test and init fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding fixes

* adding fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* adding fixes

* adding fixes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* added global network arg to associated classes

* style formatting

* docstring fixes

* adding extra info to network arg docstring

* adding extra info to network arg docstring

* removing changes to noxfile

* reverting noxfile

* reverting noxfile

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* reverting job files to not include global network

* reverting initalizer to not include global network config

* removing global network config

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* added fix and test to models

* added fix and test to models

* simplifying delete method

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: nayaknishant <[email protected]>
Co-authored-by: sasha-gitg <[email protected]>
  • Loading branch information
4 people authored Jun 28, 2022
1 parent caa41ae commit 425a32f
Show file tree
Hide file tree
Showing 8 changed files with 1,329 additions and 232 deletions.
2 changes: 2 additions & 0 deletions google/cloud/aiplatform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
)
from google.cloud.aiplatform import metadata
from google.cloud.aiplatform.models import Endpoint
from google.cloud.aiplatform.models import PrivateEndpoint
from google.cloud.aiplatform.models import Model
from google.cloud.aiplatform.model_evaluation import ModelEvaluation
from google.cloud.aiplatform.jobs import (
Expand Down Expand Up @@ -136,6 +137,7 @@
"Model",
"ModelEvaluation",
"PipelineJob",
"PrivateEndpoint",
"SequenceToSequencePlusForecastingTrainingJob",
"TabularDataset",
"Tensorboard",
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/aiplatform/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def init(
Raises:
ValueError:
If experiment_description is provided but experiment is not.
If experiment_tensorboard is provided but expeirment is not.
If experiment_tensorboard is provided but experiment is not.
"""

if experiment_description and experiment is None:
Expand Down
1,186 changes: 963 additions & 223 deletions google/cloud/aiplatform/models.py

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@
"pandas >= 1.0.0",
"pyarrow >= 6.0.1",
]
pipelines_extra_requires = [
pipelines_extra_require = [
"pyyaml>=5.3,<6",
]
datasets_extra_require = [
"pyarrow >= 3.0.0, < 8.0dev",
]
private_endpoints_extra_require = [
"urllib3 >=1.21.1, <1.27",
]
full_extra_require = list(
set(
tensorboard_extra_require
+ metadata_extra_require
+ xai_extra_require
+ lit_extra_require
+ featurestore_extra_require
+ pipelines_extra_requires
+ pipelines_extra_require
+ datasets_extra_require
+ private_endpoints_extra_require
)
)
testing_extra_require = (
Expand Down Expand Up @@ -118,7 +122,9 @@
"xai": xai_extra_require,
"lit": lit_extra_require,
"cloud_profiler": profiler_extra_require,
"pipelines": pipelines_extra_requires,
"pipelines": pipelines_extra_require,
"datasets": datasets_extra_require,
"private_endpoints": private_endpoints_extra_require,
},
python_requires=">=3.7",
classifiers=[
Expand Down
1 change: 0 additions & 1 deletion tests/system/aiplatform/e2e_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def tear_down_resources(self, shared_state: Dict[str, Any]):
yield

# TODO(b/218310362): Add resource deletion system tests

# Bring all Endpoints to the front of the list
# Ensures Models are undeployed first before we attempt deletion
shared_state["resources"].sort(
Expand Down
69 changes: 69 additions & 0 deletions tests/system/aiplatform/test_private_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pytest

from google.cloud import aiplatform

from tests.system.aiplatform import e2e_base

# permanent_custom_mnist_model
_MODEL_ID = "6430031960164270080"
_PRIVATE_ENDPOINT_NETWORK = "projects/580378083368/global/networks/private-endpoint-vpc"


@pytest.mark.usefixtures("tear_down_resources")
class TestPrivateEndpoint(e2e_base.TestEndToEnd):

_temp_prefix = "temp_vertex_sdk_e2e"

def test_create_deploy_delete_private_endpoint(self, shared_state):
# Collection of resources generated by this test, to be deleted during teardown
shared_state["resources"] = []

aiplatform.init(
project=e2e_base._PROJECT,
location=e2e_base._LOCATION,
)

private_endpoint = aiplatform.PrivateEndpoint.create(
display_name=self._make_display_name("private_endpoint_test"),
network=_PRIVATE_ENDPOINT_NETWORK,
)
shared_state["resources"].append(private_endpoint)

# Verify that the retrieved private Endpoint is the same
my_private_endpoint = aiplatform.PrivateEndpoint(
endpoint_name=private_endpoint.resource_name
)
assert private_endpoint.resource_name == my_private_endpoint.resource_name
assert private_endpoint.display_name == my_private_endpoint.display_name

# Verify the endpoint is in the private Endpoint list
list_private_endpoint = aiplatform.PrivateEndpoint.list()
assert private_endpoint.resource_name in [
private_endpoint.resource_name for private_endpoint in list_private_endpoint
]

# Retrieve permanent model, deploy to private Endpoint, then undeploy
my_model = aiplatform.Model(model_name=_MODEL_ID)

my_private_endpoint.deploy(model=my_model)
assert my_private_endpoint._gca_resource.deployed_models

deployed_model_id = my_private_endpoint.list_models()[0].id
my_private_endpoint.undeploy(deployed_model_id=deployed_model_id)
assert not my_private_endpoint._gca_resource.deployed_models
Loading

0 comments on commit 425a32f

Please sign in to comment.