|
1 | 1 | #!/usr/bin/env python |
2 | | -# Copyright (c) 2024 Oracle and/or its affiliates. |
| 2 | +# Copyright (c) 2024, 2025 Oracle and/or its affiliates. |
3 | 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ |
4 | 4 | import base64 |
5 | 5 | import json |
|
43 | 43 | get_container_image, |
44 | 44 | is_valid_ocid, |
45 | 45 | upload_local_to_os, |
| 46 | + validate_dataclass_params, |
46 | 47 | ) |
47 | 48 | from ads.aqua.config.config import get_evaluation_service_config |
48 | 49 | from ads.aqua.constants import ( |
@@ -155,16 +156,9 @@ def create( |
155 | 156 | The instance of AquaEvaluationSummary. |
156 | 157 | """ |
157 | 158 | if not create_aqua_evaluation_details: |
158 | | - try: |
159 | | - create_aqua_evaluation_details = CreateAquaEvaluationDetails(**kwargs) |
160 | | - except Exception as ex: |
161 | | - custom_errors = { |
162 | | - ".".join(map(str, e["loc"])): e["msg"] |
163 | | - for e in json.loads(ex.json()) |
164 | | - } |
165 | | - raise AquaValueError( |
166 | | - f"Invalid create evaluation parameters. Error details: {custom_errors}." |
167 | | - ) from ex |
| 159 | + create_aqua_evaluation_details = validate_dataclass_params( |
| 160 | + CreateAquaEvaluationDetails, **kwargs |
| 161 | + ) |
168 | 162 |
|
169 | 163 | if not is_valid_ocid(create_aqua_evaluation_details.evaluation_source_id): |
170 | 164 | raise AquaValueError( |
@@ -199,11 +193,11 @@ def create( |
199 | 193 | eval_inference_configuration = ( |
200 | 194 | container.spec.evaluation_configuration |
201 | 195 | ) |
202 | | - except Exception: |
| 196 | + except Exception as ex: |
203 | 197 | logger.debug( |
204 | 198 | f"Could not load inference config details for the evaluation source id: " |
205 | 199 | f"{create_aqua_evaluation_details.evaluation_source_id}. Please check if the container" |
206 | | - f" runtime has the correct SMC image information." |
| 200 | + f" runtime has the correct SMC image information.\nError: {str(ex)}" |
207 | 201 | ) |
208 | 202 | elif ( |
209 | 203 | DataScienceResource.MODEL |
@@ -289,7 +283,7 @@ def create( |
289 | 283 | f"Invalid experiment name. Please provide an experiment with `{Tags.AQUA_EVALUATION}` in tags." |
290 | 284 | ) |
291 | 285 | except Exception: |
292 | | - logger.debug( |
| 286 | + logger.info( |
293 | 287 | f"Model version set {experiment_model_version_set_name} doesn't exist. " |
294 | 288 | "Creating new model version set." |
295 | 289 | ) |
@@ -711,21 +705,27 @@ def get(self, eval_id) -> AquaEvaluationDetail: |
711 | 705 | try: |
712 | 706 | log = utils.query_resource(log_id, return_all=False) |
713 | 707 | log_name = log.display_name if log else "" |
714 | | - except Exception: |
| 708 | + except Exception as ex: |
| 709 | + logger.debug(f"Failed to get associated log name. Error: {ex}") |
715 | 710 | pass |
716 | 711 |
|
717 | 712 | if loggroup_id: |
718 | 713 | try: |
719 | 714 | loggroup = utils.query_resource(loggroup_id, return_all=False) |
720 | 715 | loggroup_name = loggroup.display_name if loggroup else "" |
721 | | - except Exception: |
| 716 | + except Exception as ex: |
| 717 | + logger.debug(f"Failed to get associated loggroup name. Error: {ex}") |
722 | 718 | pass |
723 | 719 |
|
724 | 720 | try: |
725 | 721 | introspection = json.loads( |
726 | 722 | self._get_attribute_from_model_metadata(resource, "ArtifactTestResults") |
727 | 723 | ) |
728 | | - except Exception: |
| 724 | + except Exception as ex: |
| 725 | + logger.debug( |
| 726 | + f"There was an issue loading the model attribute as json object for evaluation {eval_id}. " |
| 727 | + f"Setting introspection to empty.\n Error:{ex}" |
| 728 | + ) |
729 | 729 | introspection = {} |
730 | 730 |
|
731 | 731 | summary = AquaEvaluationDetail( |
@@ -878,13 +878,13 @@ def get_status(self, eval_id: str) -> dict: |
878 | 878 | try: |
879 | 879 | log_id = job_run_details.log_details.log_id |
880 | 880 | except Exception as e: |
881 | | - logger.debug(f"Failed to get associated log. {str(e)}") |
| 881 | + logger.debug(f"Failed to get associated log.\nError: {str(e)}") |
882 | 882 | log_id = "" |
883 | 883 |
|
884 | 884 | try: |
885 | 885 | loggroup_id = job_run_details.log_details.log_group_id |
886 | 886 | except Exception as e: |
887 | | - logger.debug(f"Failed to get associated log. {str(e)}") |
| 887 | + logger.debug(f"Failed to get associated log.\nError: {str(e)}") |
888 | 888 | loggroup_id = "" |
889 | 889 |
|
890 | 890 | loggroup_url = get_log_links(region=self.region, log_group_id=loggroup_id) |
@@ -958,7 +958,7 @@ def load_metrics(self, eval_id: str) -> AquaEvalMetrics: |
958 | 958 | ) |
959 | 959 | except Exception as e: |
960 | 960 | logger.debug( |
961 | | - "Failed to load `report.json` from evaluation artifact" f"{str(e)}" |
| 961 | + f"Failed to load `report.json` from evaluation artifact.\nError: {str(e)}" |
962 | 962 | ) |
963 | 963 | json_report = {} |
964 | 964 |
|
@@ -1047,6 +1047,7 @@ def download_report(self, eval_id) -> AquaEvalReport: |
1047 | 1047 | return report |
1048 | 1048 |
|
1049 | 1049 | with tempfile.TemporaryDirectory() as temp_dir: |
| 1050 | + logger.info(f"Downloading evaluation artifact for {eval_id}.") |
1050 | 1051 | DataScienceModel.from_id(eval_id).download_artifact( |
1051 | 1052 | temp_dir, |
1052 | 1053 | auth=self._auth, |
@@ -1200,6 +1201,7 @@ def _delete_job_and_model(job, model): |
1200 | 1201 | def load_evaluation_config(self, container: Optional[str] = None) -> Dict: |
1201 | 1202 | """Loads evaluation config.""" |
1202 | 1203 |
|
| 1204 | + logger.info("Loading evaluation container config.") |
1203 | 1205 | # retrieve the evaluation config by container family name |
1204 | 1206 | evaluation_config = get_evaluation_service_config(container) |
1205 | 1207 |
|
@@ -1279,9 +1281,9 @@ def _get_source( |
1279 | 1281 | raise AquaRuntimeError( |
1280 | 1282 | f"Not supported source type: {resource_type}" |
1281 | 1283 | ) |
1282 | | - except Exception: |
| 1284 | + except Exception as ex: |
1283 | 1285 | logger.debug( |
1284 | | - f"Failed to retrieve source information for evaluation {evaluation.identifier}." |
| 1286 | + f"Failed to retrieve source information for evaluation {evaluation.identifier}.\nError: {str(ex)}" |
1285 | 1287 | ) |
1286 | 1288 | source_name = "" |
1287 | 1289 |
|
|
0 commit comments