diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index cd73cce3..f059c568 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -3,14 +3,12 @@ import json import math from datetime import datetime -import pandas as pd from fastapi import APIRouter, Depends from backend.app.dependencies import validate_token from backend.app.plan.schemas import PlanTriggerRequest from backend.app.config import get_settings from sqlalchemy.orm import sessionmaker from utils.logger import setup_logger -from utils.s3 import read_excel_from_s3 from backend.app.db.connection import db_engine from backend.app.db.functions.recommendations_functions import create_scenario @@ -45,14 +43,8 @@ async def trigger_plan_entrypoint(body: PlanTriggerRequest): # If file_format is domna_asset_list and type is xlsx, read and chunk it if data.get("file_format") == "domna_asset_list" and data.get("file_type") == "xlsx": try: - input_data: pd.DataFrame = read_excel_from_s3( - bucket_name=settings.PLAN_TRIGGER_BUCKET, - file_key=data.get("trigger_file_path"), - sheet_name=data.get("sheet_name"), - header_row=0 - ) - total_rows = len(input_data) + total_rows = body.get("sheet_count", 0) chunk_size = 30 total_chunks = math.ceil(total_rows / chunk_size) diff --git a/backend/app/plan/schemas.py b/backend/app/plan/schemas.py index a6d21ae7..d5b92256 100644 --- a/backend/app/plan/schemas.py +++ b/backend/app/plan/schemas.py @@ -108,6 +108,7 @@ class PlanTriggerRequest(BaseModel): file_type: Optional[Literal["csv", "xlsx"]] = None file_format: Optional[Literal["domna_asset_list"]] = None sheet_name: Optional[str] = None + sheet_count: Optional[int] = None # If one of index_start or index_end is set, the other must be set too index_start: Optional[int] = None index_end: Optional[int] = None diff --git a/backend/app/requirements/requirements.txt b/backend/app/requirements/requirements.txt index ca9d0f32..14ec525f 100644 --- a/backend/app/requirements/requirements.txt +++ b/backend/app/requirements/requirements.txt @@ -8,4 +8,5 @@ cryptography==43.0.3 mangum==0.19.0 # AWS boto3==1.35.44 - +# Data +openpyxl==3.1.2 diff --git a/backend/engine/handler.py b/backend/engine/handler.py index fdf48db3..8fce7f16 100644 --- a/backend/engine/handler.py +++ b/backend/engine/handler.py @@ -11,6 +11,7 @@ def handler(event, context): """ Lambda handler that triggers the model engine for each SQS message. """ + logger.info("Received event: %s", json.dumps(event, indent=2)) for record in event.get("Records", []): try: body_dict = json.loads(record["body"])