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
@@ -161,10 +158,11 @@ def create(
161158 try :
162159 create_aqua_evaluation_details = CreateAquaEvaluationDetails (** kwargs )
163160 except Exception as ex :
161+ custom_errors = {
162+ "." .join (map (str , e ["loc" ])): e ["msg" ] for e in json .loads (ex .json ())
163+ }
164164 raise AquaValueError (
165- "Invalid create evaluation parameters. "
166- "Allowable parameters are: "
167- f"{ ', ' .join ([field .name for field in fields (CreateAquaEvaluationDetails )])} ."
165+ f"Invalid create evaluation parameters. Error details: { custom_errors } ."
168166 ) from ex
169167
170168 if not is_valid_ocid (create_aqua_evaluation_details .evaluation_source_id ):
@@ -175,15 +173,7 @@ def create(
175173
176174 # The model to evaluate
177175 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.
182176 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 = {}
187177
188178 if (
189179 DataScienceResource .MODEL_DEPLOYMENT
@@ -200,29 +190,14 @@ def create(
200190 runtime = ModelDeploymentContainerRuntime .from_dict (
201191 evaluation_source .runtime .to_dict ()
202192 )
203- container_config = AquaContainerConfig .from_container_index_json (
193+ inference_config = AquaContainerConfig .from_container_index_json (
204194 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- ):
195+ ).inference
196+ for container in inference_config .values ():
197+ if container .name == runtime .image [: runtime .image .rfind (":" )]:
214198 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- )
199+ container .spec .evaluation_configuration
224200 )
225-
226201 except Exception :
227202 logger .debug (
228203 f"Could not load inference config details for the evaluation source id: "
@@ -277,19 +252,12 @@ def create(
277252 )
278253 evaluation_dataset_path = dst_uri
279254
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
255+ evaluation_model_parameters = AquaEvalParams (
256+ shape = create_aqua_evaluation_details .shape_name ,
257+ dataset_path = evaluation_dataset_path ,
258+ report_path = create_aqua_evaluation_details .report_path ,
259+ ** create_aqua_evaluation_details .model_parameters ,
260+ )
293261
294262 target_compartment = (
295263 create_aqua_evaluation_details .compartment_id or COMPARTMENT_OCID
@@ -370,7 +338,7 @@ def create(
370338 evaluation_model_taxonomy_metadata = ModelTaxonomyMetadata ()
371339 evaluation_model_taxonomy_metadata [
372340 MetadataTaxonomyKeys .HYPERPARAMETERS
373- ].value = {"model_params" : dict ( asdict ( evaluation_model_parameters ) )}
341+ ].value = {"model_params" : evaluation_model_parameters . to_dict ( )}
374342
375343 evaluation_model = (
376344 DataScienceModel ()
@@ -443,7 +411,6 @@ def create(
443411 dataset_path = evaluation_dataset_path ,
444412 report_path = create_aqua_evaluation_details .report_path ,
445413 model_parameters = {
446- ** eval_inference_service_model_params ,
447414 ** create_aqua_evaluation_details .model_parameters ,
448415 },
449416 metrics = create_aqua_evaluation_details .metrics ,
@@ -580,16 +547,14 @@ def _build_evaluation_runtime(
580547 ** {
581548 "AIP_SMC_EVALUATION_ARGUMENTS" : json .dumps (
582549 {
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- ),
550+ ** self ._build_launch_cmd (
551+ evaluation_id = evaluation_id ,
552+ evaluation_source_id = evaluation_source_id ,
553+ dataset_path = dataset_path ,
554+ report_path = report_path ,
555+ model_parameters = model_parameters ,
556+ metrics = metrics ,
557+ ).to_dict (),
593558 ** (inference_configuration or {}),
594559 },
595560 ),
@@ -662,9 +627,9 @@ def _build_launch_cmd(
662627 "format" : Path (dataset_path ).suffix ,
663628 "url" : dataset_path ,
664629 },
665- metrics = metrics ,
630+ metrics = metrics or [] ,
666631 output_dir = report_path ,
667- params = model_parameters ,
632+ params = model_parameters or {} ,
668633 )
669634
670635 @telemetry (entry_point = "plugin=evaluation&action=get" , name = "aqua" )
0 commit comments