Skip to content

Commit b918f98

Browse files
committed
Support for PE on AQUA MD.
1 parent a0efd38 commit b918f98

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed

ads/aqua/extension/deployment_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def post(self, *args, **kwargs):
102102
ocpus = input_data.get("ocpus")
103103
memory_in_gbs = input_data.get("memory_in_gbs")
104104
model_file = input_data.get("model_file")
105+
private_endpoint_id = input_data.get("private_endpoint_id")
105106

106107
self.finish(
107108
AquaDeploymentApp().create(
@@ -124,6 +125,7 @@ def post(self, *args, **kwargs):
124125
ocpus=ocpus,
125126
memory_in_gbs=memory_in_gbs,
126127
model_file=model_file,
128+
private_endpoint_id=private_endpoint_id,
127129
)
128130
)
129131

ads/aqua/modeldeployment/deployment.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def create(
107107
memory_in_gbs: Optional[float] = None,
108108
ocpus: Optional[float] = None,
109109
model_file: Optional[str] = None,
110+
private_endpoint_id: Optional[str] = None,
110111
) -> "AquaDeployment":
111112
"""
112113
Creates a new Aqua deployment
@@ -153,6 +154,9 @@ def create(
153154
The ocpu count for the shape selected.
154155
model_file: str
155156
The file used for model deployment.
157+
private_endpoint_id: str
158+
The private endpoint id of model deployment.
159+
156160
Returns
157161
-------
158162
AquaDeployment
@@ -342,6 +346,7 @@ def create(
342346
.with_bandwidth_mbps(bandwidth_mbps)
343347
.with_replica(instance_count)
344348
.with_web_concurrency(web_concurrency)
349+
.with_private_endpoint_id(private_endpoint_id)
345350
.with_access_log(
346351
log_group_id=log_group_id,
347352
log_id=access_log_id,

ads/aqua/modeldeployment/entities.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AquaDeployment(DataClassSerializable):
4747
created_on: str = None
4848
created_by: str = None
4949
endpoint: str = None
50+
private_endpoint_id: str = None
5051
console_link: str = None
5152
lifecycle_details: str = None
5253
shape_info: field(default_factory=ShapeInfo) = None
@@ -98,6 +99,9 @@ def from_oci_model_deployment(
9899
freeform_tags = oci_model_deployment.freeform_tags or UNKNOWN_DICT
99100
aqua_service_model_tag = freeform_tags.get(Tags.AQUA_SERVICE_MODEL_TAG, None)
100101
aqua_model_name = freeform_tags.get(Tags.AQUA_MODEL_NAME_TAG, UNKNOWN)
102+
private_endpoint_id = (
103+
getattr(oci_model_deployment.model_deployment_configuration_details.model_configuration_details.instance_configuration, "private_endpoint_id", UNKNOWN)
104+
)
101105

102106
return AquaDeployment(
103107
id=oci_model_deployment.id,
@@ -113,6 +117,7 @@ def from_oci_model_deployment(
113117
created_on=str(oci_model_deployment.time_created),
114118
created_by=oci_model_deployment.created_by,
115119
endpoint=oci_model_deployment.model_deployment_url,
120+
private_endpoint_id=private_endpoint_id,
116121
console_link=get_console_link(
117122
resource="model-deployments",
118123
ocid=oci_model_deployment.id,

ads/model/deployment/model_deployment.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,18 @@ def _build_model_deployment_configuration_details(self) -> Dict:
16481648
infrastructure.CONST_SUBNET_ID
16491649
] = infrastructure.subnet_id
16501650

1651+
if infrastructure.private_endpoint_id:
1652+
if not hasattr(
1653+
oci.data_science.models.InstanceConfiguration, "private_endpoint_id"
1654+
):
1655+
raise EnvironmentError(
1656+
"Private endpoint is not supported in the current OCI SDK installed."
1657+
)
1658+
1659+
instance_configuration[
1660+
infrastructure.CONST_PRIVATE_ENDPOINT_ID
1661+
] = infrastructure.private_endpoint_id
1662+
16511663
scaling_policy = {
16521664
infrastructure.CONST_POLICY_TYPE: "FIXED_SIZE",
16531665
infrastructure.CONST_INSTANCE_COUNT: infrastructure.replica

ads/model/deployment/model_deployment_infrastructure.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class ModelDeploymentInfrastructure(Builder):
5757
The web concurrency of model deployment
5858
subnet_id: str
5959
The subnet id of model deployment
60+
private_endpoint_id: str
61+
The private endpoint id of model deployment
6062
6163
Methods
6264
-------
@@ -84,6 +86,8 @@ class ModelDeploymentInfrastructure(Builder):
8486
Sets the web concurrency of model deployment
8587
with_subnet_id(subnet_id)
8688
Sets the subnet id of model deployment
89+
with_private_endpoint_id(private_endpoint)
90+
Sets the private endpoint id of model deployment
8791
8892
Example
8993
-------
@@ -100,6 +104,7 @@ class ModelDeploymentInfrastructure(Builder):
100104
... .with_bandwidth_mbps(10)
101105
... .with_web_concurrency(10)
102106
... .with_subnet_id(<subnet_id>)
107+
... .with_private_endpoint_id(<private_endpoint_id>)
103108
... .with_access_log(
104109
... log_group_id=<log_group_id>,
105110
... log_id=<log_id>
@@ -143,6 +148,7 @@ class ModelDeploymentInfrastructure(Builder):
143148
CONST_WEB_CONCURRENCY = "webConcurrency"
144149
CONST_STREAM_CONFIG_DETAILS = "streamConfigurationDetails"
145150
CONST_SUBNET_ID = "subnetId"
151+
CONST_PRIVATE_ENDPOINT_ID = "privateEndpointId"
146152

147153
attribute_map = {
148154
CONST_PROJECT_ID: "project_id",
@@ -159,6 +165,7 @@ class ModelDeploymentInfrastructure(Builder):
159165
CONST_LOG_GROUP_ID: "log_group_id",
160166
CONST_WEB_CONCURRENCY: "web_concurrency",
161167
CONST_SUBNET_ID: "subnet_id",
168+
CONST_PRIVATE_ENDPOINT_ID: "private_endpoint_id",
162169
}
163170

164171
shape_config_details_attribute_map = {
@@ -186,6 +193,7 @@ class ModelDeploymentInfrastructure(Builder):
186193
CONST_SHAPE_NAME: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.instance_shape_name",
187194
CONST_SHAPE_CONFIG_DETAILS: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.model_deployment_instance_shape_config_details",
188195
CONST_SUBNET_ID: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.subnet_id",
196+
CONST_PRIVATE_ENDPOINT_ID: f"{MODEL_CONFIG_DETAILS_PATH}.instance_configuration.private_endpoint_id",
189197
CONST_REPLICA: f"{MODEL_CONFIG_DETAILS_PATH}.scaling_policy.instance_count",
190198
CONST_BANDWIDTH_MBPS: f"{MODEL_CONFIG_DETAILS_PATH}.bandwidth_mbps",
191199
CONST_ACCESS_LOG: "category_log_details.access",
@@ -613,6 +621,32 @@ def subnet_id(self) -> str:
613621
"""
614622
return self.get_spec(self.CONST_SUBNET_ID, None)
615623

624+
def with_private_endpoint_id(self, private_endpoint_id: str) -> "ModelDeploymentInfrastructure":
625+
"""Sets the private endpoint id of model deployment.
626+
627+
Parameters
628+
----------
629+
private_endpoint_id : str
630+
The private endpoint id of model deployment.
631+
632+
Returns
633+
-------
634+
ModelDeploymentInfrastructure
635+
The ModelDeploymentInfrastructure instance (self).
636+
"""
637+
return self.set_spec(self.CONST_PRIVATE_ENDPOINT_ID, private_endpoint_id)
638+
639+
@property
640+
def private_endpoint_id(self) -> str:
641+
"""The model deployment private endpoint id.
642+
643+
Returns
644+
-------
645+
str
646+
The model deployment private endpoint id.
647+
"""
648+
return self.get_spec(self.CONST_PRIVATE_ENDPOINT_ID, None)
649+
616650
def init(self, **kwargs) -> "ModelDeploymentInfrastructure":
617651
"""Initializes a starter specification for the ModelDeploymentInfrastructure.
618652

ads/model/generic_model.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,7 @@ def deploy(
22622262
description: Optional[str] = None,
22632263
deployment_instance_shape: Optional[str] = None,
22642264
deployment_instance_subnet_id: Optional[str] = None,
2265+
deployment_instance_private_endpoint_id: Optional[str] = None,
22652266
deployment_instance_count: Optional[int] = None,
22662267
deployment_bandwidth_mbps: Optional[int] = None,
22672268
deployment_log_group_id: Optional[str] = None,
@@ -2312,6 +2313,8 @@ def deploy(
23122313
The shape of the instance used for deployment.
23132314
deployment_instance_subnet_id: (str, optional). Default to None.
23142315
The subnet id of the instance used for deployment.
2316+
deployment_instance_private_endpoint_id: (str, optional). Default to None.
2317+
The private endpoint id of instance used for deployment.
23152318
deployment_instance_count: (int, optional). Defaults to 1.
23162319
The number of instance used for deployment.
23172320
deployment_bandwidth_mbps: (int, optional). Defaults to 10.
@@ -2432,6 +2435,8 @@ def deploy(
24322435
or self.properties.deployment_image,
24332436
deployment_instance_subnet_id=existing_infrastructure.subnet_id
24342437
or self.properties.deployment_instance_subnet_id,
2438+
deployment_instance_private_endpoint_id=existing_infrastructure.private_endpoint_id
2439+
or self.properties.deployment_instance_private_endpoint_id,
24352440
).to_dict()
24362441

24372442
property_dict.update(override_properties)
@@ -2465,6 +2470,7 @@ def deploy(
24652470
.with_shape_name(self.properties.deployment_instance_shape)
24662471
.with_replica(self.properties.deployment_instance_count)
24672472
.with_subnet_id(self.properties.deployment_instance_subnet_id)
2473+
.with_private_endpoint_id(self.properties.deployment_instance_private_endpoint_id)
24682474
)
24692475

24702476
web_concurrency = (
@@ -2611,6 +2617,7 @@ def prepare_save_deploy(
26112617
deployment_description: Optional[str] = None,
26122618
deployment_instance_shape: Optional[str] = None,
26132619
deployment_instance_subnet_id: Optional[str] = None,
2620+
deployment_instance_private_endpoint_id: Optional[str] = None,
26142621
deployment_instance_count: Optional[int] = None,
26152622
deployment_bandwidth_mbps: Optional[int] = None,
26162623
deployment_log_group_id: Optional[str] = None,
@@ -2701,6 +2708,8 @@ def prepare_save_deploy(
27012708
The shape of the instance used for deployment.
27022709
deployment_instance_subnet_id: (str, optional). Default to None.
27032710
The subnet id of the instance used for deployment.
2711+
deployment_instance_private_endpoint_id: (str, optional). Default to None.
2712+
The private endpoint id of instance used for deployment.
27042713
deployment_instance_count: (int, optional). Defaults to 1.
27052714
The number of instance used for deployment.
27062715
deployment_bandwidth_mbps: (int, optional). Defaults to 10.
@@ -2846,6 +2855,7 @@ def prepare_save_deploy(
28462855
description=deployment_description,
28472856
deployment_instance_shape=self.properties.deployment_instance_shape,
28482857
deployment_instance_subnet_id=self.properties.deployment_instance_subnet_id,
2858+
deployment_instance_private_endpoint_id=self.properties.deployment_instance_private_endpoint_id,
28492859
deployment_instance_count=self.properties.deployment_instance_count,
28502860
deployment_bandwidth_mbps=self.properties.deployment_bandwidth_mbps,
28512861
deployment_log_group_id=self.properties.deployment_log_group_id,

ads/model/model_properties.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ModelProperties(BaseProperties):
2929
overwrite_existing_artifact: bool = None
3030
deployment_instance_shape: str = None
3131
deployment_instance_subnet_id: str = None
32+
deployment_instance_private_endpoint_id: str = None
3233
deployment_instance_count: int = None
3334
deployment_bandwidth_mbps: int = None
3435
deployment_log_group_id: str = None

0 commit comments

Comments
 (0)