36
36
ModelCustomMetadataItem ,
37
37
ModelProvenanceMetadata ,
38
38
ModelTaxonomyMetadata ,
39
+ ModelBackupSetting ,
40
+ ModelRetentionSetting ,
41
+ ModelRetentionOperationDetails ,
42
+ ModelBackupOperationDetails
39
43
)
40
44
from ads .model .service .oci_datascience_model import (
41
45
ModelProvenanceNotFoundError ,
@@ -120,6 +124,19 @@ class DataScienceModel(Builder):
120
124
Model version id
121
125
model_file_description: dict
122
126
Contains object path details for models created by reference.
127
+ backup_setting: ModelBackupSetting
128
+ The value to assign to the backup_setting property of this CreateModelDetails.
129
+ retention_setting: ModelRetentionSetting
130
+ The value to assign to the retention_setting property of this CreateModelDetails.
131
+ retention_operation_details: ModelRetentionOperationDetails
132
+ The value to assign to the retention_operation_details property for the Model.
133
+ backup_operation_details: ModelBackupOperationDetails
134
+ The value to assign to the backup_operation_details property for the Model.
135
+
136
+
137
+
138
+
139
+
123
140
124
141
Methods
125
142
-------
@@ -178,7 +195,6 @@ class DataScienceModel(Builder):
178
195
Sets path details for models created by reference. Input can be either a dict, string or json file and
179
196
the schema is dictated by model_file_description_schema.json
180
197
181
-
182
198
Examples
183
199
--------
184
200
>>> ds_model = (DataScienceModel()
@@ -217,7 +233,12 @@ class DataScienceModel(Builder):
217
233
CONST_MODEL_VERSION_ID = "versionId"
218
234
CONST_TIME_CREATED = "timeCreated"
219
235
CONST_LIFECYCLE_STATE = "lifecycleState"
236
+ CONST_LIFECYCLE_DETAILS = "lifecycleDetails"
220
237
CONST_MODEL_FILE_DESCRIPTION = "modelDescription"
238
+ CONST_BACKUP_SETTING = "backupSetting"
239
+ CONST_RETENTION_SETTING = "retentionSetting"
240
+ CONST_BACKUP_OPERATION_DETAILS = "backupOperationDetails"
241
+ CONST_RETENTION_OPERATION_DETAILS = "retentionOperationDetails"
221
242
222
243
attribute_map = {
223
244
CONST_ID : "id" ,
@@ -239,7 +260,12 @@ class DataScienceModel(Builder):
239
260
CONST_MODEL_VERSION_ID : "version_id" ,
240
261
CONST_TIME_CREATED : "time_created" ,
241
262
CONST_LIFECYCLE_STATE : "lifecycle_state" ,
263
+ CONST_LIFECYCLE_DETAILS : "lifecycle_details" ,
242
264
CONST_MODEL_FILE_DESCRIPTION : "model_description" ,
265
+ CONST_BACKUP_SETTING : "backup_setting" ,
266
+ CONST_RETENTION_SETTING : "retention_setting" ,
267
+ CONST_BACKUP_OPERATION_DETAILS : "backup_operation_details" ,
268
+ CONST_RETENTION_OPERATION_DETAILS : "retention_operation_details"
243
269
}
244
270
245
271
def __init__ (self , spec : Dict = None , ** kwargs ) -> None :
@@ -685,6 +711,114 @@ def with_model_file_description(
685
711
686
712
return self .set_spec (self .CONST_MODEL_FILE_DESCRIPTION , json_data )
687
713
714
+ @property
715
+ def retention_setting (self ) -> ModelRetentionSetting :
716
+ """
717
+ Gets the retention_setting of this model.
718
+
719
+ :return: The retention_setting of this model.
720
+ :rtype: RetentionSetting
721
+ """
722
+ return self .get_spec (self .CONST_RETENTION_SETTING )
723
+
724
+ def with_retention_setting (self , retention_setting : Union [Dict , ModelRetentionSetting ]) -> "DataScienceModel" :
725
+ """
726
+ Sets the retention setting details for the model.
727
+
728
+ Parameters
729
+ ----------
730
+ retention_setting : Union[Dict, RetentionSetting]
731
+ The retention setting details for the model. Can be provided as either a dictionary or
732
+ an instance of the `RetentionSetting` class.
733
+
734
+ Returns
735
+ -------
736
+ DataScienceModel
737
+ The `DataScienceModel` instance (self) for method chaining.
738
+ """
739
+ if retention_setting and isinstance (retention_setting , dict ):
740
+ try :
741
+ retention_setting = ModelRetentionSetting .from_dict (retention_setting )
742
+ except Exception as err :
743
+ logger .warn (f"Failed to convert retention_setting from dict: { err } " )
744
+
745
+ return self .set_spec (self .CONST_RETENTION_SETTING , retention_setting )
746
+
747
+
748
+
749
+ @property
750
+ def backup_setting (self ) -> ModelBackupSetting :
751
+ """
752
+ Gets the backup_setting of this model.
753
+
754
+ :return: The backup_setting of this model.
755
+ :rtype: BackupSetting
756
+ """
757
+ return self .get_spec (self .CONST_BACKUP_SETTING )
758
+
759
+ def with_backup_setting (self , backup_setting : Union [Dict , ModelBackupSetting ]) -> "DataScienceModel" :
760
+ """
761
+ Sets the model's backup setting details.
762
+
763
+ Parameters
764
+ ----------
765
+ backup_setting : Union[Dict, BackupSetting]
766
+ The backup setting details for the model. This can be passed as either a dictionary or
767
+ an instance of the `BackupSetting` class.
768
+
769
+ Returns
770
+ -------
771
+ DataScienceModel
772
+ The `DataScienceModel` instance (self) for method chaining.
773
+ """
774
+ if backup_setting and isinstance (backup_setting , dict ):
775
+ try :
776
+ backup_setting = ModelBackupSetting .from_dict (backup_setting )
777
+ except Exception as err :
778
+ logger .warn (f"Failed to convert backup_setting from dict: { err } " )
779
+
780
+ return self .set_spec (self .CONST_BACKUP_SETTING , backup_setting )
781
+
782
+ @property
783
+ def retention_operation_details (self ) -> ModelRetentionOperationDetails :
784
+ """
785
+ Gets the retention_operation_details of this Model using the spec constant.
786
+
787
+ :return: The retention_operation_details of this Model.
788
+ :rtype: ModelRetentionOperationDetails
789
+ """
790
+ return self .get_spec (self .CONST_RETENTION_OPERATION_DETAILS )
791
+
792
+ @retention_operation_details .setter
793
+ def retention_operation_details (self , retention_operation_details : ModelRetentionOperationDetails ) -> "DataScienceModel" :
794
+ """
795
+ Sets the retention_operation_details of this Model using the spec constant.
796
+
797
+ :param retention_operation_details: The retention_operation_details of this Model.
798
+ :type: ModelRetentionOperationDetails
799
+ """
800
+ return self .set_spec (self .CONST_RETENTION_OPERATION_DETAILS , retention_operation_details )
801
+
802
+ @property
803
+ def backup_operation_details (self ) -> "ModelBackupOperationDetails" :
804
+ """
805
+ Gets the backup_operation_details of this Model using the spec constant.
806
+
807
+ :return: The backup_operation_details of this Model.
808
+ :rtype: ModelBackupOperationDetails
809
+ """
810
+ return self .get_spec (self .CONST_BACKUP_OPERATION_DETAILS )
811
+
812
+ @backup_operation_details .setter
813
+ def backup_operation_details (self , backup_operation_details : "ModelBackupOperationDetails" ) -> "DataScienceModel" :
814
+ """
815
+ Sets the backup_operation_details of this Model using the spec constant.
816
+
817
+ :param backup_operation_details: The backup_operation_details of this Model.
818
+ :type: ModelBackupOperationDetails
819
+ """
820
+ return self .set_spec (self .CONST_BACKUP_OPERATION_DETAILS , backup_operation_details )
821
+
688
822
def create (self , ** kwargs ) -> "DataScienceModel" :
689
823
"""Creates datascience model.
690
824
@@ -900,6 +1034,8 @@ def upload_artifact(
900
1034
artifact_uploader .upload ()
901
1035
902
1036
self ._remove_file_description_artifact ()
1037
+
1038
+
903
1039
904
1040
def _remove_file_description_artifact (self ):
905
1041
"""Removes temporary model file description artifact for model by reference."""
@@ -1181,6 +1317,8 @@ def _to_oci_dsc_model(self, **kwargs):
1181
1317
self .CONST_CUSTOM_METADATA : "_to_oci_metadata" ,
1182
1318
self .CONST_DEFINED_METADATA : "_to_oci_metadata" ,
1183
1319
self .CONST_PROVENANCE_METADATA : "_to_oci_metadata" ,
1320
+ self .CONST_BACKUP_SETTING : "to_json" ,
1321
+ self .CONST_RETENTION_SETTING : "to_json"
1184
1322
}
1185
1323
dsc_spec = {}
1186
1324
for infra_attr , dsc_attr in self .attribute_map .items ():
@@ -1219,6 +1357,8 @@ def _update_from_oci_dsc_model(
1219
1357
self .CONST_OUTPUT_SCHEMA : [Schema .from_json , json .loads ],
1220
1358
self .CONST_CUSTOM_METADATA : ModelCustomMetadata ._from_oci_metadata ,
1221
1359
self .CONST_DEFINED_METADATA : ModelTaxonomyMetadata ._from_oci_metadata ,
1360
+ self .CONST_BACKUP_SETTING : ModelBackupSetting .from_json ,
1361
+ self .CONST_RETENTION_SETTING : ModelRetentionSetting .from_json ,
1222
1362
}
1223
1363
1224
1364
# Update the main properties
0 commit comments