77import re
88import tempfile
99from concurrent .futures import ThreadPoolExecutor , as_completed
10- from dataclasses import asdict , fields
1110from datetime import datetime , timedelta
1211from pathlib import Path
1312from threading import Lock
4645 upload_local_to_os ,
4746)
4847from ads .aqua .config .config import get_evaluation_service_config
49- from ads .aqua .config .evaluation .evaluation_service_config import EvaluationServiceConfig
5048from ads .aqua .constants import (
5149 CONSOLE_LINK_RESOURCE_TYPE_MAPPING ,
5250 EVALUATION_REPORT ,
7573 AquaEvaluationSummary ,
7674 AquaResourceIdentifier ,
7775 CreateAquaEvaluationDetails ,
78- ModelParams ,
7976)
8077from ads .aqua .evaluation .errors import EVALUATION_JOB_EXIT_CODE_MESSAGE
8178from ads .aqua .ui import AquaContainerConfig
@@ -164,7 +161,7 @@ def create(
164161 raise AquaValueError (
165162 "Invalid create evaluation parameters. "
166163 "Allowable parameters are: "
167- f"{ ', ' .join ([field . name for field in fields ( CreateAquaEvaluationDetails ) ])} ."
164+ f"{ ', ' .join ([field for field in CreateAquaEvaluationDetails . model_fields ])} ."
168165 ) from ex
169166
170167 if not is_valid_ocid (create_aqua_evaluation_details .evaluation_source_id ):
@@ -175,15 +172,7 @@ def create(
175172
176173 # The model to evaluate
177174 evaluation_source = None
178- # The evaluation service config
179- evaluation_config : EvaluationServiceConfig = get_evaluation_service_config ()
180- # The evaluation inference configuration. The inference configuration will be extracted
181- # based on the inferencing container family.
182175 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 = {}
187176
188177 if (
189178 DataScienceResource .MODEL_DEPLOYMENT
@@ -200,29 +189,14 @@ def create(
200189 runtime = ModelDeploymentContainerRuntime .from_dict (
201190 evaluation_source .runtime .to_dict ()
202191 )
203- container_config = AquaContainerConfig .from_container_index_json (
192+ inference_config = AquaContainerConfig .from_container_index_json (
204193 enable_spec = True
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- ):
194+ ).inference
195+ for container in inference_config .values ():
196+ if container .name == runtime .image [: runtime .image .rfind (":" )]:
214197 eval_inference_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- )
198+ container .spec .evaluation_configuration
224199 )
225-
226200 except Exception :
227201 logger .debug (
228202 f"Could not load inference config details for the evaluation source id: "
@@ -277,19 +251,12 @@ def create(
277251 )
278252 evaluation_dataset_path = dst_uri
279253
280- evaluation_model_parameters = None
281- try :
282- evaluation_model_parameters = AquaEvalParams (
283- shape = create_aqua_evaluation_details .shape_name ,
284- dataset_path = evaluation_dataset_path ,
285- report_path = create_aqua_evaluation_details .report_path ,
286- ** create_aqua_evaluation_details .model_parameters ,
287- )
288- except Exception as ex :
289- raise AquaValueError (
290- "Invalid model parameters. Model parameters should "
291- f"be a dictionary with keys: { ', ' .join (list (ModelParams .__annotations__ .keys ()))} ."
292- ) from ex
254+ evaluation_model_parameters = AquaEvalParams (
255+ shape = create_aqua_evaluation_details .shape_name ,
256+ dataset_path = evaluation_dataset_path ,
257+ report_path = create_aqua_evaluation_details .report_path ,
258+ ** create_aqua_evaluation_details .model_parameters ,
259+ )
293260
294261 target_compartment = (
295262 create_aqua_evaluation_details .compartment_id or COMPARTMENT_OCID
@@ -370,7 +337,7 @@ def create(
370337 evaluation_model_taxonomy_metadata = ModelTaxonomyMetadata ()
371338 evaluation_model_taxonomy_metadata [
372339 MetadataTaxonomyKeys .HYPERPARAMETERS
373- ].value = {"model_params" : dict ( asdict ( evaluation_model_parameters ) )}
340+ ].value = {"model_params" : evaluation_model_parameters . to_dict ( )}
374341
375342 evaluation_model = (
376343 DataScienceModel ()
@@ -443,7 +410,6 @@ def create(
443410 dataset_path = evaluation_dataset_path ,
444411 report_path = create_aqua_evaluation_details .report_path ,
445412 model_parameters = {
446- ** eval_inference_service_model_params ,
447413 ** create_aqua_evaluation_details .model_parameters ,
448414 },
449415 metrics = create_aqua_evaluation_details .metrics ,
@@ -580,16 +546,14 @@ def _build_evaluation_runtime(
580546 ** {
581547 "AIP_SMC_EVALUATION_ARGUMENTS" : json .dumps (
582548 {
583- ** asdict (
584- self ._build_launch_cmd (
585- evaluation_id = evaluation_id ,
586- evaluation_source_id = evaluation_source_id ,
587- dataset_path = dataset_path ,
588- report_path = report_path ,
589- model_parameters = model_parameters ,
590- metrics = metrics ,
591- ),
592- ),
549+ ** self ._build_launch_cmd (
550+ evaluation_id = evaluation_id ,
551+ evaluation_source_id = evaluation_source_id ,
552+ dataset_path = dataset_path ,
553+ report_path = report_path ,
554+ model_parameters = model_parameters ,
555+ metrics = metrics ,
556+ ).to_dict (),
593557 ** (inference_configuration or {}),
594558 },
595559 ),
@@ -662,9 +626,9 @@ def _build_launch_cmd(
662626 "format" : Path (dataset_path ).suffix ,
663627 "url" : dataset_path ,
664628 },
665- metrics = metrics ,
629+ metrics = metrics or [] ,
666630 output_dir = report_path ,
667- params = model_parameters ,
631+ params = model_parameters or {} ,
668632 )
669633
670634 @telemetry (entry_point = "plugin=evaluation&action=get" , name = "aqua" )
0 commit comments