@@ -517,20 +517,31 @@ def add_models(self, model_details: ModelDetails) -> "Dataset":
517517 if existing_model_details and existing_model_details .items :
518518 items = existing_model_details ["items" ]
519519 for item in items :
520- model_details .items .append (item )
520+ if item not in model_details .items :
521+ model_details .items .append (item )
521522 self .with_model_details (model_details )
522- self .update ()
523-
524- self ._update_from_oci_dataset_model (self .oci_dataset )
525- updated_model_details = self .model_details
526- if updated_model_details and updated_model_details .items and model_details :
527- for model_id in model_details .items :
528- if model_id not in updated_model_details ["items" ]:
529- logger .warning (
530- f"Either model with Id '{ model_id } ' doesnt exist or unable to validate"
531- )
532-
533- return self
523+ try :
524+ return self .update ()
525+ except Exception as ex :
526+ logger .error (
527+ f"Dataset update Failed with : { type (ex )} with error message: { ex } "
528+ )
529+ if existing_model_details :
530+ self .with_model_details (ModelDetails ().with_items (existing_model_details ["items" ]))
531+ else :
532+ self .with_model_details (ModelDetails ().with_items ([]))
533+
534+ # self._update_from_oci_dataset_model(self.oci_dataset)
535+ # updated_model_details = self.model_details
536+ # if updated_model_details and updated_model_details.items and model_details:
537+ # for model_id in model_details.items:
538+ # if model_id not in updated_model_details["items"]:
539+ # logger.warning(
540+ # f"Either model with Id '{model_id}' doesnt exist or unable to validate"
541+ # )
542+ # )
543+ #
544+ # return self
534545
535546 def remove_models (self , model_details : ModelDetails ) -> "Dataset" :
536547 """remove model details from the dataset, remove from the existing dataset model id list
0 commit comments