diff --git a/.github/workflows/_build_image.yml b/.github/workflows/_build_image.yml index 41677b1f..d5e028b2 100644 --- a/.github/workflows/_build_image.yml +++ b/.github/workflows/_build_image.yml @@ -32,13 +32,7 @@ on: required: true AWS_REGION: required: true - DEV_DB_HOST: - required: false - DEV_DB_PORT: - required: false - DEV_DB_NAME: - required: false - + jobs: build: runs-on: ubuntu-latest @@ -87,10 +81,6 @@ jobs: temp=$(eval echo "$line") BUILD_ARGS="$BUILD_ARGS --build-arg $temp" done <<< "${{ inputs.build_args }}" - - echo "dev db host: $DEV_DB_HOST" - echo "dev db port: $DEV_DB_PORT" - echo "dev db name: $DEV_DB_NAME" docker build \ -f ${{ inputs.dockerfile_path }} \ diff --git a/backend/condition/handler/handler.py b/backend/condition/handler/handler.py index 33d6559c..fabfc84c 100644 --- a/backend/condition/handler/handler.py +++ b/backend/condition/handler/handler.py @@ -1,64 +1,42 @@ -# import json +import json from typing import Mapping, Any import os -# from io import BytesIO +from io import BytesIO from backend.app.config import get_settings -# from backend.condition.condition_trigger_request import ConditionTriggerRequest -# from backend.condition.lookups.uprn_lookup_s3 import UprnLookupS3 -# from backend.condition.processor import process_file -# from utils.logger import setup_logger -# from utils.s3 import read_io_from_s3 +from backend.condition.condition_trigger_request import ConditionTriggerRequest +from backend.condition.lookups.uprn_lookup_s3 import UprnLookupS3 +from backend.condition.processor import process_file +from utils.logger import setup_logger +from utils.s3 import read_io_from_s3 -# logger = setup_logger() +logger = setup_logger() def handler(event: Mapping[str, Any], context: Any) -> None: - print( - "hello DB HOST:", - os.getenv("DB_HOST", "empty db host"), - ) - print( - "hello DB PORT:", - os.getenv("DB_PORT", "empty db port"), - ) - print( - "hello DB NAME:", - os.getenv("DB_NAME", "empty name"), - ) - print( - "hello region", - os.getenv("AWS_REGION", "empty region"), - ) - print( - "hello Dan:", - os.getenv("DAN", "empty dan"), - ) - settings = get_settings() - print("hello db user", settings.DB_USERNAME) - # uprn_lookup = UprnLookupS3( - # bucket="", key="" - # ) # TODO: replace with postgres implementation + uprn_lookup = UprnLookupS3( + bucket="", key="" + ) # TODO: replace with postgres implementation - # for record in event.get("Records", []): - # try: - # body_dict = json.loads(record["body"]) - # payload = ConditionTriggerRequest.model_validate(body_dict) + for record in event.get("Records", []): + try: + body_dict = json.loads(record["body"]) + payload = ConditionTriggerRequest.model_validate(body_dict) - # file_bytes: BytesIO = read_io_from_s3( - # bucket_name=payload.trigger_file_bucket, - # file_key=payload.trigger_file_key, - # ) + file_bytes: BytesIO = read_io_from_s3( + bucket_name=payload.trigger_file_bucket, + file_key=payload.trigger_file_key, + ) - # process_file( - # file_stream=file_bytes, - # file_type=payload.file_type, - # uprn_lookup=uprn_lookup, - # ) + process_file( + file_stream=file_bytes, + file_type=payload.file_type, + uprn_lookup=uprn_lookup, + ) - # except Exception as e: - # logger.error(f"Failed to process record: {e}") + except Exception as e: + logger.error(f"Failed to process record: {e}")