diff --git a/backend/app/db/connection.py b/backend/app/db/connection.py index 976e57a7..28f06047 100644 --- a/backend/app/db/connection.py +++ b/backend/app/db/connection.py @@ -11,4 +11,4 @@ db_string = connection_string.format( dbname=get_settings().DB_NAME, ) -db_engine = create_engine(db_string) +db_engine = create_engine(db_string, pool_size=20, max_overflow=5) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 17a5fc88..a8ad04a7 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -196,21 +196,17 @@ async def trigger_plan(body: PlanTriggerRequest): epc_client = EpcClient(auth_token=get_settings().EPC_AUTH_TOKEN) plan_input = read_csv_from_s3(bucket_name=bucket_name, filepath=body.trigger_file_path) - input_properties = [] for config in plan_input: # We validate each record in the file. If the record is NOT valid, we need to handle this accordingly # TODO: implment validation - # Create a record in db property_id, is_new = create_property( session, portfolio_id=body.portfolio_id, address=config['address'], postcode=config['postcode'] ) - # if a new record was not created, we don't produduce recommendations if not is_new: continue - # TODO: Need to add heat demand target create_property_targets( session, @@ -403,7 +399,7 @@ async def trigger_plan(body: PlanTriggerRequest): read_csv_from_s3(bucket_name=get_settings().PREDICTIONS_BUCKET, filepath=response["storage_filepath"]) ) - predictions["RDSAP_CHANGE"] = predictions["RDSAP_CHANGE"].astype(float).round(0) + predictions["RDSAP_CHANGE"] = predictions["RDSAP_CHANGE"].astype(float).round(1) predictions[['property_id', 'recommendation_id']] = predictions['id'].str.split('+', expand=True) # Insert the predictions into the recommendations and run the optimiser @@ -419,7 +415,7 @@ async def trigger_plan(body: PlanTriggerRequest): rec["recommendation_id"] )]["RDSAP_CHANGE"].values[0] - if not rec["sap_points"]: + if rec["sap_points"] is None: raise ValueError("Sap points missing") input_measures = prepare_input_measures(recommendations[property_id], body.goal) diff --git a/run_lambda_local.sh b/run_lambda_local.sh index abcd5633..8aee4e1a 100755 --- a/run_lambda_local.sh +++ b/run_lambda_local.sh @@ -20,7 +20,7 @@ fi # Step 2: Build the Docker image echo "Building Docker image..." -docker build -t $IMAGE_NAME:$TAG -f backend/docker/lambda.Dockerfile . +docker build --platform linux/amd64 -t $IMAGE_NAME:$TAG -f backend/docker/lambda.Dockerfile . # Step 3: Run the Docker image with the emulator, .env file, and AWS credentials echo "Starting the Docker container..."