Skip a landlord override that targets a building part the EPC lacks 🟩

A Landlord Override can reference a building part the lodged or predicted EPC
never carried (e.g. an extension_1 override on a property whose EPC has only
main). apply_simulations indexed parts_by_id[identifier] unguarded, raising
KeyError and aborting the whole property's modelling. Now the orphaned part is
skipped. Recovers 14 of the 22 modelling_e2e failures in portfolio 796.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-23 15:36:37 +00:00
parent d1a2ee11e8
commit 23ccfb0d0b

View file

@ -41,7 +41,13 @@ def apply_simulations(
for simulation in simulations:
for identifier, overlay in simulation.building_parts.items():
part = parts_by_id[identifier]
# A Landlord Override can target a building part the lodged (or
# predicted) EPC never carried — e.g. an `extension_1` override on a
# property whose EPC has only `main`. Skip the orphaned part rather
# than crashing the whole property's modelling on a `KeyError`.
part = parts_by_id.get(identifier)
if part is None:
continue
for overlay_field in fields(overlay):
value = getattr(overlay, overlay_field.name)
if value is not None: