mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
get the task statuses to update
This commit is contained in:
parent
b7f7c40552
commit
bb51d16f7f
4 changed files with 17 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue