From 296bbcc6267aa02eb7c3e54f405d0264b6b31581 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 22 Apr 2026 12:39:44 +0000 Subject: [PATCH] added logic to add to serverless --- asset_list/app.py | 6 +++--- infrastructure/terraform/lambda/fast-api/main.tf | 13 ++++++++++++- serverless.yml | 6 +++++- sfr/principal_pitch/2_export_data.py | 12 ++++++------ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/asset_list/app.py b/asset_list/app.py index 25c72bda..49ec48a0 100644 --- a/asset_list/app.py +++ b/asset_list/app.py @@ -74,7 +74,7 @@ def app(): """ data_folder = "/workspaces/model/asset_list" - data_filename = "foom (2).xlsx" + data_filename = "2026-04-22T08_22_00.779745_61049fd3.xlsx" sheet_name = "in" postcode_column = "postcode_clean" address1_column = "address2uprn_address" @@ -84,8 +84,8 @@ def app(): missing_postcodes_method = None landlord_year_built = None landlord_os_uprn = "address2uprn_uprn" - landlord_property_type = None # Good to include if landlord gave - landlord_built_form = None # Good to include if landlord gave + landlord_property_type = "Property Type" # Good to include if landlord gave + landlord_built_form = "Built Form" # Good to include if landlord gave landlord_wall_construction = None landlord_roof_construction = None landlord_heating_system = None diff --git a/infrastructure/terraform/lambda/fast-api/main.tf b/infrastructure/terraform/lambda/fast-api/main.tf index 8dcbb8a3..3a2b5a5f 100644 --- a/infrastructure/terraform/lambda/fast-api/main.tf +++ b/infrastructure/terraform/lambda/fast-api/main.tf @@ -37,6 +37,15 @@ data "terraform_remote_state" "postcode_splitter" { } } +data "terraform_remote_state" "bulk_address2uprn_combiner" { + backend = "s3" + config = { + bucket = "bulk-address2uprn-combiner-terraform-state", + key = "env:/${var.stage}/terraform.tfstate" + region = "eu-west-2" + } +} + ############################################ # Load Credentials ############################################ @@ -95,6 +104,7 @@ module "fastapi" { ENGINE_SQS_URL = data.terraform_remote_state.engine.outputs.ara_engine_queue_url CATEGORISATION_SQS_URL = data.terraform_remote_state.categorisation.outputs.categorisation_queue_url POSTCODE_SPLITTER_SQS_URL = data.terraform_remote_state.postcode_splitter.outputs.postcode_splitter_queue_url + COMBINER_SQS_URL = data.terraform_remote_state.bulk_address2uprn_combiner.outputs.bulk_address2uprn_combiner_queue_url } } @@ -115,7 +125,8 @@ module "fastapi_sqs_policy" { resources = [ data.terraform_remote_state.engine.outputs.ara_engine_queue_arn, data.terraform_remote_state.categorisation.outputs.categorisation_queue_arn, - data.terraform_remote_state.postcode_splitter.outputs.postcode_splitter_queue_arn + data.terraform_remote_state.postcode_splitter.outputs.postcode_splitter_queue_arn, + data.terraform_remote_state.bulk_address2uprn_combiner.outputs.bulk_address2uprn_combiner_queue_arn ] conditions = null diff --git a/serverless.yml b/serverless.yml index cf369a36..43b8b4e5 100644 --- a/serverless.yml +++ b/serverless.yml @@ -33,8 +33,10 @@ provider: HEAT_BASELINE_PREDICTIONS_BUCKET: ${env:HEAT_BASELINE_PREDICTIONS_BUCKET} ENGINE_SQS_URL: Ref: EngineQueue - # hardcode the categorisation queue for now as it's created in terraform + # hardcoded queues (created in terraform) CATEGORISATION_SQS_URL: "https://sqs.eu-west-2.amazonaws.com/337213553626/categorisation-queue-dev" + POSTCODE_SPLITTER_SQS_URL: "https://sqs.eu-west-2.amazonaws.com/337213553626/postcode-splitter-queue-dev" + COMBINER_SQS_URL: "https://sqs.eu-west-2.amazonaws.com/337213553626/bulk-address2uprn-combiner-queue-dev" plugins: - serverless-python-requirements @@ -112,6 +114,8 @@ resources: Resource: - Fn::GetAtt: [ EngineQueue, Arn ] - "arn:aws:sqs:eu-west-2:337213553626:categorisation-queue-dev" + - "arn:aws:sqs:eu-west-2:337213553626:postcode-splitter-queue-dev" + - "arn:aws:sqs:eu-west-2:337213553626:bulk-address2uprn-combiner-queue-dev" - Effect: Allow Action: - s3:GetObject diff --git a/sfr/principal_pitch/2_export_data.py b/sfr/principal_pitch/2_export_data.py index 06727f86..b275086d 100644 --- a/sfr/principal_pitch/2_export_data.py +++ b/sfr/principal_pitch/2_export_data.py @@ -26,13 +26,13 @@ from backend.app.db.functions.materials_functions import get_materials from collections import defaultdict from sqlalchemy import func -PORTFOLIO_ID = 632 -SCENARIOS = [1144] +PORTFOLIO_ID = 711 +SCENARIOS = [1233] scenario_names = { - 1144: "EPC C", + 1233: "Reach EPC C", } -project_name = "Calico Project" +project_name = "Novus" def get_data(portfolio_id, scenario_ids): @@ -230,7 +230,7 @@ for scenario_id in SCENARIOS: # Get recs for this scenario recommended_measures_df = recommendations_df[ recommendations_df["scenario_id"] == scenario_id - ][["property_id", "measure_type", "estimated_cost", "default"]] + ][["property_id", "measure_type", "estimated_cost", "default"]] recommended_measures_df = recommended_measures_df[ recommended_measures_df["default"] ] @@ -238,7 +238,7 @@ for scenario_id in SCENARIOS: post_install_sap = recommendations_df[ recommendations_df["scenario_id"] == scenario_id - ][["property_id", "default", "sap_points"]] + ][["property_id", "default", "sap_points"]] post_install_sap = post_install_sap[post_install_sap["default"]] # Sum up the sap points by property id post_install_sap = (