1111from datetime import datetime , timedelta
1212from pathlib import Path
1313from threading import Lock
14- from typing import Any , Dict , List , Union
14+ from typing import Any , Dict , List , Optional , Union
1515
1616import oci
1717from cachetools import TTLCache
4646 upload_local_to_os ,
4747)
4848from ads .aqua .config .config import evaluation_service_config
49+ from ads .aqua .config .evaluation .evaluation_service_config import EvaluationServiceConfig
4950from ads .aqua .constants import (
5051 CONSOLE_LINK_RESOURCE_TYPE_MAPPING ,
5152 EVALUATION_REPORT ,
@@ -171,8 +172,19 @@ def create(
171172 f"Invalid evaluation source { create_aqua_evaluation_details .evaluation_source_id } . "
172173 "Specify either a model or model deployment id."
173174 )
175+
176+ # The model to evaluate
174177 evaluation_source = None
175- eval_inference_configuration = None
178+ # The evaluation service config
179+ evaluation_config : EvaluationServiceConfig = evaluation_service_config ()
180+ # The evaluation inference configuration. The inference configuration will be extracted
181+ # based on the inferencing container family.
182+ eval_inference_configuration : Dict = {}
183+ # The evaluation inference model sampling params. The system parameters that will not be
184+ # visible for user, but will be applied implicitly for evaluation. The service model params
185+ # will be extracted based on the container family and version.
186+ eval_inference_service_model_params : Dict = {}
187+
176188 if (
177189 DataScienceResource .MODEL_DEPLOYMENT
178190 in create_aqua_evaluation_details .evaluation_source_id
@@ -188,17 +200,32 @@ def create(
188200 runtime = ModelDeploymentContainerRuntime .from_dict (
189201 evaluation_source .runtime .to_dict ()
190202 )
191- inference_config = AquaContainerConfig .from_container_index_json (
203+ container_config = AquaContainerConfig .from_container_index_json (
192204 enable_spec = True
193- ).inference
194- for container in inference_config .values ():
195- if container .name == runtime .image [: runtime .image .rfind (":" )]:
205+ )
206+ for (
207+ inference_container_family ,
208+ inference_container_info ,
209+ ) in container_config .inference .items ():
210+ if (
211+ inference_container_info .name
212+ == runtime .image [: runtime .image .rfind (":" )]
213+ ):
196214 eval_inference_configuration = (
197- container .spec .evaluation_configuration
215+ evaluation_config .get_merged_inference_params (
216+ inference_container_family
217+ ).to_dict ()
218+ )
219+ eval_inference_service_model_params = (
220+ evaluation_config .get_merged_inference_model_params (
221+ inference_container_family ,
222+ inference_container_info .version ,
223+ )
198224 )
225+
199226 except Exception :
200227 logger .debug (
201- f"Could not load inference config details for the evaluation id: "
228+ f"Could not load inference config details for the evaluation source id: "
202229 f"{ create_aqua_evaluation_details .evaluation_source_id } . Please check if the container"
203230 f" runtime has the correct SMC image information."
204231 )
@@ -415,13 +442,12 @@ def create(
415442 container_image = container_image ,
416443 dataset_path = evaluation_dataset_path ,
417444 report_path = create_aqua_evaluation_details .report_path ,
418- model_parameters = create_aqua_evaluation_details .model_parameters ,
445+ model_parameters = {
446+ ** eval_inference_service_model_params ,
447+ ** create_aqua_evaluation_details .model_parameters ,
448+ },
419449 metrics = create_aqua_evaluation_details .metrics ,
420- inference_configuration = (
421- eval_inference_configuration .to_filtered_dict ()
422- if eval_inference_configuration
423- else {}
424- ),
450+ inference_configuration = eval_inference_configuration or {},
425451 )
426452 ).create (** kwargs ) ## TODO: decide what parameters will be needed
427453 logger .debug (
@@ -1188,45 +1214,24 @@ def _delete_job_and_model(job, model):
11881214 f"Exception message: { ex } "
11891215 )
11901216
1191- def load_evaluation_config (self ) :
1217+ def load_evaluation_config (self , container : Optional [ str ] = None ) -> Dict :
11921218 """Loads evaluation config."""
1219+
1220+ # retrieve the evaluation config by container family name
1221+ evaluation_config = evaluation_service_config (container )
1222+
1223+ # convert the new config representation to the old one
11931224 return {
1194- "model_params" : {
1195- "max_tokens" : 500 ,
1196- "temperature" : 0.7 ,
1197- "top_p" : 1.0 ,
1198- "top_k" : 50 ,
1199- "presence_penalty" : 0.0 ,
1200- "frequency_penalty" : 0.0 ,
1201- "stop" : [],
1202- },
1225+ "model_params" : evaluation_config .ui_config .model_params .default ,
12031226 "shape" : {
1204- "VM.Standard.E3.Flex" : {
1205- "ocpu" : 8 ,
1206- "memory_in_gbs" : 128 ,
1207- "block_storage_size" : 200 ,
1208- },
1209- "VM.Standard.E4.Flex" : {
1210- "ocpu" : 8 ,
1211- "memory_in_gbs" : 128 ,
1212- "block_storage_size" : 200 ,
1213- },
1214- "VM.Standard3.Flex" : {
1215- "ocpu" : 8 ,
1216- "memory_in_gbs" : 128 ,
1217- "block_storage_size" : 200 ,
1218- },
1219- "VM.Optimized3.Flex" : {
1220- "ocpu" : 8 ,
1221- "memory_in_gbs" : 128 ,
1222- "block_storage_size" : 200 ,
1223- },
1224- },
1225- "default" : {
1226- "ocpu" : 8 ,
1227- "memory_in_gbs" : 128 ,
1228- "block_storage_size" : 200 ,
1227+ shape .name : shape .to_dict ()
1228+ for shape in evaluation_config .ui_config .shapes
12291229 },
1230+ "default" : (
1231+ evaluation_config .ui_config .shapes [0 ].to_dict ()
1232+ if len (evaluation_config .ui_config .shapes ) > 0
1233+ else {}
1234+ ),
12301235 }
12311236
12321237 def _get_attribute_from_model_metadata (
0 commit comments