mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Stage-2 entry point for the First Run use case. Adds the `ara_first_run` Lambda package mirroring the `postcode_splitter` template, its typed trigger contract, and a stub `FirstRunPipeline`. - `AraFirstRunTriggerBody`: thin command of five fields — `task_id`, `sub_task_id` (UUID, lifecycle), `portfolio_id`, `property_ids`, `scenario_ids` (int business IDs). No `model_config` override, so Pydantic's default `extra="ignore"` lets the FastAPI backend add fields without breaking deployed lambdas. UPRNs / Scenario defs are deliberately off the event — read from source-of-truth tables. - Thin `handler.py`: validate-and-delegate only, via a named `dispatch_first_run` seam (testable without the Lambda runtime). Subtask status (in-progress/complete/failed) + CloudWatch log URL come for free from the existing `@subtask_handler()` decorator. - `FirstRunPipeline` (orchestration/) stub: `run(command)` receives the validated command. Declares a structural `FirstRunCommand` Protocol (the three business fields) that `AraFirstRunTriggerBody` satisfies, so orchestration needs no application-layer import — rhymes with the `EpcFetcher`/`SolarFetcher` Protocols on IngestionOrchestrator (ADR-0011). Full Ingestion→Baseline→Modelling composition lands in #1136. - Dockerfile / requirements.txt / local_handler/ mirror postcode_splitter. TDD: 7 new tests (trigger-body validation incl. forward-compat + id-types, pipeline seam, handler delegation). pyright strict clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
1.2 KiB
Docker
34 lines
1.2 KiB
Docker
FROM public.ecr.aws/lambda/python:3.11
|
|
|
|
# Postgres host/port/database are baked into the image at build time from
|
|
# the deploy workflow's --build-arg values (GitHub Actions DEV_DB_* secrets),
|
|
# mirroring applications/postcode_splitter/Dockerfile. They map onto the
|
|
# POSTGRES_* names PostgresConfig.from_env reads. Username/password are NOT
|
|
# baked in -- Terraform injects those as Lambda env vars from Secrets Manager.
|
|
ARG DEV_DB_HOST
|
|
ARG DEV_DB_PORT
|
|
ARG DEV_DB_NAME
|
|
|
|
ENV POSTGRES_HOST=${DEV_DB_HOST}
|
|
ENV POSTGRES_PORT=${DEV_DB_PORT}
|
|
ENV POSTGRES_DATABASE=${DEV_DB_NAME}
|
|
|
|
WORKDIR /var/task
|
|
|
|
COPY applications/ara_first_run/requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy the layered source the handler imports from. DDD-shaped packages only —
|
|
# no pandas, no legacy backend/.
|
|
COPY domain/ domain/
|
|
COPY infrastructure/ infrastructure/
|
|
COPY orchestration/ orchestration/
|
|
COPY repositories/ repositories/
|
|
COPY utilities/ utilities/
|
|
COPY applications/ applications/
|
|
|
|
# Place the handler at the Lambda task root so the runtime can resolve
|
|
# ``main.handler`` without an extra package prefix.
|
|
COPY applications/ara_first_run/handler.py /var/task/main.py
|
|
|
|
CMD ["main.handler"]
|