mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
debugging local lambda run and updating the sap point checking condition
This commit is contained in:
parent
cde303a0c0
commit
c2fcd0041f
3 changed files with 4 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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..."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue