Skip to content

Commit feeb54d

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: expose PSC for OpenModel
PiperOrigin-RevId: 856418756
1 parent 33fe72a commit feeb54d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/unit/vertexai/model_garden/test_model_garden.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,30 @@ def test_batch_prediction_success(self, batch_prediction_mock):
14061406
timeout=None,
14071407
)
14081408

1409+
def test_deploy_with_psc_success(self, deploy_mock):
1410+
"""Tests deploying a model with Private Service Connect."""
1411+
aiplatform.init(
1412+
project=_TEST_PROJECT,
1413+
location=_TEST_LOCATION,
1414+
)
1415+
model = model_garden.OpenModel(model_name=_TEST_MODEL_FULL_RESOURCE_NAME)
1416+
model.deploy(
1417+
enable_private_service_connect=True,
1418+
psc_project_allow_list=["project-1", "project-2"],
1419+
)
1420+
deploy_mock.assert_called_once_with(
1421+
types.DeployRequest(
1422+
publisher_model_name=_TEST_MODEL_FULL_RESOURCE_NAME,
1423+
destination=f"projects/{_TEST_PROJECT}/locations/{_TEST_LOCATION}",
1424+
endpoint_config=types.DeployRequest.EndpointConfig(
1425+
private_service_connect_config=types.PrivateServiceConnectConfig(
1426+
enable_private_service_connect=True,
1427+
project_allowlist=["project-1", "project-2"],
1428+
)
1429+
),
1430+
)
1431+
)
1432+
14091433
def test_check_license_agreement_status_success(
14101434
self, check_license_agreement_status_mock
14111435
):

vertexai/model_garden/_model_garden.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ def deploy(
416416
serving_container_health_probe_exec: Optional[Sequence[str]] = None,
417417
serving_container_health_probe_period_seconds: Optional[int] = None,
418418
serving_container_health_probe_timeout_seconds: Optional[int] = None,
419+
enable_private_service_connect: bool = False,
420+
psc_project_allow_list: Optional[Sequence[str]] = None,
419421
) -> aiplatform.Endpoint:
420422
"""Deploys an Open Model to an endpoint.
421423
@@ -550,6 +552,10 @@ def deploy(
550552
serving_container_health_probe_timeout_seconds (int): Optional. Number
551553
of seconds after which the health probe times out. Defaults to 1
552554
second. Minimum value is 1.
555+
enable_private_service_connect (bool): Whether to enable private service
556+
connect.
557+
psc_project_allow_list (Sequence[str]): The list of projects that are
558+
allowed to access the endpoint over private service connect.
553559
554560
Returns:
555561
endpoint (aiplatform.Endpoint):
@@ -618,6 +624,14 @@ def deploy(
618624
dedicated_endpoint_disabled
619625
)
620626

627+
if enable_private_service_connect and psc_project_allow_list:
628+
request.endpoint_config.private_service_connect_config = (
629+
types.PrivateServiceConnectConfig(
630+
enable_private_service_connect=enable_private_service_connect,
631+
project_allowlist=psc_project_allow_list,
632+
)
633+
)
634+
621635
if fast_tryout_enabled:
622636
request.deploy_config.fast_tryout_enabled = fast_tryout_enabled
623637

0 commit comments

Comments
 (0)