From 50c89fbd92eb42fb03d20c6e56f04280ba5a6707 Mon Sep 17 00:00:00 2001 From: enrique Date: Sat, 22 Jun 2024 11:53:48 -0600 Subject: [PATCH 1/4] Additional logs for schedule-orders --- .../delivery/delivery_modules/data_access/dynamo_handler.py | 6 +++++- src/orders/delivery/location_router.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/orders/delivery/delivery_modules/data_access/dynamo_handler.py b/src/orders/delivery/delivery_modules/data_access/dynamo_handler.py index da4656d..7712da5 100644 --- a/src/orders/delivery/delivery_modules/data_access/dynamo_handler.py +++ b/src/orders/delivery/delivery_modules/data_access/dynamo_handler.py @@ -43,7 +43,11 @@ def update_records(self, records: List[Dict[str, Any]]) -> Dict[str, Any]: :rtype: Dict[str, Any] """ try: - for record in records: + total_records = len(records) + self.logger.debug(f"Total records to update: {total_records}") + for index, record in enumerate(records, start=1): + self.logger.debug(f"Updating record {index} of {total_records}") + update_expression = "SET delivery_sequence = :val, #status = :statusVal, #driver = :driverVal" expression_attribute_values = { ":val": record["delivery_sequence"], diff --git a/src/orders/delivery/location_router.py b/src/orders/delivery/location_router.py index 7668732..61beb03 100644 --- a/src/orders/delivery/location_router.py +++ b/src/orders/delivery/location_router.py @@ -1,5 +1,6 @@ from itertools import permutations from math import inf +from aws_lambda_powertools import Logger class TravelPlanner: @@ -30,6 +31,7 @@ def find_shortest_path(self, locations, start_point): locations.append(start_point) num_locations = len(locations) locations_indices = list(range(num_locations)) + logger = Logger() start_index = next( ( @@ -62,6 +64,7 @@ def find_shortest_path(self, locations, start_point): order["delivery_sequence"] = index # We need to remove starting point from the list, so there is no confusions in frontend ordered_locations.pop(0) + logger.debug("Shortest path found.") return ordered_locations else: raise ValueError("Start point not found in locations list") From fe17e5f6535959696779e628be09ab27d99974bc Mon Sep 17 00:00:00 2001 From: enrique Date: Sat, 22 Jun 2024 12:09:28 -0600 Subject: [PATCH 2/4] Adjust orders pipeline --- .github/workflows/orders_pipeline.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/orders_pipeline.yaml b/.github/workflows/orders_pipeline.yaml index 50cc43c..e6845f3 100644 --- a/.github/workflows/orders_pipeline.yaml +++ b/.github/workflows/orders_pipeline.yaml @@ -4,10 +4,9 @@ on: push: paths: - 'src/orders/**' - - '.github/workflows/orders_pipeline.yaml' branches: - 'main' - - 'feature**' + - 'feature*' workflow_dispatch: jobs: run_unit_tests: From c5695d0ffc21fe6b70dfc430e70a257a5a3bd4a8 Mon Sep 17 00:00:00 2001 From: enrique Date: Sat, 22 Jun 2024 12:15:43 -0600 Subject: [PATCH 3/4] Remove main branch cond --- .github/workflows/orders_pipeline.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/orders_pipeline.yaml b/.github/workflows/orders_pipeline.yaml index e6845f3..642ae07 100644 --- a/.github/workflows/orders_pipeline.yaml +++ b/.github/workflows/orders_pipeline.yaml @@ -27,7 +27,6 @@ jobs: working-directory: ./tests development: - if: startsWith(github.event.ref, 'refs/heads/main') uses: ./.github/workflows/pipeline_template.yaml needs: [run_unit_tests] with: From 39ff0c888c4daf3f3a4237b40b0c6ffc950b9475 Mon Sep 17 00:00:00 2001 From: enrique Date: Sat, 22 Jun 2024 12:35:52 -0600 Subject: [PATCH 4/4] DEBUG log level for dev --- .github/workflows/orders_pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/orders_pipeline.yaml b/.github/workflows/orders_pipeline.yaml index 642ae07..115f318 100644 --- a/.github/workflows/orders_pipeline.yaml +++ b/.github/workflows/orders_pipeline.yaml @@ -31,7 +31,7 @@ jobs: needs: [run_unit_tests] with: stack_name: ${{ vars.ORDERS_STACK_NAME }}-development - sam_deploy_overrides: "ShopifyEventBusName=${{ vars.SHOPIFY_EVENT_BUS_NAME_DEV }} StageName=development" + sam_deploy_overrides: "ShopifyEventBusName=${{ vars.SHOPIFY_EVENT_BUS_NAME_DEV }} StageName=development LogLevel=DEBUG" sam_template: src/orders/template.yaml aws_region: us-east-1 pipeline_execution_role: ${{ vars.PIPELINE_EXECUTION_ROLE_DEV }}