@@ -625,7 +625,7 @@ def _is_model_by_reference(self):
625
625
msg = "Model needs to be saved to the Model Catalog before the creating custom metadata artifact corresponding to that model"
626
626
)
627
627
def create_custom_metadata_artifact (
628
- self , metadata_key_name : str , artifact_path : str
628
+ self , metadata_key_name : str , artifact_path : str , path_type : str
629
629
) -> ModelMetadataArtifactDetails :
630
630
"""Creates model custom metadata artifact for specified model.
631
631
@@ -653,12 +653,9 @@ def create_custom_metadata_artifact(
653
653
}
654
654
655
655
"""
656
- if not utils .is_path_exists (artifact_path ):
657
- raise FileNotFoundError (f"File not found: { artifact_path } . " )
658
- with open (artifact_path , "rb" ) as f :
659
- contents = f .read ()
660
- logger .info (f"The metadata artifact content - { contents } " )
661
-
656
+ contents = self .get_metadata_content (
657
+ artifact_path_or_content = artifact_path , path_type = path_type
658
+ )
662
659
response = self .client .create_model_custom_metadatum_artifact (
663
660
self .id ,
664
661
metadata_key_name ,
@@ -671,6 +668,21 @@ def create_custom_metadata_artifact(
671
668
return response_data
672
669
673
670
def get_metadata_content (self , artifact_path_or_content : str , path_type ):
671
+ """
672
+ returns the content of the metadata artifact
673
+
674
+ Parameters
675
+ ----------
676
+ artifact_path_or_content: str
677
+ The path of the file (local or oss) containing metadata artifact or content.
678
+ path_type: str
679
+ can be one of local , oss or content
680
+
681
+ Returns
682
+ -------
683
+ metadata artifact content
684
+ """
685
+
674
686
if path_type == utils .MetadataArtifactPathType .CONTENT :
675
687
return artifact_path_or_content
676
688
elif path_type == utils .MetadataArtifactPathType .LOCAL :
@@ -723,7 +735,9 @@ def create_defined_metadata_artifact(
723
735
}
724
736
725
737
"""
726
- contents = self .get_metadata_content (artifact_path , path_type )
738
+ contents = self .get_metadata_content (
739
+ artifact_path_or_content = artifact_path , path_type = path_type
740
+ )
727
741
response = self .client .create_model_defined_metadatum_artifact (
728
742
self .id ,
729
743
metadata_key_name ,
@@ -767,7 +781,9 @@ def update_defined_metadata_artifact(
767
781
}
768
782
769
783
"""
770
- contents = self .get_metadata_content (artifact_path , path_type )
784
+ contents = self .get_metadata_content (
785
+ artifact_path_or_content = artifact_path , path_type = path_type
786
+ )
771
787
response = self .client .update_model_defined_metadatum_artifact (
772
788
self .id ,
773
789
metadata_key_name ,
@@ -811,7 +827,9 @@ def update_custom_metadata_artifact(
811
827
}
812
828
813
829
"""
814
- contents = self .get_metadata_content (artifact_path , path_type )
830
+ contents = self .get_metadata_content (
831
+ artifact_path_or_content = artifact_path , path_type = path_type
832
+ )
815
833
response = self .client .update_model_custom_metadatum_artifact (
816
834
self .id ,
817
835
metadata_key_name ,
0 commit comments