From 5460fe9f9130867e6de578458e7d64c6bb55d53d Mon Sep 17 00:00:00 2001 From: ghyadav Date: Thu, 2 Jan 2025 12:38:36 +0530 Subject: [PATCH] Adding postprocessing to app insights --- .../context/online_eval/evaluate_online.py | 2 -- .../evaluations-built-in/context/online_eval/postprocess.py | 2 +- .../evaluations-built-in/context/online_eval/utils.py | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/evaluate_online.py b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/evaluate_online.py index eb55747a1b..fdd53f1ba1 100644 --- a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/evaluate_online.py +++ b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/evaluate_online.py @@ -40,8 +40,6 @@ def run(): evaluate.run(args) postprocess.run(args) - # Evaluate - if __name__ == "__main__": with mlflow.start_run() as _run: diff --git a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/postprocess.py b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/postprocess.py index da4bb0f6f4..7d6faa78ee 100644 --- a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/postprocess.py +++ b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/postprocess.py @@ -76,7 +76,7 @@ def log_evaluation_event_single(trace_id, span_id, trace_flags, response_id, eva def log_processing_time_event(args): """Log processing time event.""" - body = f"Schedule ID: {args['schedule_id']} | Last Run Time: {args['time_window'][1]}" + body = f"Schedule ID: {args['schedule_name']} | Last Run Time: {args['time_window'][1]}" event = opentelemetry.sdk._logs.LogRecord( timestamp=time_ns(), observed_timestamp=time_ns(), diff --git a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/utils.py b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/utils.py index bc137c47d7..abf243697d 100644 --- a/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/utils.py +++ b/assets/evaluation_on_cloud/environments/evaluations-built-in/context/online_eval/utils.py @@ -8,7 +8,7 @@ from azure.ai.ml import MLClient from azure.ai.ml.identity import AzureMLOnBehalfOfCredential -from azure.identity import ManagedIdentityCredential +from azure.identity import ManagedIdentityCredential, DefaultAzureCredential from azure.monitor.query import LogsQueryClient import logging @@ -26,6 +26,10 @@ def get_managed_identity_credentials(): def get_user_identity_credentials(): """Get the user identity or default credentials.""" + if os.getenv("IS_OFFLINE", "false").lower() == "true": + logger.info("IS_OFFLINE is set to true. Using default credentials.") + credential = DefaultAzureCredential() + return credential logger.info("Trying to load AzureMLOnBehalfOfCredential") credential = AzureMLOnBehalfOfCredential() logger.info("AzureMLOnBehalfOfCredential successfully loaded.")