diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 6c691cc1..0e6b2aa3 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -108,7 +108,6 @@ async def trigger_categorisation( logger.info( f"Chunk {batch_index} sent to SQS. {len(batch_property_ids)} Property IDs in batch (total {len(property_ids)}). Property IDs {min(batch_property_ids)}–{max(batch_property_ids)}. Message ID: {response.get('MessageId')}" - # f"Chunk {batch_index} sent to SQS. Property IDs {min(batch_property_ids)}–{max(batch_property_ids)}" ) await asyncio.sleep(0.05) # Small delay to avoid SQS throttling diff --git a/backend/app/plan/utils.py b/backend/app/plan/utils.py index 2237c38e..7dfe5538 100644 --- a/backend/app/plan/utils.py +++ b/backend/app/plan/utils.py @@ -246,9 +246,13 @@ def build_cloudwatch_log_url(start_ms: int) -> str: Build a CloudWatch Logs URL for the current Lambda invocation, including timestamp window from start_ms to end_ms (epoch ms). """ + logger.info("Building cloudwatch logs URL") region = os.environ["AWS_REGION"] + logger.info("Building cloudwatch logs URL: Got AWS region") log_group = os.environ["AWS_LAMBDA_LOG_GROUP_NAME"] + logger.info("Building cloudwatch logs URL: Got lambda log group name") log_stream = os.environ["AWS_LAMBDA_LOG_STREAM_NAME"] + logger.info("Building cloudwatch logs URL: Got lambda log stream name") # CloudWatch console requires / encoded as $252F encoded_group = log_group.replace("/", "$252F") diff --git a/backend/categorisation/local_handler/invoke_local_lambda.py b/backend/categorisation/local_handler/invoke_local_lambda.py index 8504ff55..0897e7f2 100644 --- a/backend/categorisation/local_handler/invoke_local_lambda.py +++ b/backend/categorisation/local_handler/invoke_local_lambda.py @@ -9,11 +9,12 @@ payload = { { "body": json.dumps( { - "portfolio_id": 556, + "portfolio_id": 569, "scenarios_to_consider": [], "scenario_priority_order": [], - "min_property_id": 653150, - "max_property_id": 653150, + "min_property_id": 660418, + "max_property_id": 660917, + "subtask_id": "6a0bcbac-ddab-435f-8708-8acd4662b067", } ) } diff --git a/backend/categorisation/processor.py b/backend/categorisation/processor.py index a212aac9..88bc121e 100644 --- a/backend/categorisation/processor.py +++ b/backend/categorisation/processor.py @@ -36,6 +36,14 @@ def process_portfolio( logger.info(f"Processing portfolio {portfolio_id}") start_ms = int(time.time() * 1000) + cloud_logs_url = build_cloudwatch_log_url(start_ms) + + if body.subtask_id: + SubTaskInterface().update_subtask_status( + subtask_id=UUID(subtask_id), + status="in progress", + cloud_logs_url=cloud_logs_url, + ) try: @@ -101,14 +109,13 @@ def process_portfolio( _update_plans_in_db(list(plans_by_id.values())) # Mark the subtask as successful + logger.info(f"Successfully updated {len(plans_by_id)} Plans in database") if body.subtask_id: - cloud_logs_url = build_cloudwatch_log_url(start_ms) SubTaskInterface().update_subtask_status( subtask_id=UUID(subtask_id), status="complete", cloud_logs_url=cloud_logs_url, ) - logger.info(f"Successfully updated {len(plans_by_id)} Plans in database") return Response(status_code=200) except Exception as e: