mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
move handler stuff to applications directory
This commit is contained in:
parent
a54671e569
commit
c45a27adb0
6 changed files with 27 additions and 12 deletions
|
|
@ -2,7 +2,7 @@ FROM public.ecr.aws/lambda/python:3.11
|
|||
|
||||
WORKDIR /var/task
|
||||
|
||||
COPY lambdas/modelling_e2e/requirements.txt .
|
||||
COPY applications/modelling_e2e/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY datatypes/ datatypes/
|
||||
|
|
@ -19,6 +19,6 @@ COPY tests/__init__.py tests/__init__.py
|
|||
COPY tests/orchestration/__init__.py tests/orchestration/__init__.py
|
||||
COPY tests/orchestration/fakes.py tests/orchestration/fakes.py
|
||||
|
||||
COPY lambdas/ lambdas/
|
||||
COPY applications/ applications/
|
||||
|
||||
CMD ["lambdas.modelling_e2e.handler.handler"]
|
||||
CMD ["applications.modelling_e2e.handler.handler"]
|
||||
|
|
@ -39,6 +39,7 @@ from infrastructure.solar.google_solar_api_client import (
|
|||
BuildingInsightsNotFoundError,
|
||||
GoogleSolarApiClient,
|
||||
)
|
||||
from applications.modelling_e2e.modelling_e2e_trigger_body import ModellingE2ETriggerBody
|
||||
from repositories.geospatial.geospatial_s3_repository import (
|
||||
GeospatialS3Repository,
|
||||
ParquetReader,
|
||||
|
|
@ -102,11 +103,12 @@ def _solar_insights_for(
|
|||
|
||||
@task_handler(task_source="modelling_e2e", source=Source.PROPERTY)
|
||||
def handler(body: dict[str, Any], context: Any) -> None:
|
||||
property_id = int(body["property_id"])
|
||||
portfolio_id = int(body["portfolio_id"])
|
||||
scenario_id = int(body["scenario_id"])
|
||||
no_solar = bool(body.get("no_solar", False))
|
||||
dry_run = bool(body.get("dry_run", False))
|
||||
trigger = ModellingE2ETriggerBody.model_validate(body)
|
||||
property_id = trigger.property_id
|
||||
portfolio_id = trigger.portfolio_id
|
||||
scenario_id = trigger.scenario_id
|
||||
no_solar = trigger.no_solar
|
||||
dry_run = trigger.dry_run
|
||||
|
||||
engine = _get_engine()
|
||||
epc_client = EpcClientService(os.environ["OPEN_EPC_API_TOKEN"])
|
||||
|
|
@ -135,7 +137,9 @@ def handler(body: dict[str, Any], context: Any) -> None:
|
|||
effective_epc = overlaid.effective_epc
|
||||
|
||||
spatial = _spatial_for(geospatial, uprn)
|
||||
restrictions = spatial.restrictions if spatial is not None else PlanningRestrictions()
|
||||
restrictions = (
|
||||
spatial.restrictions if spatial is not None else PlanningRestrictions()
|
||||
)
|
||||
solar_insights = None if no_solar else _solar_insights_for(solar_client, spatial)
|
||||
|
||||
with Session(engine) as session:
|
||||
|
|
@ -144,9 +148,9 @@ def handler(body: dict[str, Any], context: Any) -> None:
|
|||
|
||||
# secondary_heating_removal is absent from the live material.type enum;
|
||||
# exclude it unconditionally until the catalogue gap is resolved.
|
||||
considered: Optional[frozenset[MeasureType]] = (
|
||||
frozenset(MeasureType) - {MeasureType.SECONDARY_HEATING_REMOVAL}
|
||||
)
|
||||
considered: Optional[frozenset[MeasureType]] = frozenset(MeasureType) - {
|
||||
MeasureType.SECONDARY_HEATING_REMOVAL
|
||||
}
|
||||
|
||||
plan = run_modelling(
|
||||
effective_epc,
|
||||
11
applications/modelling_e2e/modelling_e2e_trigger_body.py
Normal file
11
applications/modelling_e2e/modelling_e2e_trigger_body.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class ModellingE2ETriggerBody(BaseModel):
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
property_id: int
|
||||
portfolio_id: int
|
||||
scenario_id: int
|
||||
no_solar: bool = False
|
||||
dry_run: bool = False
|
||||
Loading…
Add table
Reference in a new issue