Skip to content

Commit 8dcb254

Browse files
committed
Updated pr.
1 parent bc57a23 commit 8dcb254

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

ads/aqua/modeldeployment/deployment.py

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
AquaDeploymentDetail,
6161
ConfigurationItem,
6262
ConfigValidationError,
63-
CreateModelDeploymentDetails,
6463
ModelDeploymentConfigSummary,
65-
UpdateModelDeploymentDetails,
64+
ModelDeploymentCreateSpec,
65+
ModelDeploymentUpdateSpec,
6666
)
6767
from ads.aqua.modeldeployment.utils import MultiModelDeploymentConfigLoader
6868
from ads.common.object_storage_details import ObjectStorageDetails
@@ -120,16 +120,16 @@ class AquaDeploymentApp(AquaApp):
120120
@telemetry(entry_point="plugin=deployment&action=create", name="aqua")
121121
def create(
122122
self,
123-
create_deployment_details: Optional[CreateModelDeploymentDetails] = None,
123+
create_deployment_details: Optional[ModelDeploymentCreateSpec] = None,
124124
**kwargs,
125125
) -> "AquaDeployment":
126126
"""
127127
Creates a new Aqua model deployment.\n
128128
For detailed information about CLI flags see: https://github.com/oracle-samples/oci-data-science-ai-samples/blob/main/ai-quick-actions/cli-tips.md#create-model-deployment
129129
130130
Args:
131-
create_deployment_details : CreateModelDeploymentDetails, optional
132-
An instance of CreateModelDeploymentDetails containing all required and optional
131+
create_deployment_details : ModelDeploymentCreateSpec, optional
132+
An instance of ModelDeploymentCreateSpec containing all required and optional
133133
fields for creating a model deployment via Aqua.
134134
kwargs:
135135
instance_shape (str): The instance shape used for deployment.
@@ -166,7 +166,7 @@ def create(
166166
# Build deployment details from kwargs if not explicitly provided.
167167
if create_deployment_details is None:
168168
try:
169-
create_deployment_details = CreateModelDeploymentDetails(**kwargs)
169+
create_deployment_details = ModelDeploymentCreateSpec(**kwargs)
170170
except ValidationError as ex:
171171
custom_errors = build_pydantic_error_message(ex)
172172
raise AquaValueError(
@@ -316,7 +316,7 @@ def create(
316316
def _create(
317317
self,
318318
aqua_model: DataScienceModel,
319-
create_deployment_details: CreateModelDeploymentDetails,
319+
create_deployment_details: ModelDeploymentCreateSpec,
320320
container_config: Dict,
321321
) -> AquaDeployment:
322322
"""Builds the configurations required by single model deployment and creates the deployment.
@@ -325,8 +325,8 @@ def _create(
325325
----------
326326
aqua_model : DataScienceModel
327327
An instance of Aqua data science model.
328-
create_deployment_details : CreateModelDeploymentDetails
329-
An instance of CreateModelDeploymentDetails containing all required and optional
328+
create_deployment_details : ModelDeploymentCreateSpec
329+
An instance of ModelDeploymentCreateSpec containing all required and optional
330330
fields for creating a model deployment via Aqua.
331331
container_config: Dict
332332
Container config dictionary.
@@ -345,7 +345,7 @@ def _create(
345345
env_var,
346346
tags,
347347
cmd_var,
348-
) = self._get_container_details(
348+
) = self._get_runtime_config_from_model_deployment(
349349
aqua_model=aqua_model,
350350
deployment_details=create_deployment_details,
351351
container_config=container_config,
@@ -364,12 +364,10 @@ def _create(
364364
cmd_var=cmd_var,
365365
)
366366

367-
def _get_container_details(
367+
def _get_runtime_config_from_model_deployment(
368368
self,
369369
aqua_model: DataScienceModel,
370-
deployment_details: Union[
371-
CreateModelDeploymentDetails, UpdateModelDeploymentDetails
372-
],
370+
deployment_details: Union[ModelDeploymentCreateSpec, ModelDeploymentUpdateSpec],
373371
container_config: Dict,
374372
):
375373
"""Gets required or optional configurations for building container runtime of model deployment.
@@ -378,8 +376,8 @@ def _get_container_details(
378376
----------
379377
aqua_model: DataScienceModel
380378
An instance of Aqua data science model.
381-
deployment_details: Union[CreateModelDeploymentDetails, UpdateModelDeploymentDetails]
382-
An instance of either CreateModelDeploymentDetails or UpdateModelDeploymentDetails containing all required and optional
379+
deployment_details: Union[ModelDeploymentCreateSpec, ModelDeploymentUpdateSpec]
380+
An instance of either ModelDeploymentCreateSpec or ModelDeploymentUpdateSpec containing all required and optional
383381
fields for creating or updating a model deployment via Aqua.
384382
container_config: Dict
385383
Container config dictionary.
@@ -608,7 +606,7 @@ def _create_multi(
608606
self,
609607
aqua_model: DataScienceModel,
610608
model_config_summary: ModelDeploymentConfigSummary,
611-
create_deployment_details: CreateModelDeploymentDetails,
609+
create_deployment_details: ModelDeploymentCreateSpec,
612610
container_config: AquaContainerConfig,
613611
) -> AquaDeployment:
614612
"""Builds the environment variables required by multi deployment container and creates the deployment.
@@ -619,8 +617,8 @@ def _create_multi(
619617
Summary Model Deployment configuration for the group of models.
620618
aqua_model : DataScienceModel
621619
An instance of Aqua data science model.
622-
create_deployment_details : CreateModelDeploymentDetails
623-
An instance of CreateModelDeploymentDetails containing all required and optional
620+
create_deployment_details : ModelDeploymentCreateSpec
621+
An instance of ModelDeploymentCreateSpec containing all required and optional
624622
fields for creating a model deployment via Aqua.
625623
container_config: Dict
626624
Container config dictionary.
@@ -752,7 +750,7 @@ def _create_multi(
752750

753751
def _create_deployment(
754752
self,
755-
create_deployment_details: CreateModelDeploymentDetails,
753+
create_deployment_details: ModelDeploymentCreateSpec,
756754
aqua_model_id: str,
757755
model_name: str,
758756
model_type: str,
@@ -767,8 +765,8 @@ def _create_deployment(
767765
768766
Parameters
769767
----------
770-
create_deployment_details : CreateModelDeploymentDetails
771-
An instance of CreateModelDeploymentDetails containing all required and optional
768+
create_deployment_details : ModelDeploymentCreateSpec
769+
An instance of ModelDeploymentCreateSpec containing all required and optional
772770
fields for creating a model deployment via Aqua.
773771
aqua_model_id: str
774772
The id of the aqua model to be deployed.
@@ -963,16 +961,16 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
963961
@telemetry(entry_point="plugin=deployment&action=update", name="aqua")
964962
def update(
965963
self,
966-
update_deployment_details: Optional[UpdateModelDeploymentDetails] = None,
964+
update_deployment_details: Optional[ModelDeploymentUpdateSpec] = None,
967965
**kwargs,
968966
) -> "AquaDeployment":
969967
"""
970968
Updates an Aqua model deployment.\n
971969
For detailed information about CLI flags see: https://github.com/oracle-samples/oci-data-science-ai-samples/blob/main/ai-quick-actions/cli-tips.md#update-model-deployment
972970
973971
Args:
974-
update_deployment_details : UpdateModelDeploymentDetails, optional
975-
An instance of UpdateModelDeploymentDetails containing all required and optional
972+
update_deployment_details : ModelDeploymentUpdateSpec, optional
973+
An instance of ModelDeploymentUpdateSpec containing all required and optional
976974
fields for updating a model deployment via Aqua.
977975
kwargs:
978976
deployment_id (str): The OCID of model deployment to be update.
@@ -1008,7 +1006,7 @@ def update(
10081006
# Build update deployment details from kwargs if not explicitly provided.
10091007
if update_deployment_details is None:
10101008
try:
1011-
update_deployment_details = UpdateModelDeploymentDetails(**kwargs)
1009+
update_deployment_details = ModelDeploymentUpdateSpec(**kwargs)
10121010
except ValidationError as ex:
10131011
custom_errors = build_pydantic_error_message(ex)
10141012
raise AquaValueError(
@@ -1096,7 +1094,7 @@ def _update(
10961094
self,
10971095
model: DataScienceModel,
10981096
model_deployment: ModelDeployment,
1099-
update_deployment_details: UpdateModelDeploymentDetails,
1097+
update_deployment_details: ModelDeploymentUpdateSpec,
11001098
):
11011099
"""Builds the configurations required by single model deployment and updates the deployment.
11021100
@@ -1106,8 +1104,8 @@ def _update(
11061104
An instance of Aqua data science model.
11071105
model_deployment : ModelDeployment
11081106
An instance of Aqua model deployment.
1109-
update_deployment_details : UpdateModelDeploymentDetails
1110-
An instance of UpdateModelDeploymentDetails containing all required and optional
1107+
update_deployment_details : ModelDeploymentUpdateSpec
1108+
An instance of ModelDeploymentUpdateSpec containing all required and optional
11111109
fields for updating a model deployment via Aqua.
11121110
"""
11131111
infrastructure = model_deployment.infrastructure
@@ -1174,7 +1172,7 @@ def _update(
11741172
env_var,
11751173
tags,
11761174
cmd_var,
1177-
) = self._get_container_details(
1175+
) = self._get_runtime_config_from_model_deployment(
11781176
aqua_model=model,
11791177
deployment_details=update_deployment_details,
11801178
container_config=self.get_container_config(),

ads/aqua/modeldeployment/entities.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class Config:
406406
extra = "allow"
407407

408408

409-
class ModelDeploymentBasicDetails(BaseModel):
409+
class ModelDeploymentSpec(BaseModel):
410410
"""Class for Aqua model deployments basic details."""
411411

412412
description: Optional[str] = Field(
@@ -483,7 +483,7 @@ class Config:
483483
extra = "ignore"
484484

485485

486-
class CreateModelDeploymentDetails(ModelDeploymentBasicDetails):
486+
class ModelDeploymentCreateSpec(ModelDeploymentSpec):
487487
"""Class for creating Aqua model deployments."""
488488

489489
instance_shape: str = Field(
@@ -676,7 +676,7 @@ class Config:
676676
protected_namespaces = ()
677677

678678

679-
class UpdateModelDeploymentDetails(ModelDeploymentBasicDetails):
679+
class ModelDeploymentUpdateSpec(ModelDeploymentSpec):
680680
"""Class for updating Aqua model deployments."""
681681

682682
deployment_id: str = Field(
@@ -688,4 +688,4 @@ class UpdateModelDeploymentDetails(ModelDeploymentBasicDetails):
688688
display_name: str = Field(None, description="The name of the model deployment.")
689689

690690
class Config:
691-
extra = "ignore"
691+
extra = "allow"

tests/unitary/with_extras/aqua/test_deployment.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
AquaDeploymentConfig,
4242
AquaDeploymentDetail,
4343
ConfigValidationError,
44-
CreateModelDeploymentDetails,
44+
ModelDeploymentCreateSpec,
4545
ModelDeploymentConfigSummary,
4646
ModelParams,
4747
)
@@ -1719,7 +1719,7 @@ def test_create_deployment_for_tei_byoc_embedding_model(
17191719
@patch("ads.model.deployment.model_deployment.ModelDeployment.deploy")
17201720
@patch("ads.aqua.modeldeployment.AquaDeploymentApp.get_deployment_config")
17211721
@patch(
1722-
"ads.aqua.modeldeployment.entities.CreateModelDeploymentDetails.validate_multimodel_deployment_feasibility"
1722+
"ads.aqua.modeldeployment.entities.ModelDeploymentCreateSpec.validate_multimodel_deployment_feasibility"
17231723
)
17241724
def test_create_deployment_for_multi_model(
17251725
self,
@@ -1840,7 +1840,9 @@ def test_create_deployment_for_multi_model(
18401840
assert actual_attributes == expected_result
18411841

18421842
@patch("ads.model.deployment.model_deployment.ModelDeployment.update")
1843-
@patch("ads.aqua.modeldeployment.AquaDeploymentApp._get_container_details")
1843+
@patch(
1844+
"ads.aqua.modeldeployment.AquaDeploymentApp._get_runtime_config_from_model_deployment"
1845+
)
18441846
@patch.object(AquaApp, "get_container_config")
18451847
@patch("ads.model.datascience_model.DataScienceModel.from_id")
18461848
@patch("ads.model.deployment.model_deployment.ModelDeployment.from_id")
@@ -1849,7 +1851,7 @@ def test_update_single_model_deployment(
18491851
mock_deployment,
18501852
mock_model,
18511853
mock_get_container_config,
1852-
mock_get_container_details,
1854+
mock_get_runtime_config_from_model_deployment,
18531855
mock_update,
18541856
):
18551857
mock_get_container_config.return_value = (
@@ -1880,7 +1882,7 @@ def test_update_single_model_deployment(
18801882
)
18811883
)
18821884

1883-
mock_get_container_details.return_value = (
1885+
mock_get_runtime_config_from_model_deployment.return_value = (
18841886
None,
18851887
None,
18861888
"dsmc://image-name:1.0.0.0",
@@ -2117,15 +2119,15 @@ def validate_multimodel_deployment_feasibility_helper(
21172119
for x in models
21182120
]
21192121

2120-
mock_create_deployment_details = CreateModelDeploymentDetails(
2122+
mock_create_deployment_details = ModelDeploymentCreateSpec(
21212123
models=aqua_models,
21222124
instance_shape=instance_shape,
21232125
display_name=display_name,
21242126
freeform_tags={Tags.MULTIMODEL_TYPE_TAG: "true"},
21252127
)
21262128
else:
21272129
model_id = "model_a"
2128-
mock_create_deployment_details = CreateModelDeploymentDetails(
2130+
mock_create_deployment_details = ModelDeploymentCreateSpec(
21292131
model_id=model_id,
21302132
instance_shape=instance_shape,
21312133
display_name=display_name,

0 commit comments

Comments
 (0)