@@ -825,6 +825,125 @@ def test_get_model_fine_tuned(
825
825
"evaluation_container" : "odsc-llm-evaluate" ,
826
826
}
827
827
828
+ @patch .object (DataScienceModel , "create" )
829
+ @patch .object (DataScienceModel , "from_id" )
830
+ def test_convert_fine_tune (self , mock_from_id , mock_create ):
831
+ ds_model = MagicMock ()
832
+ ds_model .id = "test_id"
833
+ ds_model .compartment_id = "test_model_compartment_id"
834
+ ds_model .project_id = "test_project_id"
835
+ ds_model .display_name = "test_display_name"
836
+ ds_model .description = "test_description"
837
+ ds_model .model_version_set_id = "test_model_version_set_id"
838
+ ds_model .model_version_set_name = "test_model_version_set_name"
839
+ ds_model .freeform_tags = {
840
+ "license" : "test_license" ,
841
+ "organization" : "test_organization" ,
842
+ "task" : "test_task" ,
843
+ "aqua_fine_tuned_model" : "test_finetuned_model" ,
844
+ }
845
+ ds_model .time_created = "2024-01-19T17:57:39.158000+00:00"
846
+ ds_model .lifecycle_state = "ACTIVE"
847
+ custom_metadata_list = ModelCustomMetadata ()
848
+ custom_metadata_list .add (
849
+ ** {"key" : "artifact_location" , "value" : "oci://bucket@namespace/prefix/" }
850
+ )
851
+ custom_metadata_list .add (
852
+ ** {"key" : "fine_tune_source" , "value" : "test_fine_tuned_source_id" }
853
+ )
854
+ custom_metadata_list .add (
855
+ ** {"key" : "fine_tune_source_name" , "value" : "test_fine_tuned_source_name" }
856
+ )
857
+ custom_metadata_list .add (
858
+ ** {
859
+ "key" : "deployment-container" ,
860
+ "value" : "odsc-vllm-serving" ,
861
+ }
862
+ )
863
+ custom_metadata_list .add (
864
+ ** {
865
+ "key" : "evaluation-container" ,
866
+ "value" : "odsc-llm-evaluate" ,
867
+ }
868
+ )
869
+ custom_metadata_list .add (
870
+ ** {
871
+ "key" : "finetune-container" ,
872
+ "value" : "odsc-llm-fine-tuning" ,
873
+ }
874
+ )
875
+ ds_model .custom_metadata_list = custom_metadata_list
876
+ defined_metadata_list = ModelTaxonomyMetadata ()
877
+ defined_metadata_list ["Hyperparameters" ].value = {
878
+ "training_data" : "test_training_data" ,
879
+ "val_set_size" : "test_val_set_size" ,
880
+ }
881
+ ds_model .defined_metadata_list = defined_metadata_list
882
+ ds_model .provenance_metadata = ModelProvenanceMetadata (
883
+ training_id = "test_training_job_run_id"
884
+ )
885
+ ds_model .model_file_description = {
886
+ "version" : "1.0" ,
887
+ "type" : "modelOSSReferenceDescription" ,
888
+ "models" : [
889
+ {
890
+ "namespace" : "test_namespace_one" ,
891
+ "bucketName" : "test_bucket_name_one" ,
892
+ "prefix" : "test_prefix_one" ,
893
+ "objects" : [
894
+ {
895
+ "name" : "artifact/.gitattributes" ,
896
+ "version" : "123" ,
897
+ "sizeInBytes" : 1519 ,
898
+ }
899
+ ],
900
+ },
901
+ {
902
+ "namespace" : "test_namespace_two" ,
903
+ "bucketName" : "test_bucket_name_two" ,
904
+ "prefix" : "test_prefix_two" ,
905
+ "objects" : [
906
+ {
907
+ "name" : "/README.md" ,
908
+ "version" : "b52c2608-009f-4774-8325-60ec226ae003" ,
909
+ "sizeInBytes" : 5189 ,
910
+ }
911
+ ],
912
+ },
913
+ ],
914
+ }
915
+
916
+ mock_from_id .return_value = ds_model
917
+
918
+ # missing 'OCI_AQUA' tag
919
+ with pytest .raises (
920
+ AquaValueError ,
921
+ match = "Model 'mock_model_id' is not eligible for conversion. Only legacy AQUA fine-tuned models without the 'fine_tune_model_version=v2' tag are supported." ,
922
+ ):
923
+ self .app .convert_fine_tune (model_id = "mock_model_id" )
924
+
925
+ # add 'OCI_AQUA' tag
926
+ mock_from_id .return_value .freeform_tags ["OCI_AQUA" ] = "ACTIVE"
927
+
928
+ self .app .convert_fine_tune (model_id = "mock_model_id" )
929
+
930
+ mock_create .assert_called_with (model_by_reference = True )
931
+
932
+ assert mock_from_id .return_value .model_file_description ["models" ] == [
933
+ {
934
+ "namespace" : "test_namespace_two" ,
935
+ "bucketName" : "test_bucket_name_two" ,
936
+ "prefix" : "test_prefix_two" ,
937
+ "objects" : [
938
+ {
939
+ "name" : "/README.md" ,
940
+ "version" : "b52c2608-009f-4774-8325-60ec226ae003" ,
941
+ "sizeInBytes" : 5189 ,
942
+ }
943
+ ],
944
+ }
945
+ ]
946
+
828
947
@pytest .mark .parametrize (
829
948
("artifact_location_set" , "download_from_hf" , "cleanup_model_cache" ),
830
949
[
0 commit comments