Skip to content

Commit b902ae5

Browse files
committed
added container runtime param instead of changing MC display name
1 parent 7db3ca8 commit b902ae5

File tree

3 files changed

+65
-9
lines changed

3 files changed

+65
-9
lines changed

ads/aqua/model/model.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def create(
151151
compartment_id: Optional[str] = None,
152152
freeform_tags: Optional[Dict] = None,
153153
defined_tags: Optional[Dict] = None,
154-
display_name: Optional[str] = None,
155154
**kwargs,
156155
) -> DataScienceModel:
157156
"""
@@ -170,8 +169,6 @@ def create(
170169
Freeform tags for the model.
171170
defined_tags : Optional[Dict]
172171
Defined tags for the model.
173-
display_name: ptional[str]
174-
The display name of the custom model.
175172
176173
Returns
177174
-------
@@ -207,15 +204,11 @@ def create(
207204
**(defined_tags or {}),
208205
}
209206

210-
if display_name:
211-
service_model.display_name = display_name
212-
213207
custom_model = (
214208
DataScienceModel()
215209
.with_compartment_id(target_compartment)
216210
.with_project_id(target_project)
217211
.with_model_file_description(json_dict=service_model.model_file_description)
218-
.with_display_name(service_model.display_name)
219212
.with_description(service_model.description)
220213
.with_freeform_tags(**combined_freeform_tags)
221214
.with_defined_tags(**combined_defined_tags)

ads/aqua/modeldeployment/deployment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ def create(
227227
)
228228
aqua_model = model_app.create(
229229
model_id=create_deployment_details.model_id,
230-
display_name=create_deployment_details.model_name,
231230
compartment_id=compartment_id,
232231
project_id=project_id,
233232
freeform_tags=freeform_tags,
@@ -758,6 +757,7 @@ def _create_deployment(
758757
.with_image(container_image_uri)
759758
.with_server_port(server_port)
760759
.with_health_check_port(health_check_port)
760+
.with_custom_model_name(create_deployment_details.model_name)
761761
.with_env(env_var)
762762
.with_deployment_mode(ModelDeploymentMode.HTTPS)
763763
.with_model_uri(aqua_model_id)

ads/model/deployment/model_deployment_runtime.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8; -*-
32

43
# Copyright (c) 2023 Oracle and/or its affiliates.
54
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/from typing import Dict
65

76

87
from typing import Dict, List
8+
99
from ads.jobs.builders.base import Builder
1010

1111
MODEL_DEPLOYMENT_RUNTIME_KIND = "runtime"
@@ -519,6 +519,8 @@ class ModelDeploymentContainerRuntime(ModelDeploymentRuntime):
519519
The server port of model deployment container runtime.
520520
health_check_port: int
521521
The health check port of model deployment container runtime.
522+
custom_model_name : str
523+
The custom model name for single model deployment, to be used in predict calls
522524
523525
Methods
524526
-------
@@ -534,6 +536,8 @@ class ModelDeploymentContainerRuntime(ModelDeploymentRuntime):
534536
Sets the server port of model deployment container runtime
535537
with_health_check_port(health_check_port)
536538
Sets the health check port of model deployment container runtime
539+
with_custom_model_name(custom_model_name)
540+
Sets a custom model name for single model deployment, to be used in predict calls
537541
538542
Examples
539543
--------
@@ -560,6 +564,7 @@ class ModelDeploymentContainerRuntime(ModelDeploymentRuntime):
560564
CONST_SERVER_PORT = "serverPort"
561565
CONST_HEALTH_CHECK_PORT = "healthCheckPort"
562566
CONST_INFERENCE_SERVER = "inferenceServer"
567+
CONST_CUSTOM_MODEL_NAME = "customModelName"
563568

564569
attribute_map = {
565570
**ModelDeploymentRuntime.attribute_map,
@@ -570,6 +575,7 @@ class ModelDeploymentContainerRuntime(ModelDeploymentRuntime):
570575
CONST_SERVER_PORT: "server_port",
571576
CONST_HEALTH_CHECK_PORT: "health_check_port",
572577
CONST_INFERENCE_SERVER: "inference_server",
578+
CONST_CUSTOM_MODEL_NAME: "custom_model_name",
573579
}
574580

575581
payload_attribute_map = {
@@ -580,6 +586,7 @@ class ModelDeploymentContainerRuntime(ModelDeploymentRuntime):
580586
CONST_ENTRYPOINT: f"{ModelDeploymentRuntime.ENVIRONMENT_CONFIG_DETAILS_PATH}.entrypoint",
581587
CONST_SERVER_PORT: f"{ModelDeploymentRuntime.ENVIRONMENT_CONFIG_DETAILS_PATH}.server_port",
582588
CONST_HEALTH_CHECK_PORT: f"{ModelDeploymentRuntime.ENVIRONMENT_CONFIG_DETAILS_PATH}.health_check_port",
589+
CONST_CUSTOM_MODEL_NAME: f"{ModelDeploymentRuntime.ENVIRONMENT_CONFIG_DETAILS_PATH}.custom_model_name",
583590
}
584591

585592
@property
@@ -820,6 +827,62 @@ def with_inference_server(
820827
"""
821828
return self.set_spec(self.CONST_INFERENCE_SERVER, inference_server.lower())
822829

830+
@property
831+
def custom_model_name(self) -> str:
832+
"""Returns the custom model name.
833+
834+
Returns
835+
-------
836+
str
837+
The custom model name.
838+
"""
839+
return self.get_spec(self.CONST_CUSTOM_MODEL_NAME, None)
840+
841+
def with_custom_model_name(
842+
self, custom_model_name: str = "odsc-llm"
843+
) -> "ModelDeploymentContainerRuntime":
844+
"""Sets the custom model name. Defaults to odsc-llm if you do not set the custom model name.
845+
846+
Parameters
847+
----------
848+
custom_model_name: str
849+
Set the custom model name to be used for inferencing.
850+
851+
Returns
852+
-------
853+
ModelDeploymentContainerRuntime
854+
The ModelDeploymentContainerRuntime instance (self).
855+
856+
Example
857+
-------
858+
>>> from ads.model.deployment import ModelDeployment, ModelDeploymentContainerRuntime, ModelDeploymentInfrastructure
859+
>>> import ads
860+
>>> ads.set_auth("resource_principal")
861+
>>> infrastructure = ModelDeploymentInfrastructure()\
862+
... .with_project_id(<project_id>)\
863+
... .with_compartment_id(<comparment_id>)\
864+
... .with_shape_name("VM.Standard.E4.Flex")\
865+
... .with_replica(2)\
866+
... .with_bandwidth_mbps(10)\
867+
... .with_access_log(log_group_id=<deployment_log_group_id>, log_id=<deployment_access_log_id>)\
868+
... .with_predict_log(log_group_id=<deployment_log_group_id>, log_id=<deployment_predict_log_id>)
869+
870+
>>> runtime = ModelDeploymentContainerRuntime()\
871+
... .with_image(<container_image>)\
872+
... .with_server_port(<server_port>)\
873+
... .with_health_check_port(<health_check_port>)\
874+
... .with_model_uri(<model_id>)\
875+
... .with_env({"key":"value", "key2":"value2"})\
876+
... .with_inference_server("triton")
877+
>>> deployment = ModelDeployment()\
878+
... .with_display_name("Triton Example")\
879+
... .with_infrastructure(infrastructure)\
880+
... .with_runtime(runtime)
881+
.with_custom_model_name("myModel")
882+
>>> deployment.deploy()
883+
"""
884+
return self.set_spec(self.CONST_CUSTOM_MODEL_NAME, custom_model_name)
885+
823886
def init(self, **kwargs) -> "ModelDeploymentContainerRuntime":
824887
"""Initializes a starter specification for the runtime.
825888

0 commit comments

Comments
 (0)