added logic to add to serverless

This commit is contained in:
Jun-te Kim 2026-04-22 12:39:44 +00:00
parent d7b8ca34bf
commit 296bbcc626
4 changed files with 26 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 = (