Model/backend/categorisation/handler/handler.py
2026-02-17 11:46:51 +00:00

27 lines
814 B
Python

import json
from typing import Any, Mapping
from backend.categorisation.categorisation_trigger_request import (
CategorisationTriggerRequest,
)
from backend.categorisation.processor import process_portfolio
from utils.logger import setup_logger
logger = setup_logger()
def handler(event: Mapping[str, Any], context: Any) -> None:
process_portfolio(556)
for record in event.get("Records", []):
try:
body_dict = json.loads(record["body"])
logger.debug("Validating request body")
payload = CategorisationTriggerRequest.model_validate(body_dict)
logger.debug("Successfully validated request body")
# process_portfolio(payload.portfolio_id)
except Exception as e:
logger.error(f"Failed to process record: {e}")