diff --git a/applications/modelling_e2e/local_handler/.env.local.example b/applications/modelling_e2e/local_handler/.env.local.example new file mode 100644 index 000000000..8054ecd8b --- /dev/null +++ b/applications/modelling_e2e/local_handler/.env.local.example @@ -0,0 +1,36 @@ +# Local-test environment for the modelling_e2e Lambda. +# +# cp .env.local.example .env.local then fill in the values below. +# +# .env.local is gitignored. The container hits REAL AWS and a REAL Postgres, +# so every value here points at infrastructure that exists. +# +# Set dry_run=true in invoke_local_lambda.py to run the full pipeline without +# writing anything to the DB — safe for local testing. +# +# Keep comments on their own lines — docker-compose's env_file parser folds a +# trailing "# ..." into the value. + +# --- Postgres (infrastructure/postgres/config.py -> PostgresConfig.from_env) --- +# POSTGRES_HOST <- DB_HOST, PORT <- DB_PORT, USERNAME <- DB_USERNAME, +# PASSWORD <- DB_PASSWORD, DATABASE <- DB_NAME. +POSTGRES_HOST= +POSTGRES_PORT=5432 +POSTGRES_USERNAME= +POSTGRES_PASSWORD= +POSTGRES_DATABASE= +# POSTGRES_DRIVER=psycopg2 (optional; defaults to psycopg2) + +# --- Handler config (applications/modelling_e2e/handler.py) --- +# OPEN_EPC_API_TOKEN: gov.uk EPC API token (root .env: OPEN_EPC_API_TOKEN). +# GOOGLE_SOLAR_API_KEY: Google Solar API key (root .env: GOOGLE_SOLAR_API_KEY). +# DATA_BUCKET: S3 bucket holding geospatial parquet files (root .env: DATA_BUCKET). +OPEN_EPC_API_TOKEN= +GOOGLE_SOLAR_API_KEY= +DATA_BUCKET= + +# --- AWS credentials for boto3 (S3 + EPC client) --- +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=eu-west-2 +# AWS_SESSION_TOKEN= (only if using temporary/SSO credentials) diff --git a/applications/modelling_e2e/local_handler/docker-compose.yml b/applications/modelling_e2e/local_handler/docker-compose.yml new file mode 100644 index 000000000..09e41d654 --- /dev/null +++ b/applications/modelling_e2e/local_handler/docker-compose.yml @@ -0,0 +1,9 @@ +services: + modelling-e2e: + build: + context: ../../../ + dockerfile: applications/modelling_e2e/Dockerfile + ports: + - "9004:8080" + env_file: + - ../../../.env diff --git a/applications/modelling_e2e/local_handler/invoke_local_lambda.py b/applications/modelling_e2e/local_handler/invoke_local_lambda.py new file mode 100644 index 000000000..3d2379735 --- /dev/null +++ b/applications/modelling_e2e/local_handler/invoke_local_lambda.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +import json +import requests + +HOST = "localhost" +PORT = "9004" + +LAMBDA_URL = f"http://{HOST}:{PORT}/2015-03-31/functions/function/invocations" + +payload = { + "Records": [ + { + "body": json.dumps( + { + "property_id": 0, + "portfolio_id": 0, + "scenario_id": 0, + "no_solar": False, + "dry_run": True, + } + ) + } + ] +} + +response = requests.post(LAMBDA_URL, json=payload) + +print("Status code:", response.status_code) +print("Response:") +print(response.text)