From e29e96e6177c57aff7ae661bd399f76f4357c7ef Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 28 Nov 2025 07:48:52 +0000 Subject: [PATCH 1/2] fixed errors with logs url --- backend/app/plan/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/app/plan/utils.py b/backend/app/plan/utils.py index c18968f9..d8c54963 100644 --- a/backend/app/plan/utils.py +++ b/backend/app/plan/utils.py @@ -240,8 +240,7 @@ def build_cloudwatch_log_url(start_ms: int) -> str: def handle_error(session, msg, e, subtask_id, status=500, start_ms=None): # When the pipeline fails, handles error process - end_ms = int(time.time() * 1000) - cloud_logs_url = build_cloudwatch_log_url(start_ms, end_ms) + cloud_logs_url = build_cloudwatch_log_url(start_ms) SubTaskInterface().update_subtask_status( subtask_id=UUID(subtask_id), From 54b472dd473742171ccd20ffdc31bfdf58c0ca17 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 28 Nov 2025 08:03:37 +0000 Subject: [PATCH 2/2] fixed cloud logs error --- backend/app/db/functions/address_functions.py | 3 +++ backend/engine/engine.py | 23 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/backend/app/db/functions/address_functions.py b/backend/app/db/functions/address_functions.py index 34dc48c7..b04f14c9 100644 --- a/backend/app/db/functions/address_functions.py +++ b/backend/app/db/functions/address_functions.py @@ -40,6 +40,9 @@ def get_associated_uprns(session: Session, postcode: str, uprn: str): .filter(func.upper(PostcodeSearch.postcode) == postcode) .first() ) + if not record: + # No record found for this postcode + return [] matched_record = _get_associated_records(results=record.result_data["results"], uprn=uprn) diff --git a/backend/engine/engine.py b/backend/engine/engine.py index ebb0a6b8..e9cb86ea 100644 --- a/backend/engine/engine.py +++ b/backend/engine/engine.py @@ -449,6 +449,10 @@ async def model_engine(body: PlanTriggerRequest): plan_input["built_form"] = plan_input["landlord_built_form"].copy() else: plan_input["built_form"] = None + + if "epc_property_type" not in plan_input.columns: + plan_input["epc_property_type"] = None + plan_input["property_type"] = np.where( plan_input["property_type"] == "unknown", plan_input["epc_property_type"], @@ -468,7 +472,7 @@ async def model_engine(body: PlanTriggerRequest): "bungalow": "Bungalow", "block house": "House", "coach house": "House", - "bedsit": "Flat" + "bedsit": "Flat", } built_form_map = { @@ -480,8 +484,19 @@ async def model_engine(body: PlanTriggerRequest): "enclosed mid-terrace": "Enclosed Mid-Terrace", } # We remap the values to match the EPC expected formats - plan_input["property_type"] = plan_input["property_type"].map(property_type_map) - plan_input["built_form"] = plan_input["built_form"].map(built_form_map) + + # This syntax will actually retain any original values, if they don't get mapped + plan_input["property_type"] = ( + plan_input["property_type"] + .map(property_type_map) + .fillna(plan_input["property_type"]) + ) + + plan_input["built_form"] = ( + plan_input["built_form"] + .map(built_form_map) + .fillna(plan_input["built_form"]) + ) plan_input = plan_input.to_dict("records") @@ -669,7 +684,7 @@ async def model_engine(body: PlanTriggerRequest): address=epc_searcher.address_clean, postcode=epc_searcher.postcode_clean, epc_record=prepared_epc, - already_installed=req_data.already_installed + eco_packages[property_id][3], + already_installed=req_data.already_installed + eco_packages.get(property_id)[3], property_valuation=req_data.valuation, non_invasive_recommendations=property_non_invasive_recommendations, energy_assessment=energy_assessment,