@@ -1304,7 +1304,8 @@ def from_id(cls, id: str) -> "ModelDeployment":
1304
1304
ModelDeployment
1305
1305
The ModelDeployment instance (self).
1306
1306
"""
1307
- return cls ()._update_from_oci_model (OCIDataScienceModelDeployment .from_id (id ))
1307
+ oci_model = OCIDataScienceModelDeployment .from_id (id )
1308
+ return cls (properties = oci_model )._update_from_oci_model (oci_model )
1308
1309
1309
1310
@classmethod
1310
1311
def from_dict (cls , obj_dict : Dict ) -> "ModelDeployment" :
@@ -1503,7 +1504,9 @@ def _build_model_deployment_details(self) -> CreateModelDeploymentDetails:
1503
1504
** create_model_deployment_details
1504
1505
).to_oci_model (CreateModelDeploymentDetails )
1505
1506
1506
- def _update_model_deployment_details (self , ** kwargs ) -> UpdateModelDeploymentDetails :
1507
+ def _update_model_deployment_details (
1508
+ self , ** kwargs
1509
+ ) -> UpdateModelDeploymentDetails :
1507
1510
"""Builds UpdateModelDeploymentDetails from model deployment instance.
1508
1511
1509
1512
Returns
@@ -1527,7 +1530,7 @@ def _update_model_deployment_details(self, **kwargs) -> UpdateModelDeploymentDet
1527
1530
return OCIDataScienceModelDeployment (
1528
1531
** update_model_deployment_details
1529
1532
).to_oci_model (UpdateModelDeploymentDetails )
1530
-
1533
+
1531
1534
def _update_spec (self , ** kwargs ) -> "ModelDeployment" :
1532
1535
"""Updates model deployment specs from kwargs.
1533
1536
@@ -1542,7 +1545,7 @@ def _update_spec(self, **kwargs) -> "ModelDeployment":
1542
1545
Model deployment freeform tags
1543
1546
defined_tags: (dict)
1544
1547
Model deployment defined tags
1545
-
1548
+
1546
1549
Additional kwargs arguments.
1547
1550
Can be any attribute that `ads.model.deployment.ModelDeploymentCondaRuntime`, `ads.model.deployment.ModelDeploymentContainerRuntime`
1548
1551
and `ads.model.deployment.ModelDeploymentInfrastructure` accepts.
@@ -1559,20 +1562,22 @@ def _update_spec(self, **kwargs) -> "ModelDeployment":
1559
1562
specs = {
1560
1563
"self" : self ._spec ,
1561
1564
"runtime" : self .runtime ._spec ,
1562
- "infrastructure" : self .infrastructure ._spec
1565
+ "infrastructure" : self .infrastructure ._spec ,
1563
1566
}
1564
1567
sub_set = {
1565
1568
self .infrastructure .CONST_ACCESS_LOG ,
1566
1569
self .infrastructure .CONST_PREDICT_LOG ,
1567
- self .infrastructure .CONST_SHAPE_CONFIG_DETAILS
1570
+ self .infrastructure .CONST_SHAPE_CONFIG_DETAILS ,
1568
1571
}
1569
1572
for spec_value in specs .values ():
1570
1573
for key in spec_value :
1571
1574
if key in converted_specs :
1572
1575
if key in sub_set :
1573
1576
for sub_key in converted_specs [key ]:
1574
1577
converted_sub_key = ads_utils .snake_to_camel (sub_key )
1575
- spec_value [key ][converted_sub_key ] = converted_specs [key ][sub_key ]
1578
+ spec_value [key ][converted_sub_key ] = converted_specs [key ][
1579
+ sub_key
1580
+ ]
1576
1581
else :
1577
1582
spec_value [key ] = copy .deepcopy (converted_specs [key ])
1578
1583
self = (
@@ -1616,14 +1621,14 @@ def _build_model_deployment_configuration_details(self) -> Dict:
1616
1621
infrastructure .CONST_MEMORY_IN_GBS : infrastructure .shape_config_details .get (
1617
1622
"memory_in_gbs" , None
1618
1623
)
1619
- or infrastructure .shape_config_details .get (
1620
- "memoryInGBs" , None
1621
- )
1624
+ or infrastructure .shape_config_details .get ("memoryInGBs" , None )
1622
1625
or DEFAULT_MEMORY_IN_GBS ,
1623
1626
}
1624
1627
1625
1628
if infrastructure .subnet_id :
1626
- instance_configuration [infrastructure .CONST_SUBNET_ID ] = infrastructure .subnet_id
1629
+ instance_configuration [
1630
+ infrastructure .CONST_SUBNET_ID
1631
+ ] = infrastructure .subnet_id
1627
1632
1628
1633
scaling_policy = {
1629
1634
infrastructure .CONST_POLICY_TYPE : "FIXED_SIZE" ,
@@ -1638,13 +1643,11 @@ def _build_model_deployment_configuration_details(self) -> Dict:
1638
1643
1639
1644
model_id = runtime .model_uri
1640
1645
if not model_id .startswith ("ocid" ):
1641
-
1642
1646
from ads .model .datascience_model import DataScienceModel
1643
-
1647
+
1644
1648
dsc_model = DataScienceModel (
1645
1649
name = self .display_name ,
1646
- compartment_id = self .infrastructure .compartment_id
1647
- or COMPARTMENT_OCID ,
1650
+ compartment_id = self .infrastructure .compartment_id or COMPARTMENT_OCID ,
1648
1651
project_id = self .infrastructure .project_id or PROJECT_OCID ,
1649
1652
artifact = runtime .model_uri ,
1650
1653
).create (
@@ -1653,7 +1656,7 @@ def _build_model_deployment_configuration_details(self) -> Dict:
1653
1656
region = runtime .region ,
1654
1657
overwrite_existing_artifact = runtime .overwrite_existing_artifact ,
1655
1658
remove_existing_artifact = runtime .remove_existing_artifact ,
1656
- timeout = runtime .timeout
1659
+ timeout = runtime .timeout ,
1657
1660
)
1658
1661
model_id = dsc_model .id
1659
1662
0 commit comments