Skip to content

Commit a6f6192

Browse files
authored
Add support for custom networking in AQUA Model Deployments (#1298)
1 parent 411a47c commit a6f6192

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

ads/aqua/modeldeployment/deployment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def create(
189189
freeform_tags (Optional[Dict]): Freeform tags for model deployment.
190190
defined_tags (Optional[Dict]): Defined tags for model deployment.
191191
deployment_type (Optional[str]): The type of model deployment.
192+
subnet_id (Optional[str]): The custom egress for model deployment.
192193
193194
Returns
194195
-------
@@ -1150,6 +1151,7 @@ def _create_deployment(
11501151
log_group_id=create_deployment_details.log_group_id,
11511152
log_id=create_deployment_details.predict_log_id,
11521153
)
1154+
.with_subnet_id(create_deployment_details.subnet_id)
11531155
)
11541156
if (
11551157
create_deployment_details.memory_in_gbs

ads/aqua/modeldeployment/entities.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class AquaDeployment(Serializable):
132132
cmd: Optional[List[str]] = Field(
133133
default_factory=list, description="The cmd of the model deployment."
134134
)
135+
subnet_id: Optional[str] = Field(
136+
None, description="The custom egress for model deployment."
137+
)
135138

136139
@classmethod
137140
def from_oci_model_deployment(
@@ -210,6 +213,7 @@ def from_oci_model_deployment(
210213
private_endpoint_id = getattr(
211214
instance_configuration, "private_endpoint_id", UNKNOWN
212215
)
216+
subnet_id = getattr(instance_configuration, "subnet_id", UNKNOWN)
213217

214218
return AquaDeployment(
215219
id=oci_model_deployment.id,
@@ -235,6 +239,7 @@ def from_oci_model_deployment(
235239
tags=tags,
236240
environment_variables=environment_variables,
237241
cmd=cmd,
242+
subnet_id=subnet_id,
238243
)
239244

240245
class Config:
@@ -803,6 +808,9 @@ class CreateModelDeploymentDetails(ModelDeploymentDetails):
803808
deployment_type: Optional[str] = Field(
804809
None, description="The type of model deployment."
805810
)
811+
subnet_id: Optional[str] = Field(
812+
None, description="The custom egress for model deployment."
813+
)
806814

807815
@model_validator(mode="before")
808816
@classmethod

ads/aqua/server/aqua_spec.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ components:
10921092
type: string
10931093
nullable: true
10941094
example: "private-endpoint-ocid-001"
1095+
subnet_id:
1096+
type: string
1097+
nullable: true
1098+
example: "subnet-ocid-001"
10951099
console_link:
10961100
type: string
10971101
example: "https://console.example.com/model-deployments/deployment-ocid-001"
@@ -1180,6 +1184,9 @@ components:
11801184
private_endpoint_id:
11811185
type: string
11821186
example: "ocid1.datasciencemodeldeploymentprivatendpoint.oc1..<UNIQUEID>"
1187+
subnet_id:
1188+
type: string
1189+
example: "ocid1.subnet.oc1.iad..<UNIQUEID>"
11831190
cmd_var:
11841191
type: string
11851192
example: "ocid1.compartment.oc1..<UNIQUEID>"

tests/unitary/with_extras/aqua/test_deployment.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
from importlib import reload
1313
from unittest.mock import MagicMock, patch
1414

15-
from ads.aqua.modeldeployment.constants import DEFAULT_POLL_INTERVAL, DEFAULT_WAIT_TIME
16-
from ads.model.datascience_model_group import DataScienceModelGroup
17-
from ads.model.service.oci_datascience_model_deployment import (
18-
OCIDataScienceModelDeployment,
19-
)
2015
import oci
2116
import pytest
2217
from oci.data_science.models import (
@@ -56,6 +51,7 @@
5651
)
5752
from ads.aqua.modeldeployment.model_group_config import BaseModelSpec, ModelGroupConfig
5853
from ads.model.datascience_model import DataScienceModel
54+
from ads.model.datascience_model_group import DataScienceModelGroup
5955
from ads.model.deployment.model_deployment import ModelDeployment
6056
from ads.model.model_metadata import ModelCustomMetadata
6157
from ads.model.service.oci_datascience_model_deployment import (
@@ -525,6 +521,7 @@ class TestDataset:
525521
"created_by": "ocid1.user.oc1..<OCID>",
526522
"endpoint": MODEL_DEPLOYMENT_URL,
527523
"private_endpoint_id": None,
524+
"subnet_id": None,
528525
"models": [],
529526
"model_id": "ocid1.datasciencemodel.oc1.<region>.<OCID>",
530527
"environment_variables": {
@@ -555,6 +552,7 @@ class TestDataset:
555552
"created_by": "ocid1.user.oc1..<OCID>",
556553
"endpoint": MODEL_DEPLOYMENT_URL,
557554
"private_endpoint_id": None,
555+
"subnet_id": None,
558556
"models": [
559557
{
560558
"env_var": {},

0 commit comments

Comments
 (0)