1313from huggingface_hub import snapshot_download
1414from oci .data_science .models import JobRun , Metadata , Model , UpdateModelDetails
1515
16- from ads .aqua import ODSC_MODEL_COMPARTMENT_OCID , logger
16+ from ads .aqua import logger
1717from ads .aqua .app import AquaApp
1818from ads .aqua .common .entities import AquaMultiModelRef
1919from ads .aqua .common .enums import (
9494 AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME ,
9595 AQUA_EVALUATION_CONTAINER_METADATA_NAME ,
9696 AQUA_FINETUNING_CONTAINER_METADATA_NAME ,
97+ AQUA_SERVICE_MODELS ,
9798 COMPARTMENT_OCID ,
9899 PROJECT_OCID ,
99100 SERVICE ,
@@ -181,7 +182,9 @@ def create(
181182 service_model = DataScienceModel .from_id (model_id )
182183 target_project = project_id or PROJECT_OCID
183184 target_compartment = compartment_id or COMPARTMENT_OCID
184- if service_model .compartment_id != ODSC_MODEL_COMPARTMENT_OCID :
185+
186+ # Skip model copying if it is registered model
187+ if service_model .freeform_tags .get (Tags .BASE_MODEL_CUSTOM ) is not None :
185188 logger .info (
186189 f"Aqua Model { model_id } already exists in the user's compartment."
187190 "Skipped copying."
@@ -949,11 +952,11 @@ def list(
949952 category = "aqua/service/model" , action = "list"
950953 )
951954
952- if ODSC_MODEL_COMPARTMENT_OCID in self ._service_models_cache :
955+ if AQUA_SERVICE_MODELS in self ._service_models_cache :
953956 logger .info (
954- f"Returning service models list in { ODSC_MODEL_COMPARTMENT_OCID } from cache."
957+ f"Returning service models list in { AQUA_SERVICE_MODELS } from cache."
955958 )
956- return self ._service_models_cache .get (ODSC_MODEL_COMPARTMENT_OCID )
959+ return self ._service_models_cache .get (AQUA_SERVICE_MODELS )
957960 logger .info ("Fetching service models." )
958961 lifecycle_state = kwargs .pop (
959962 "lifecycle_state" , Model .LIFECYCLE_STATE_ACTIVE
@@ -968,7 +971,7 @@ def list(
968971 )
969972
970973 logger .info (
971- f"Fetched { len (models )} model in compartment_id= { ODSC_MODEL_COMPARTMENT_OCID if category == SERVICE else compartment_id } ."
974+ f"Fetched { len (models )} models from { AQUA_SERVICE_MODELS if category == SERVICE else compartment_id } ."
972975 )
973976 aqua_models = []
974977 inference_containers = self .get_container_config ().to_dict ().get ("inference" )
@@ -986,7 +989,7 @@ def list(
986989
987990 if category == SERVICE :
988991 self ._service_models_cache .__setitem__ (
989- key = ODSC_MODEL_COMPARTMENT_OCID , value = aqua_models
992+ key = AQUA_SERVICE_MODELS , value = aqua_models
990993 )
991994
992995 return aqua_models
@@ -1002,15 +1005,10 @@ def clear_model_list_cache(
10021005 """
10031006 res = {}
10041007 with self ._cache_lock :
1005- if ODSC_MODEL_COMPARTMENT_OCID in self ._service_models_cache :
1006- self ._service_models_cache .pop (key = ODSC_MODEL_COMPARTMENT_OCID )
1007- logger .info (
1008- f"Cleared models cache for service compartment { ODSC_MODEL_COMPARTMENT_OCID } ."
1009- )
1008+ if AQUA_SERVICE_MODELS in self ._service_models_cache :
1009+ self ._service_models_cache .pop (key = AQUA_SERVICE_MODELS )
1010+ logger .info ("Cleared models cache for service compartment." )
10101011 res = {
1011- "key" : {
1012- "compartment_id" : ODSC_MODEL_COMPARTMENT_OCID ,
1013- },
10141012 "cache_deleted" : True ,
10151013 }
10161014 return res
0 commit comments