From 7c943b8c1cdadd5724c4cdcba417cc03947e7c49 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 11 Oct 2023 20:42:04 +0800 Subject: [PATCH] Got the bigger portfolio working --- .idea/Model.iml | 2 +- .idea/misc.xml | 2 +- backend/Property.py | 20 ++++++++++++++++---- backend/app/plan/router.py | 4 ++++ etl/testing_data/engine_inputs.py | 6 +++++- recommendations/WallRecommendations.py | 7 ++++++- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.idea/Model.iml b/.idea/Model.iml index b0f9c00d..4413bb06 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index ca0e1cd9..3b05c6ac 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/backend/Property.py b/backend/Property.py index 2a201b97..be3d8e9b 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -102,7 +102,7 @@ class Property(Definitions): if len(response["rows"]) > 1: newest_response = [ r for r in response["rows"] if - r["inspection-date"] == max([x["inspection-date"] for x in response["rows"]]) + r["lodgement-datetime"] == max([x["lodgement-datetime"] for x in response["rows"]]) ] if len(newest_response) > 1: raise Exception("More than one result found for this address - investigate me") @@ -113,7 +113,12 @@ class Property(Definitions): response["rows"] = newest_response self.data = response["rows"][0] - self.uprn = int(self.data["uprn"]) + # For the moment, if we don't have a UPRN, we don't do anything about it, however we'll handle this in + # the future by using the Ordnance Survey places API + if not self.data["uprn"]: + logger.warning("We do not have a UPRN for this property") + else: + self.uprn = int(self.data["uprn"]) def set_coordinates(self, coordinates): """ @@ -482,7 +487,12 @@ class Property(Definitions): """ if self.uprn is None: - raise ValueError("URPN is not set, run search_address_epc") + logger.warning("We do not have a UPRN for this property - this needs to be implemented") + self.in_conservation_area = False + self.is_listed = False + self.is_heritage = False + self.restricted_measures = True + return # We get the file name for the uprn filtered_df = uprn_filenames[(uprn_filenames['lower'] <= self.uprn) & (uprn_filenames['upper'] >= self.uprn)] @@ -549,8 +559,10 @@ class Property(Definitions): if self.data["property-type"] == "House": self.number_of_floors = estimate_floors(self.floor_area, self.number_of_rooms) - elif self.data["property-type"] == "Flat": + elif self.data["property-type"] in ["Flat", "Bungalow"]: self.number_of_floors = 1 + elif self.data["property-type"] == "Maisonette": + self.number_of_floors = 2 else: raise NotImplementedError("Implement me") diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 50801b64..ea493f73 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -156,6 +156,10 @@ async def trigger_plan(body: PlanTriggerRequest): # Finally, we'll prepare data for predicting the impact on SAP data_processor = DataProcessor(None, newdata=True) data_processor.insert_data(pd.DataFrame([p.get_model_data()])) + # TODO: Temp + if data_processor.data["UPRN"].values[0] == "": + data_processor.data["UPRN"] = 0 + data_processor.pre_process() starting_epc_data = data_processor.get_component_features(suffix="_STARTING") diff --git a/etl/testing_data/engine_inputs.py b/etl/testing_data/engine_inputs.py index 507208e3..8331a90b 100644 --- a/etl/testing_data/engine_inputs.py +++ b/etl/testing_data/engine_inputs.py @@ -48,8 +48,11 @@ def app(): + a_data["rows"] ) + # TODO: For the moment, don't use park homes final_csv_data = pd.DataFrame( - [{"address": x["address"], "postcode": x["postcode"], "Notes": None} for x in final_data] + [{"address": x["address"], "postcode": x["postcode"], "Notes": None} for x + in final_data if + x["property-type"] not in ["Park home"]] ) final_csv_data = pd.concat([starting_csv, final_csv_data]).reset_index(drop=True) @@ -69,3 +72,4 @@ def app(): "goal_value": "B", "trigger_file_path": filename } + print(body) diff --git a/recommendations/WallRecommendations.py b/recommendations/WallRecommendations.py index 05957e90..379f7026 100644 --- a/recommendations/WallRecommendations.py +++ b/recommendations/WallRecommendations.py @@ -10,6 +10,9 @@ from recommendations.recommendation_utils import ( get_recommended_part, get_wall_u_value ) from recommendations.config import PARTIALLY_FILLED_PERCENTAGE_ASSUMPTION +from utils.logger import setup_logger + +logger = setup_logger() class WallRecommendations(Definitions): @@ -125,7 +128,9 @@ class WallRecommendations(Definitions): return - raise NotImplementedError("Not implemented yet") + logger.error("Not implemented yet") + return + # NotImplementedError("Not implemented yet") def find_cavity_insulation(self, u_value, insulation_thickness): """