From c3a7866df43dfb2441cd6685a17e0ae3786efb07 Mon Sep 17 00:00:00 2001 From: Michael Duong Date: Sun, 2 Nov 2025 13:34:34 +0000 Subject: [PATCH] make changes to request body --- .github/workflows/MLPipelinePullRequest.yml | 3 ++- deployment/handlers/prediction_app.py | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MLPipelinePullRequest.yml b/.github/workflows/MLPipelinePullRequest.yml index c0576c3..15aeefc 100644 --- a/.github/workflows/MLPipelinePullRequest.yml +++ b/.github/workflows/MLPipelinePullRequest.yml @@ -86,7 +86,7 @@ jobs: - name: Test Lambda endpoint run: | sleep 5 - RESPONSE=$(curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"body": "{\"file_location\": \"cicd://retrofit-data-dev/sap_change_model/sample_data_for_cicd/${timestamp}/sample_test.parquet\", \"property_id\": 1, \"portfolio_id\": 4, \"created_at\": \"now\"}"}') + RESPONSE=$(curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"body": "{\"file_location\": \"s3://retrofit-data-dev/sap_change_model/sample_data_for_cicd/${timestamp}/sample_test.parquet\", \"property_id\": 1, \"portfolio_id\": 4, \"created_at\": \"now\", \"testing\": true}"}') echo "Lambda response: $RESPONSE" if [[ $RESPONSE != *"predictions"* ]]; then echo "Lambda invocation failed" @@ -94,6 +94,7 @@ jobs: fi - name: Remove uploaded sample row dataset from S3 + if: always() env: AWS_ACCESS_KEY_ID: ${{ secrets.ROBOT_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.ROBOT_AWS_SECRET_ACCESS_KEY }} diff --git a/deployment/handlers/prediction_app.py b/deployment/handlers/prediction_app.py index a0507bf..25fa120 100644 --- a/deployment/handlers/prediction_app.py +++ b/deployment/handlers/prediction_app.py @@ -67,11 +67,9 @@ def handler(event, context): # TODO: Implement the loading of the model and prediction - if body["file_location"].startswith("cicd://"): - storage_filepath = ( - body["file_location"] - .replace("cicd://", "s3://") - .replace(".parquet", "_output.parquet") + if "testing" in body: + storage_filepath = body["file_location"].replace( + ".parquet", "_output.parquet" ) else: storage_filepath = f"s3://{PREDICTIONS_BUCKET}/{portfolio_id}/{property_id}/{created_at}.parquet"