Skip to content

Add ignore validation flag while registering model & improve logging #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9cc430b
add ignore validation flag while registering model
VipulMascarenhas Dec 12, 2024
bd4205e
update logging
VipulMascarenhas Dec 12, 2024
9881dcb
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Dec 12, 2024
6aaa3ef
improve error message logging
VipulMascarenhas Dec 14, 2024
6b2e4aa
update handler tests
VipulMascarenhas Dec 14, 2024
71269a7
update logging level
VipulMascarenhas Dec 16, 2024
bff4771
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Dec 17, 2024
59a042b
log request ids
VipulMascarenhas Jan 3, 2025
a8321a1
update logging for model operations
VipulMascarenhas Jan 3, 2025
fe1eada
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 3, 2025
ee8dbf8
update logging for deployment operations
VipulMascarenhas Jan 3, 2025
68f325a
update logging for deployment operations
VipulMascarenhas Jan 4, 2025
86ef7ad
update logging for finetuning operations
VipulMascarenhas Jan 4, 2025
adace88
update logging for finetuning operations
VipulMascarenhas Jan 4, 2025
38e046c
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 6, 2025
e3cb8d5
update evaluation validation for create API
VipulMascarenhas Jan 6, 2025
8005294
merge ODSC-65657/ignore_config_validation changes
VipulMascarenhas Jan 6, 2025
b0827e5
update evaluation logging
VipulMascarenhas Jan 6, 2025
ed9504d
update evaluation logging
VipulMascarenhas Jan 6, 2025
fc0caa1
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 6, 2025
b83e1e9
Merge branch 'ODSC-65657/ignore_config_validation' of github.com:orac…
VipulMascarenhas Jan 6, 2025
8b603b7
Merge branch 'ODSC-65657/ignore_config_validation' into ODSC-65743/ad…
VipulMascarenhas Jan 6, 2025
ca02f03
update tests
VipulMascarenhas Jan 6, 2025
44d41ce
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 6, 2025
d39a1ff
Merge branch 'ODSC-65657/ignore_config_validation' of github.com:orac…
VipulMascarenhas Jan 6, 2025
f4240ce
Merge branch 'ODSC-65657/ignore_config_validation' into ODSC-65743/ad…
VipulMascarenhas Jan 6, 2025
d7ff57d
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 8, 2025
fde6c46
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 9, 2025
ed4098d
add missing request id
VipulMascarenhas Jan 10, 2025
8db09df
Additional logging statements for AI Quick Actions operations (#1034)
VipulMascarenhas Jan 10, 2025
6b70096
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 10, 2025
5621a06
Merge branch 'main' into ODSC-65657/ignore_config_validation
VipulMascarenhas Jan 13, 2025
4cbd7e0
revert to previous validation
VipulMascarenhas Jan 14, 2025
3bc31e5
Resolve merge conflicts
VipulMascarenhas Jan 31, 2025
7616ff2
fix tests after merge
VipulMascarenhas Jan 31, 2025
85a825b
Merge branch 'main' into ODSC-65657/ignore_config_validation
mayoor Feb 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ads/aqua/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

import json
Expand Down Expand Up @@ -298,7 +298,7 @@ def get_config(self, model_id: str, config_file_name: str) -> Dict:
config = {}
artifact_path = get_artifact_path(oci_model.custom_metadata_list)
if not artifact_path:
logger.error(
logger.debug(
f"Failed to get artifact path from custom metadata for the model: {model_id}"
)
return config
Expand Down
32 changes: 20 additions & 12 deletions ads/aqua/evaluation/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
import base64
import json
Expand Down Expand Up @@ -199,11 +199,11 @@ def create(
eval_inference_configuration = (
container.spec.evaluation_configuration
)
except Exception:
except Exception as ex:
logger.debug(
f"Could not load inference config details for the evaluation source id: "
f"{create_aqua_evaluation_details.evaluation_source_id}. Please check if the container"
f" runtime has the correct SMC image information."
f" runtime has the correct SMC image information.\nError: {str(ex)}"
)
elif (
DataScienceResource.MODEL
Expand Down Expand Up @@ -289,7 +289,7 @@ def create(
f"Invalid experiment name. Please provide an experiment with `{Tags.AQUA_EVALUATION}` in tags."
)
except Exception:
logger.debug(
logger.info(
f"Model version set {experiment_model_version_set_name} doesn't exist. "
"Creating new model version set."
)
Expand Down Expand Up @@ -711,21 +711,27 @@ def get(self, eval_id) -> AquaEvaluationDetail:
try:
log = utils.query_resource(log_id, return_all=False)
log_name = log.display_name if log else ""
except Exception:
except Exception as ex:
logger.debug(f"Failed to get associated log name. Error: {ex}")
pass

if loggroup_id:
try:
loggroup = utils.query_resource(loggroup_id, return_all=False)
loggroup_name = loggroup.display_name if loggroup else ""
except Exception:
except Exception as ex:
logger.debug(f"Failed to get associated loggroup name. Error: {ex}")
pass

try:
introspection = json.loads(
self._get_attribute_from_model_metadata(resource, "ArtifactTestResults")
)
except Exception:
except Exception as ex:
logger.debug(
f"There was an issue loading the model attribute as json object for evaluation {eval_id}. "
f"Setting introspection to empty.\n Error:{ex}"
)
introspection = {}

summary = AquaEvaluationDetail(
Expand Down Expand Up @@ -878,13 +884,13 @@ def get_status(self, eval_id: str) -> dict:
try:
log_id = job_run_details.log_details.log_id
except Exception as e:
logger.debug(f"Failed to get associated log. {str(e)}")
logger.debug(f"Failed to get associated log.\nError: {str(e)}")
log_id = ""

try:
loggroup_id = job_run_details.log_details.log_group_id
except Exception as e:
logger.debug(f"Failed to get associated log. {str(e)}")
logger.debug(f"Failed to get associated log.\nError: {str(e)}")
loggroup_id = ""

loggroup_url = get_log_links(region=self.region, log_group_id=loggroup_id)
Expand Down Expand Up @@ -958,7 +964,7 @@ def load_metrics(self, eval_id: str) -> AquaEvalMetrics:
)
except Exception as e:
logger.debug(
"Failed to load `report.json` from evaluation artifact" f"{str(e)}"
f"Failed to load `report.json` from evaluation artifact.\nError: {str(e)}"
)
json_report = {}

Expand Down Expand Up @@ -1047,6 +1053,7 @@ def download_report(self, eval_id) -> AquaEvalReport:
return report

with tempfile.TemporaryDirectory() as temp_dir:
logger.info(f"Downloading evaluation artifact for {eval_id}.")
DataScienceModel.from_id(eval_id).download_artifact(
temp_dir,
auth=self._auth,
Expand Down Expand Up @@ -1200,6 +1207,7 @@ def _delete_job_and_model(job, model):
def load_evaluation_config(self, container: Optional[str] = None) -> Dict:
"""Loads evaluation config."""

logger.info("Loading evaluation container config.")
# retrieve the evaluation config by container family name
evaluation_config = get_evaluation_service_config(container)

Expand Down Expand Up @@ -1279,9 +1287,9 @@ def _get_source(
raise AquaRuntimeError(
f"Not supported source type: {resource_type}"
)
except Exception:
except Exception as ex:
logger.debug(
f"Failed to retrieve source information for evaluation {evaluation.identifier}."
f"Failed to retrieve source information for evaluation {evaluation.identifier}.\nError: {str(ex)}"
)
source_name = ""

Expand Down
21 changes: 14 additions & 7 deletions ads/aqua/extension/aqua_ws_msg_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

import traceback
import uuid
from abc import abstractmethod
from http.client import responses
from typing import List
Expand Down Expand Up @@ -34,7 +34,7 @@ def __init__(self, message: str):
self.telemetry = TelemetryClient(
bucket=AQUA_TELEMETRY_BUCKET, namespace=AQUA_TELEMETRY_BUCKET_NS
)
except:
except Exception:
pass

@staticmethod
Expand Down Expand Up @@ -66,24 +66,31 @@ def write_error(self, status_code, **kwargs):
"message": message,
"service_payload": service_payload,
"reason": reason,
"request_id": str(uuid.uuid4()),
}
exc_info = kwargs.get("exc_info")
if exc_info:
logger.error("".join(traceback.format_exception(*exc_info)))
logger.error(
f"Error Request ID: {reply['request_id']}\n"
f"Error: {''.join(traceback.format_exception(*exc_info))}"
)
e = exc_info[1]
if isinstance(e, HTTPError):
reply["message"] = e.log_message or message
reply["reason"] = e.reason
else:
logger.warning(reply["message"])

logger.error(
f"Error Request ID: {reply['request_id']}\n"
f"Error: {reply['message']} {reply['reason']}"
)
# telemetry may not be present if there is an error while initializing
if hasattr(self, "telemetry"):
aqua_api_details = kwargs.get("aqua_api_details", {})
self.telemetry.record_event_async(
category="aqua/error",
action=str(status_code),
value=reason,
**aqua_api_details
**aqua_api_details,
)
response = AquaWsError(
status=status_code,
Expand Down
21 changes: 12 additions & 9 deletions ads/aqua/extension/base_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/


Expand Down Expand Up @@ -35,7 +34,7 @@ def __init__(
self.telemetry = TelemetryClient(
bucket=AQUA_TELEMETRY_BUCKET, namespace=AQUA_TELEMETRY_BUCKET_NS
)
except:
except Exception:
pass

@staticmethod
Expand Down Expand Up @@ -82,19 +81,23 @@ def write_error(self, status_code, **kwargs):
"message": message,
"service_payload": service_payload,
"reason": reason,
"request_id": str(uuid.uuid4()),
}
exc_info = kwargs.get("exc_info")
if exc_info:
logger.error("".join(traceback.format_exception(*exc_info)))
logger.error(
f"Error Request ID: {reply['request_id']}\n"
f"Error: {''.join(traceback.format_exception(*exc_info))}"
)
e = exc_info[1]
if isinstance(e, HTTPError):
reply["message"] = e.log_message or message
reply["reason"] = e.reason if e.reason else reply["reason"]
reply["request_id"] = str(uuid.uuid4())
else:
reply["request_id"] = str(uuid.uuid4())

logger.warning(reply["message"])
logger.error(
f"Error Request ID: {reply['request_id']}\n"
f"Error: {reply['message']} {reply['reason']}"
)

# telemetry may not be present if there is an error while initializing
if hasattr(self, "telemetry"):
Expand All @@ -103,7 +106,7 @@ def write_error(self, status_code, **kwargs):
category="aqua/error",
action=str(status_code),
value=reason,
**aqua_api_details
**aqua_api_details,
)

self.finish(json.dumps(reply))
Expand Down
5 changes: 5 additions & 0 deletions ads/aqua/extension/model_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def post(self, *args, **kwargs): # noqa: ARG002
ignore_patterns = input_data.get("ignore_patterns")
freeform_tags = input_data.get("freeform_tags")
defined_tags = input_data.get("defined_tags")
ignore_model_artifact_check = (
str(input_data.get("ignore_model_artifact_check", "false")).lower()
== "true"
)

return self.finish(
AquaModelApp().register(
Expand All @@ -158,6 +162,7 @@ def post(self, *args, **kwargs): # noqa: ARG002
ignore_patterns=ignore_patterns,
freeform_tags=freeform_tags,
defined_tags=defined_tags,
ignore_model_artifact_check=ignore_model_artifact_check,
)
)

Expand Down
8 changes: 7 additions & 1 deletion ads/aqua/finetuning/finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,19 @@ def create(
defined_tags=model_defined_tags,
),
)
logger.debug(
f"Successfully updated model custom metadata list and freeform tags for the model {ft_model.id}."
)

self.update_model_provenance(
model_id=ft_model.id,
update_model_provenance_details=UpdateModelProvenanceDetails(
training_id=ft_job_run.id
),
)
logger.debug(
f"Successfully updated model provenance for the model {ft_model.id}."
)

# tracks the shape and replica used for fine-tuning the service models
telemetry_kwargs = (
Expand Down Expand Up @@ -564,7 +570,7 @@ def get_finetuning_config(self, model_id: str) -> Dict:
config = self.get_config(model_id, AQUA_MODEL_FINETUNING_CONFIG)
if not config:
logger.debug(
f"Fine-tuning config for custom model: {model_id} is not available."
f"Fine-tuning config for custom model: {model_id} is not available. Use defaults."
)
return config

Expand Down
1 change: 1 addition & 0 deletions ads/aqua/model/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class ImportModelDetails(CLIBuilderMixin):
ignore_patterns: Optional[List[str]] = None
freeform_tags: Optional[dict] = None
defined_tags: Optional[dict] = None
ignore_model_artifact_check: Optional[bool] = None

def __post_init__(self):
self._command = "model register"
Loading