@@ -325,8 +325,8 @@ def create(
325
325
# TODO: validate metrics if it's provided
326
326
327
327
evaluation_job_freeform_tags = {
328
- EvaluationJobTags .AQUA_EVALUATION : EvaluationJobTags .AQUA_EVALUATION ,
329
- EvaluationJobTags . EVALUATION_MODEL_ID : evaluation_model .id ,
328
+ Tags .AQUA_EVALUATION : Tags .AQUA_EVALUATION ,
329
+ Tags . AQUA_EVALUATION_MODEL_ID : evaluation_model .id ,
330
330
}
331
331
332
332
evaluation_job = Job (name = evaluation_model .display_name ).with_infrastructure (
@@ -408,7 +408,7 @@ def create(
408
408
update_model_details = UpdateModelDetails (
409
409
custom_metadata_list = updated_custom_metadata_list ,
410
410
freeform_tags = {
411
- EvaluationModelTags .AQUA_EVALUATION : EvaluationModelTags .AQUA_EVALUATION ,
411
+ Tags .AQUA_EVALUATION : Tags .AQUA_EVALUATION ,
412
412
},
413
413
),
414
414
)
@@ -479,7 +479,7 @@ def create(
479
479
),
480
480
),
481
481
tags = dict (
482
- aqua_evaluation = EvaluationModelTags .AQUA_EVALUATION ,
482
+ aqua_evaluation = Tags .AQUA_EVALUATION ,
483
483
evaluation_job_id = evaluation_job .id ,
484
484
evaluation_source = create_aqua_evaluation_details .evaluation_source_id ,
485
485
evaluation_experiment_id = experiment_model_version_set_id ,
@@ -708,12 +708,10 @@ def list(
708
708
models = utils .query_resources (
709
709
compartment_id = compartment_id ,
710
710
resource_type = "datasciencemodel" ,
711
- tag_list = [EvaluationModelTags .AQUA_EVALUATION ],
711
+ tag_list = [Tags .AQUA_EVALUATION ],
712
712
)
713
713
logger .info (f"Fetched { len (models )} evaluations." )
714
714
715
- # TODO: add filter based on project_id if needed.
716
-
717
715
mapping = self ._prefetch_resources (compartment_id )
718
716
719
717
evaluations = []
@@ -934,11 +932,13 @@ def load_metrics(self, eval_id: str) -> AquaEvalMetrics:
934
932
)
935
933
936
934
files_in_artifact = get_files (temp_dir )
937
- report_content = self ._read_from_artifact (
935
+ md_report_content = self ._read_from_artifact (
938
936
temp_dir , files_in_artifact , utils .EVALUATION_REPORT_MD
939
937
)
938
+
939
+ # json report not availiable for failed evaluation
940
940
try :
941
- report = json .loads (
941
+ json_report = json .loads (
942
942
self ._read_from_artifact (
943
943
temp_dir , files_in_artifact , utils .EVALUATION_REPORT_JSON
944
944
)
@@ -947,27 +947,32 @@ def load_metrics(self, eval_id: str) -> AquaEvalMetrics:
947
947
logger .debug (
948
948
"Failed to load `report.json` from evaluation artifact" f"{ str (e )} "
949
949
)
950
- report = {}
950
+ json_report = {}
951
951
952
- # TODO: after finalizing the format of report.json, move the constant to class
953
952
eval_metrics = AquaEvalMetrics (
954
953
id = eval_id ,
955
- report = base64 .b64encode (report_content ).decode (),
954
+ report = base64 .b64encode (md_report_content ).decode (),
956
955
metric_results = [
957
956
AquaEvalMetric (
958
- key = metric_key ,
959
- name = metadata .get ("name" , utils .UNKNOWN ),
960
- description = metadata .get ("description" , utils .UNKNOWN ),
957
+ key = metadata .get (EvaluationMetricResult .SHORT_NAME , utils .UNKNOWN ),
958
+ name = metadata .get (EvaluationMetricResult .NAME , utils .UNKNOWN ),
959
+ description = metadata .get (
960
+ EvaluationMetricResult .DESCRIPTION , utils .UNKNOWN
961
+ ),
961
962
)
962
- for metric_key , metadata in report .get ("metric_results" , {}).items ()
963
+ for _ , metadata in json_report .get (
964
+ EvaluationReportJson .METRIC_RESULT , {}
965
+ ).items ()
963
966
],
964
967
metric_summary_result = [
965
968
AquaEvalMetricSummary (** m )
966
- for m in report .get ("metric_summary_result" , [{}])
969
+ for m in json_report .get (
970
+ EvaluationReportJson .METRIC_SUMMARY_RESULT , [{}]
971
+ )
967
972
],
968
973
)
969
974
970
- if report_content :
975
+ if md_report_content :
971
976
self ._metrics_cache .__setitem__ (key = eval_id , value = eval_metrics )
972
977
973
978
return eval_metrics
@@ -1266,16 +1271,16 @@ def _get_source(
1266
1271
)
1267
1272
)
1268
1273
1269
- if not source_name :
1274
+ # try to resolve source_name from source id
1275
+ if source_id and not source_name :
1270
1276
resource_type = utils .get_resource_type (source_id )
1271
1277
1272
- # TODO: adjust resource principal mapping
1273
- if resource_type == "datasciencemodel" :
1274
- source_name = self .ds_client .get_model (source_id ).data .display_name
1275
- elif resource_type == "datasciencemodeldeployment" :
1278
+ if resource_type .startswith ("datasciencemodeldeployment" ):
1276
1279
source_name = self .ds_client .get_model_deployment (
1277
1280
source_id
1278
1281
).data .display_name
1282
+ elif resource_type .startswith ("datasciencemodel" ):
1283
+ source_name = self .ds_client .get_model (source_id ).data .display_name
1279
1284
else :
1280
1285
raise AquaRuntimeError (
1281
1286
f"Not supported source type: { resource_type } "
@@ -1404,8 +1409,6 @@ def _fetch_runtime_params(
1404
1409
"model parameters have not been saved in correct format in model taxonomy. " ,
1405
1410
service_payload = {"params" : params },
1406
1411
)
1407
- # TODO: validate the format of parameters.
1408
- # self._validate_params(params)
1409
1412
1410
1413
return AquaEvalParams (** params [EvaluationConfig .PARAMS ])
1411
1414
except Exception as e :
@@ -1438,7 +1441,6 @@ def _build_job_identifier(
1438
1441
)
1439
1442
return AquaResourceIdentifier ()
1440
1443
1441
- # TODO: fix the logic for determine termination state
1442
1444
def _get_status (
1443
1445
self ,
1444
1446
model : oci .resource_search .models .ResourceSummary ,
@@ -1498,12 +1500,10 @@ def _get_status(
1498
1500
1499
1501
def _prefetch_resources (self , compartment_id ) -> dict :
1500
1502
"""Fetches all AQUA resources."""
1501
- # TODO: handle cross compartment/tenency resources
1502
- # TODO: add cache
1503
1503
resources = utils .query_resources (
1504
1504
compartment_id = compartment_id ,
1505
1505
resource_type = "all" ,
1506
- tag_list = [EvaluationModelTags .AQUA_EVALUATION , "OCI_AQUA" ],
1506
+ tag_list = [Tags .AQUA_EVALUATION , "OCI_AQUA" ],
1507
1507
connect_by_ampersands = False ,
1508
1508
return_all = False ,
1509
1509
)
0 commit comments