Skip to content

Commit e0b2c70

Browse files
authored
VED-806 Refactor batch_processor_filter (#952)
* init I * root * makefile * common * dependabot * lint * aws_dynamodb * common.clients * ruff * rm comment * REGION_NAME
1 parent 1dcfa69 commit e0b2c70

24 files changed

+65
-64
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ version: 2
77
updates:
88
- package-ecosystem: "docker"
99
directories:
10-
- "/batch_processor_filter"
1110
- "/infrastructure/grafana/non-prod/docker"
1211
- "/lambdas/ack_backend"
12+
- "/lambdas/batch_processor_filter"
1313
- "/lambdas/delta_backend"
1414
- "/lambdas/filenameprocessor"
1515
- "/lambdas/mesh_processor"
@@ -50,8 +50,8 @@ updates:
5050
directories:
5151
- "/"
5252
- "/backend"
53-
- "/batch_processor_filter"
5453
- "/lambdas/ack_backend"
54+
- "/lambdas/batch_processor_filter"
5555
- "/lambdas/delta_backend"
5656
- "/lambdas/filenameprocessor"
5757
- "/lambdas/id_sync"

.github/workflows/quality-checks.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ jobs:
9797
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
9898
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
9999
100-
- name: Run unittest with batchprocessorfilter-coverage
101-
working-directory: batch_processor_filter
102-
id: batchprocessorfilter
103-
env:
104-
PYTHONPATH: ${{ github.workspace }}/batch_processor_filter/src:${{ github.workspace }}/batch_processor_filter/tests
105-
continue-on-error: true
106-
run: |
107-
poetry install
108-
poetry run coverage run -m unittest discover || echo "batchprocessorfilter tests failed" >> ../failed_tests.txt
109-
poetry run coverage xml -o ../batchprocessorfilter-coverage.xml
110-
111100
- name: Run unittest with recordprocessor-coverage
112101
working-directory: lambdas/recordprocessor
113102
id: recordprocessor
@@ -153,6 +142,17 @@ jobs:
153142
poetry run coverage run --source=src -m unittest discover || echo "ack-lambda tests failed" >> ../../failed_tests.txt
154143
poetry run coverage xml -o ../../ack-lambda-coverage.xml
155144
145+
- name: Run unittest with batchprocessorfilter-coverage
146+
working-directory: lambdas/batch_processor_filter
147+
id: batchprocessorfilter
148+
env:
149+
PYTHONPATH: ${{ env.LAMBDA_PATH }}/batch_processor_filter/src:${{ env.LAMBDA_PATH }}/batch_processor_filter/tests:${{ env.SHARED_PATH }}/src
150+
continue-on-error: true
151+
run: |
152+
poetry install
153+
poetry run coverage run -m unittest discover || echo "batchprocessorfilter tests failed" >> ../../failed_tests.txt
154+
poetry run coverage xml -o ../../batchprocessorfilter-coverage.xml
155+
156156
- name: Run unittest with coverage-delta
157157
working-directory: lambdas/delta_backend
158158
id: delta

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL=/usr/bin/env bash -euo pipefail
22

3-
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend batch_processor_filter lambdas/ack_backend lambdas/delta_backend lambdas/filenameprocessor lambdas/id_sync lambdas/mesh_processor lambdas/mns_subscription lambdas/recordprocessor lambdas/redis_sync lambdas/shared
3+
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend lambdas/ack_backend lambdas/batch_processor_filter lambdas/delta_backend lambdas/filenameprocessor lambdas/id_sync lambdas/mesh_processor lambdas/mns_subscription lambdas/recordprocessor lambdas/redis_sync lambdas/shared
44
PYTHON_PROJECT_DIRS = tests/e2e tests/e2e_batch quality_checks $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS)
55

66
.PHONY: install lint format format-check clean publish build-proxy release initialise-all-python-venvs update-all-python-dependencies run-all-python-unit-tests build-all-docker-images

batch_processor_filter/src/logger.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

batch_processor_filter/src/send_log_to_firehose.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

immunisation-fhir-api.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{
1010
"path": "lambdas/ack_backend",
1111
},
12+
{
13+
"path": "lambdas/batch_processor_filter",
14+
},
1215
{
1316
"path": "lambdas/delta_backend",
1417
},

infrastructure/instance/batch_processor_filter_lambda.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Define the directory containing the Docker image and calculate its SHA-256 hash for triggering redeployments
22
locals {
3-
batch_processor_filter_lambda_dir = abspath("${path.root}/../../batch_processor_filter")
3+
batch_processor_filter_lambda_dir = abspath("${path.root}/../../lambdas/batch_processor_filter")
44
batch_processor_filter_lambda_files = fileset(local.batch_processor_filter_lambda_dir, "**")
55
batch_processor_filter_lambda_dir_sha = sha1(join("", [for f in local.batch_processor_filter_lambda_files : filesha1("${local.batch_processor_filter_lambda_dir}/${f}")]))
66
}
@@ -15,8 +15,9 @@ resource "aws_ecr_repository" "batch_processor_filter_lambda_repository" {
1515

1616
# Module for building and pushing Docker image to ECR
1717
module "batch_processor_filter_docker_image" {
18-
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
19-
version = "8.1.2"
18+
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
19+
version = "8.1.2"
20+
docker_file_path = "./batch_processor_filter/Dockerfile"
2021

2122
create_ecr_repo = false
2223
ecr_repo = aws_ecr_repository.batch_processor_filter_lambda_repository.name
@@ -39,9 +40,10 @@ module "batch_processor_filter_docker_image" {
3940

4041
platform = "linux/amd64"
4142
use_image_tag = false
42-
source_path = local.batch_processor_filter_lambda_dir
43+
source_path = abspath("${path.root}/../../lambdas")
4344
triggers = {
44-
dir_sha = local.batch_processor_filter_lambda_dir_sha
45+
dir_sha = local.batch_processor_filter_lambda_dir_sha
46+
shared_dir_sha = local.shared_dir_sha
4547
}
4648
}
4749

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,31 @@ RUN mkdir -p /home/appuser && \
55
echo 'appuser:x:1001:' >> /etc/group && \
66
chown -R 1001:1001 /home/appuser && pip install "poetry~=2.1.4"
77

8-
COPY poetry.lock pyproject.toml README.md ./
8+
# Install Poetry dependencies
9+
# Copy batch_processor_filter Poetry files
10+
COPY ./batch_processor_filter/poetry.lock ./batch_processor_filter/pyproject.toml ./
11+
12+
# Install batch_processor_filter dependencies
13+
WORKDIR /var/task
914
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main
15+
1016
# -----------------------------
1117
FROM base AS build
12-
COPY src .
18+
19+
# Set working directory back to Lambda task root
20+
WORKDIR /var/task
21+
22+
# Copy shared source code
23+
COPY ./shared/src/common ./common
24+
25+
# Copy batch_processor_filter source code
26+
COPY ./batch_processor_filter/src .
27+
28+
# Set correct permissions
1329
RUN chmod 644 $(find . -type f) && chmod 755 $(find . -type d)
30+
1431
# Switch to the non-root user for running the container
1532
USER 1001:1001
33+
34+
# Set the Lambda handler
1635
CMD ["lambda_handler.lambda_handler"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
TEST_ENV := @PYTHONPATH=src:tests:../shared/src
2+
13
build:
24
docker build -t imms-lambda-build -f Dockerfile .
35

@@ -6,15 +8,15 @@ package: build
68
docker run --rm -v $(shell pwd)/build:/build imms-lambda-build
79

810
test:
9-
@PYTHONPATH=src:tests python -m unittest
11+
$(TEST_ENV) python -m unittest
1012

1113
coverage-run:
12-
@PYTHONPATH=src:tests coverage run -m unittest discover
14+
$(TEST_ENV) coverage run -m unittest discover
1315

1416
coverage-report:
15-
coverage report -m
17+
$(TEST_ENV) coverage report -m
1618

1719
coverage-html:
18-
coverage html
20+
$(TEST_ENV) coverage html
1921

2022
.PHONY: build package test

0 commit comments

Comments
 (0)