Show lodged vs effective main wall per property in the modelling e2e run

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-17 14:15:46 +00:00
parent 3abf2f117a
commit 86b5387a05

View file

@ -61,7 +61,10 @@ from typing import Any, Optional
_REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(_REPO_ROOT)) # worktree root first — avoid the import trap
from datatypes.epc.domain.epc_property_data import EpcPropertyData # noqa: E402
from datatypes.epc.domain.epc_property_data import ( # noqa: E402
BuildingPartIdentifier,
EpcPropertyData,
)
from domain.property.property import Property, PropertyIdentity # noqa: E402
from repositories.property.landlord_override_overlays import ( # noqa: E402
overlays_from,
@ -168,6 +171,18 @@ def _dump_overrides(engine: Engine, property_ids: list[int]) -> None:
print()
def _main_wall_summary(epc: EpcPropertyData) -> str:
"""The MAIN building part's wall codes — what the calculator scores for the
wall U-value. Used to show whether a Landlord Override moved them."""
for part in epc.sap_building_parts:
if part.identifier is BuildingPartIdentifier.MAIN:
return (
f"wall_construction={part.wall_construction} "
f"wall_insulation_type={part.wall_insulation_type}"
)
return "no MAIN building part"
def _scenario_for(session: Session, scenario_id: int) -> Scenario:
"""Read the Scenario the run targets (read-only). An Increasing-EPC Scenario
must carry a ``goal_value`` (band) the old null-band rows were a fixed bug
@ -450,6 +465,15 @@ def main() -> None:
),
)
effective_epc: EpcPropertyData = overlaid_property.effective_epc
lodged_wall = _main_wall_summary(epc)
effective_wall = _main_wall_summary(effective_epc)
if lodged_wall != effective_wall:
print(
f" overlay moved the main wall: lodged [{lodged_wall}] "
f"-> effective [{effective_wall}]"
)
else:
print(f" overlay no-op on main wall: [{lodged_wall}]")
spatial: Optional[SpatialReference] = _spatial_for(geospatial, uprn)
restrictions: PlanningRestrictions = (
spatial.restrictions if spatial is not None else PlanningRestrictions()