debugging bigger peabody portfolio - setting default floor type with warning

This commit is contained in:
Khalim Conn-Kowlessar 2025-12-01 16:54:18 +00:00
parent 753ef66f48
commit 4e07049edb
4 changed files with 20 additions and 12 deletions

View file

@ -1078,7 +1078,12 @@ class Property:
elif self.floor["thermal_transmittance"] is not None:
self.floor_type = "solid"
else:
raise NotImplementedError("Implement this floor type")
# in this case, it's not super clear what the floor type is, so we default - this is a temp
logger.warning(
f"Could not determine floor type, given: '{self.floor['original_description']}', defaulting to "
f"suspended for property {self.uprn}"
)
self.floor_type = "suspended"
@staticmethod
def _extract_component(

View file

@ -120,7 +120,9 @@ async def trigger_plan_entrypoint(body: PlanTriggerRequest):
f"Chunk {i} sent to SQS. Rows {index_start}{index_end}. Message ID: {response.get('MessageId')}"
)
await asyncio.sleep(random.uniform(0.1, 0.5)) # Delay to reduce spike pressure
await asyncio.sleep(0.1) # Small delay to avoid SQS throttling
# await asyncio.sleep(random.uniform(0.1, 0.5)) # Delay to reduce spike pressure
except Exception as e:
logger.error("Error during Excel file handling: %s", e)

View file

@ -210,9 +210,9 @@ archetypes = sustainability_data[archetype_variables + ["UPRN"]].dropna().groupb
archetypes["Cumulative Count"] = archetypes["Count"].cumsum()
archetypes["Cumulative Proportion"] = archetypes["Cumulative Count"] / archetypes["Count"].sum()
archetypes_85 = archetypes[archetypes["Cumulative Proportion"] <= 0.80]
archetypes_85["Archetypes_85_reference"] = archetypes_85.index + 1
archetypes_85["Archetypes_85_reference"] = "Archetype_Sample_" + archetypes_85["Archetypes_85_reference"].astype(str)
archetypes_95 = archetypes[archetypes["Cumulative Proportion"] <= 0.97]
archetypes_95["Archetypes_95_reference"] = archetypes_95.index + 1
archetypes_95["Archetypes_95_reference"] = "Archetype_Sample_" + archetypes_95["Archetypes_95_reference"].astype(str)
# For the sample, look for invalid looking UPRNs and remove them.
sample_from = sustainability_data.copy()
@ -227,13 +227,13 @@ sample_from = sample_from[~pd.isnull(sample_from["UPRN"])]
# We now take a sample of the properties that represent 85% of the total properties
sample_from = sample_from.merge(
archetypes_85,
archetypes_95,
on=archetype_variables,
how="inner"
)
# We take 1 random property, by archetype 85 reference
modelling_sample = sample_from.groupby("Archetypes_85_reference").apply(
# We take 1 random property, by archetype reference
modelling_sample = sample_from.groupby("Archetypes_95_reference").apply(
lambda x: x.sample(1, random_state=42)
).reset_index(drop=True)
@ -248,7 +248,7 @@ def compare_distributions(full_df, sample_df, column):
for col in archetype_variables:
print(f"--- {col} ---")
print(compare_distributions(sustainability_data, modelling_sample, col))
print(compare_distributions(sustainability_data, sample_from, col))
# prepare
modelling_sample["domna_property_id"] = modelling_sample.index + 1
@ -263,7 +263,7 @@ modelling_sample = modelling_sample.rename(
}
)
modelling_sample["domna_built_form"] = modelling_sample["domna_built_form"].map(
modelling_sample["landlord_built_form"] = modelling_sample["landlord_built_form"].map(
{
"MidTerrace": "Mid-Terrace",
"EndTerrace": "End-Terrace",
@ -274,7 +274,7 @@ modelling_sample["domna_built_form"] = modelling_sample["domna_built_form"].map(
}
)
if pd.isnull(modelling_sample["domna_built_form"]).sum():
if pd.isnull(modelling_sample["landlord_built_form"]).sum():
raise ValueError("Some built forms are null after mapping")
@ -292,7 +292,7 @@ modelling_sample.to_excel(
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/modelling_sample.xlsx",
)
# Save the archetype definitions
archetypes_85.to_excel(
archetypes_95.to_excel(
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/archetypes_85.xlsx",
)
# Save the full archetypes

View file

@ -684,6 +684,7 @@ class RetrieveFindMyEpc:
"Heating controls recommendation": [],
"Replace boiler with Band A condensing boiler": ["boiler_upgrade"],
"Band A condensing gas boiler": ["boiler_upgrade"],
"Install Band A condensing heating unit": ["boiler_upgrade"],
"Solar panel recommendation": [],
"Double glazing recommendation": [],
"Solid wall insulation recommendation": [],