7
7
import re
8
8
import tempfile
9
9
from concurrent .futures import ThreadPoolExecutor , as_completed
10
- from dataclasses import asdict , fields
11
10
from datetime import datetime , timedelta
12
11
from pathlib import Path
13
12
from threading import Lock
46
45
upload_local_to_os ,
47
46
)
48
47
from ads .aqua .config .config import get_evaluation_service_config
49
- from ads .aqua .config .evaluation .evaluation_service_config import EvaluationServiceConfig
50
48
from ads .aqua .constants import (
51
49
CONSOLE_LINK_RESOURCE_TYPE_MAPPING ,
52
50
EVALUATION_REPORT ,
75
73
AquaEvaluationSummary ,
76
74
AquaResourceIdentifier ,
77
75
CreateAquaEvaluationDetails ,
78
- ModelParams ,
79
76
)
80
77
from ads .aqua .evaluation .errors import EVALUATION_JOB_EXIT_CODE_MESSAGE
81
78
from ads .aqua .ui import AquaContainerConfig
@@ -161,10 +158,11 @@ def create(
161
158
try :
162
159
create_aqua_evaluation_details = CreateAquaEvaluationDetails (** kwargs )
163
160
except Exception as ex :
161
+ custom_errors = {
162
+ "." .join (map (str , e ["loc" ])): e ["msg" ] for e in json .loads (ex .json ())
163
+ }
164
164
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 } ."
168
166
) from ex
169
167
170
168
if not is_valid_ocid (create_aqua_evaluation_details .evaluation_source_id ):
@@ -175,15 +173,7 @@ def create(
175
173
176
174
# The model to evaluate
177
175
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.
182
176
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
177
188
178
if (
189
179
DataScienceResource .MODEL_DEPLOYMENT
@@ -200,29 +190,14 @@ def create(
200
190
runtime = ModelDeploymentContainerRuntime .from_dict (
201
191
evaluation_source .runtime .to_dict ()
202
192
)
203
- container_config = AquaContainerConfig .from_container_index_json (
193
+ inference_config = AquaContainerConfig .from_container_index_json (
204
194
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 (":" )]:
214
198
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
224
200
)
225
-
226
201
except Exception :
227
202
logger .debug (
228
203
f"Could not load inference config details for the evaluation source id: "
@@ -277,19 +252,12 @@ def create(
277
252
)
278
253
evaluation_dataset_path = dst_uri
279
254
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
+ )
293
261
294
262
target_compartment = (
295
263
create_aqua_evaluation_details .compartment_id or COMPARTMENT_OCID
@@ -370,7 +338,7 @@ def create(
370
338
evaluation_model_taxonomy_metadata = ModelTaxonomyMetadata ()
371
339
evaluation_model_taxonomy_metadata [
372
340
MetadataTaxonomyKeys .HYPERPARAMETERS
373
- ].value = {"model_params" : dict ( asdict ( evaluation_model_parameters ) )}
341
+ ].value = {"model_params" : evaluation_model_parameters . to_dict ( )}
374
342
375
343
evaluation_model = (
376
344
DataScienceModel ()
@@ -443,7 +411,6 @@ def create(
443
411
dataset_path = evaluation_dataset_path ,
444
412
report_path = create_aqua_evaluation_details .report_path ,
445
413
model_parameters = {
446
- ** eval_inference_service_model_params ,
447
414
** create_aqua_evaluation_details .model_parameters ,
448
415
},
449
416
metrics = create_aqua_evaluation_details .metrics ,
@@ -580,16 +547,14 @@ def _build_evaluation_runtime(
580
547
** {
581
548
"AIP_SMC_EVALUATION_ARGUMENTS" : json .dumps (
582
549
{
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 (),
593
558
** (inference_configuration or {}),
594
559
},
595
560
),
@@ -662,9 +627,9 @@ def _build_launch_cmd(
662
627
"format" : Path (dataset_path ).suffix ,
663
628
"url" : dataset_path ,
664
629
},
665
- metrics = metrics ,
630
+ metrics = metrics or [] ,
666
631
output_dir = report_path ,
667
- params = model_parameters ,
632
+ params = model_parameters or {} ,
668
633
)
669
634
670
635
@telemetry (entry_point = "plugin=evaluation&action=get" , name = "aqua" )
0 commit comments