diff --git a/backend/engine/engine.py b/backend/engine/engine.py index bb465d4c..98db7b88 100644 --- a/backend/engine/engine.py +++ b/backend/engine/engine.py @@ -22,7 +22,7 @@ from backend.app.db.functions.tasks.Tasks import SubTaskInterface from backend.app.plan.schemas import PlanTriggerRequest from backend.app.plan.utils import ( - get_cleaned, patch_epc, extract_property_request_data, parse_eco_packages, handle_error, build_cloudwatch_log_url + get_cleaned, patch_epc, extract_property_request_data, handle_error, build_cloudwatch_log_url ) from backend.app.utils import sap_to_epc import backend.app.assumptions as assumptions @@ -542,15 +542,14 @@ def keep_max_sap_per_measure_type(items): async def model_engine(body: PlanTriggerRequest): + created_at = datetime.now().isoformat() + start_ms = int(time.time() * 1000) logger.info("Model Engine triggered with body: %s", json.loads(body.model_dump_json())) if body.subtask_id: SubTaskInterface().update_subtask_status( - subtask_id=UUID(body.subtask_id), status="in progress", cloud_logs_url=None + subtask_id=UUID(body.subtask_id), status="in progress", cloud_logs_url=build_cloudwatch_log_url(start_ms) ) - created_at = datetime.now().isoformat() - start_ms = int(time.time() * 1000) - try: logger.info("Getting the inputs") @@ -1516,11 +1515,8 @@ async def model_engine(body: PlanTriggerRequest): except Exception as e: # General exception handling return handle_error("An unexpected error occurred.", e, body.subtask_id, 500, start_ms) - cloud_logs_url = build_cloudwatch_log_url(start_ms) # Mark the subtask as successful - SubTaskInterface().update_subtask_status( - subtask_id=UUID(body.subtask_id), status="complete", cloud_logs_url=cloud_logs_url - ) + SubTaskInterface().update_subtask_status(subtask_id=UUID(body.subtask_id), status="complete") logger.info("Model Engine completed successfully")