@@ -185,7 +185,7 @@ def create(
185185 target_compartment = compartment_id or COMPARTMENT_OCID
186186
187187 # Skip model copying if it is registered model
188- if service_model .freeform_tags .get (Tags .BASE_MODEL_CUSTOM ) is not None :
188+ if service_model .freeform_tags .get (Tags .BASE_MODEL_CUSTOM , None ) is not None :
189189 logger .info (
190190 f"Aqua Model { model_id } already exists in the user's compartment."
191191 "Skipped copying."
@@ -919,12 +919,13 @@ def _process_model(
919919 def list (
920920 self ,
921921 compartment_id : str = None ,
922+ category : str = None ,
922923 project_id : str = None ,
923924 model_type : str = None ,
924925 ** kwargs ,
925926 ) -> List ["AquaModelSummary" ]:
926927 """Lists all Aqua models within a specified compartment and/or project.
927- If `compartment_id ` is not specified, the method defaults to returning
928+ If `category ` is not specified, the method defaults to returning
928929 the service models within the pre-configured default compartment. By default, the list
929930 of models in the service compartment are cached. Use clear_model_list_cache() to invalidate
930931 the cache.
@@ -933,6 +934,8 @@ def list(
933934 ----------
934935 compartment_id: (str, optional). Defaults to `None`.
935936 The compartment OCID.
937+ category: (str,optional). Defaults to `SERVICE`
938+ The category of the models to fetch. Can be either `USER` or `SERVICE`
936939 project_id: (str, optional). Defaults to `None`.
937940 The project OCID.
938941 model_type: (str, optional). Defaults to `None`.
@@ -946,9 +949,9 @@ def list(
946949 The list of the `ads.aqua.model.AquaModelSummary`.
947950 """
948951
949- models = []
950- category = kwargs . pop ( "category" , USER )
951- if compartment_id and category != SERVICE :
952+ category = category or kwargs . pop ( "category" , SERVICE )
953+ compartment_id = compartment_id or COMPARTMENT_OCID
954+ if category == USER :
952955 # tracks number of times custom model listing was called
953956 self .telemetry .record_event_async (
954957 category = "aqua/custom/model" , action = "list"
@@ -957,33 +960,32 @@ def list(
957960 logger .info (f"Fetching custom models from compartment_id={ compartment_id } ." )
958961 model_type = model_type .upper () if model_type else ModelType .FT
959962 models = self ._rqs (compartment_id , model_type = model_type )
963+ logger .info (
964+ f"Fetched { len (models )} models from { compartment_id or COMPARTMENT_OCID } ."
965+ )
960966 else :
961967 # tracks number of times service model listing was called
962968 self .telemetry .record_event_async (
963969 category = "aqua/service/model" , action = "list"
964970 )
965971
966972 if AQUA_SERVICE_MODELS in self ._service_models_cache :
967- logger .info (
968- f"Returning service models list in { AQUA_SERVICE_MODELS } from cache."
969- )
973+ logger .info ("Returning service models list from cache." )
970974 return self ._service_models_cache .get (AQUA_SERVICE_MODELS )
971- logger .info ("Fetching service models." )
975+ logger .info ("Fetching service models from cache ." )
972976 lifecycle_state = kwargs .pop (
973977 "lifecycle_state" , Model .LIFECYCLE_STATE_ACTIVE
974978 )
975979
976980 models = self .list_resource (
977981 self .ds_client .list_models ,
978- compartment_id = compartment_id or COMPARTMENT_OCID ,
982+ compartment_id = compartment_id ,
979983 lifecycle_state = lifecycle_state ,
980984 category = category ,
981985 ** kwargs ,
982986 )
987+ logger .info (f"Fetched { len (models )} service models." )
983988
984- logger .info (
985- f"Fetched { len (models )} models from { AQUA_SERVICE_MODELS if category == SERVICE else compartment_id } ."
986- )
987989 aqua_models = []
988990 inference_containers = self .get_container_config ().to_dict ().get ("inference" )
989991 for model in models :
@@ -997,7 +999,6 @@ def list(
997999 project_id = project_id or UNKNOWN ,
9981000 )
9991001 )
1000-
10011002 if category == SERVICE :
10021003 self ._service_models_cache .__setitem__ (
10031004 key = AQUA_SERVICE_MODELS , value = aqua_models
0 commit comments