mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
local handler
This commit is contained in:
parent
c45a27adb0
commit
409fb8485c
3 changed files with 75 additions and 0 deletions
36
applications/modelling_e2e/local_handler/.env.local.example
Normal file
36
applications/modelling_e2e/local_handler/.env.local.example
Normal file
|
|
@ -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)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
services:
|
||||
modelling-e2e:
|
||||
build:
|
||||
context: ../../../
|
||||
dockerfile: applications/modelling_e2e/Dockerfile
|
||||
ports:
|
||||
- "9004:8080"
|
||||
env_file:
|
||||
- ../../../.env
|
||||
|
|
@ -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)
|
||||
Loading…
Add table
Reference in a new issue