From 6696c06c9a4f0987f83aa001bf7af183e67f551f Mon Sep 17 00:00:00 2001 From: Marcus Messer Date: Fri, 6 Nov 2026 11:21:20 +0000 Subject: [PATCH 1/4] Move to Python 3.12 base image Python 3.8 is out of support on AWS Lambda, and the rolling main-3.8 base image broke prod when 3.9+ syntax landed in the base layer. Switch to main-3.12 (as compareExpressions uses) and run the staging test job on 3.12 to match. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/staging-deploy.yml | 2 +- app/Dockerfile | 4 ++-- readme.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 5e12dc2..4a8443b 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8"] + python-version: ["3.12"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/app/Dockerfile b/app/Dockerfile index 7832b6e..bb4203c 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,6 +1,6 @@ -# Base image that bundles AWS Lambda Python 3.8 image with some middleware functions +# Base image that bundles AWS Lambda Python 3.12 image with some middleware functions # FROM base-eval-tmp -FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.8 +FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.12 WORKDIR /app diff --git a/readme.md b/readme.md index ea1e128..bb1660b 100644 --- a/readme.md +++ b/readme.md @@ -91,7 +91,7 @@ Once the code passes all these tests, it will then be uploaded to AWS and will b ## Pre-requisites Although all programming can be done through the GitHub interface, it is recommended you do this locally on your machine. To do this, you must have installed: -- Python 3.8 or higher. +- Python 3.12 or higher. - GitHub Desktop or the `git` CLI. From bc3dc9b4366f9a0d5fd5983f82fb2f2e61c67528 Mon Sep 17 00:00:00 2001 From: Marcus Messer Date: Fri, 6 Nov 2026 11:34:48 +0000 Subject: [PATCH 2/4] Install findutils in the 3.12 image The Python 3.12 Lambda base image is Amazon Linux 2023, which doesn't include find, so the chmod step failed with 'find: command not found'. Co-Authored-By: Claude Opus 5.5 --- app/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Dockerfile b/app/Dockerfile index bb4203c..b78ca05 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -2,6 +2,9 @@ # FROM base-eval-tmp FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.12 +# The 3.12 image is Amazon Linux 2023, which doesn't ship `find` (used below) +RUN dnf install -y findutils && dnf clean all + WORKDIR /app # Copy and install any packages/modules needed for your evaluation script. From 879c2cb24a10911740649e0bd9e714153b3548c2 Mon Sep 17 00:00:00 2001 From: Marcus Messer Date: Fri, 6 Nov 2026 11:40:52 +0000 Subject: [PATCH 3/4] Base the 3.12 Dockerfile on compareExpressions Python 3.12's Lambda runtime imports the handler as a module name, so CMD /app/app.handler became import_module('.app.app') and crashed on startup (every request returned 500). Use CMD app.handler with PYTHONPATH=/app, as compareExpressions does, and install pytest for the healthcheck. Co-Authored-By: Claude Opus 5.5 --- app/Dockerfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index b78ca05..1b0e75f 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,5 +1,4 @@ -# Base image that bundles AWS Lambda Python 3.12 image with some middleware functions -# FROM base-eval-tmp +# Base image that bundles the AWS Lambda Python image with the lambda-feedback middleware (app.handler) FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.12 # The 3.12 image is Amazon Linux 2023, which doesn't ship `find` (used below) @@ -7,10 +6,15 @@ RUN dnf install -y findutils && dnf clean all WORKDIR /app +ENV PYTHONPATH=/app + # Copy and install any packages/modules needed for your evaluation script. COPY requirements.txt . RUN pip3 install -r requirements.txt +# The healthcheck command runs the pytest suite +RUN pip3 install pytest + # Copy the evaluation and testing scripts COPY evaluation.py ./app/ COPY evaluation_test.py ./app/ @@ -23,5 +27,6 @@ COPY docs/user.md ./app/docs/user.md RUN chmod 644 $(find . -type f) RUN chmod 755 $(find . -type d) -# The entrypoint for AWS is to invoke the handler function within the app package -CMD [ "/app/app.handler" ] +# The entrypoint for AWS is to invoke the handler function within the app package. +# Python 3.12's Lambda runtime imports this as a module name, so it can't be a path. +CMD [ "app.handler" ] From 806e6e214dd47c7e40bba7b5a8cec45800aecf8f Mon Sep 17 00:00:00 2001 From: Marcus Messer Date: Fri, 6 Nov 2026 11:51:41 +0000 Subject: [PATCH 4/4] Rename evaluation_test.py back to evaluation_tests.py The base layer's healthcheck imports app.evaluation_tests, so since the rename in 88052af the deployed healthcheck has reported tests_passed: false. Add a pytest.ini so CI still discovers the file. Co-Authored-By: Claude Opus 5.5 --- app/Dockerfile | 2 +- app/{evaluation_test.py => evaluation_tests.py} | 0 pytest.ini | 4 ++++ readme.md | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) rename app/{evaluation_test.py => evaluation_tests.py} (100%) create mode 100644 pytest.ini diff --git a/app/Dockerfile b/app/Dockerfile index 1b0e75f..d3b1373 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -17,7 +17,7 @@ RUN pip3 install pytest # Copy the evaluation and testing scripts COPY evaluation.py ./app/ -COPY evaluation_test.py ./app/ +COPY evaluation_tests.py ./app/ # Copy Documentation COPY docs/dev.md ./app/docs/dev.md diff --git a/app/evaluation_test.py b/app/evaluation_tests.py similarity index 100% rename from app/evaluation_test.py rename to app/evaluation_tests.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..589497f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +# evaluation_tests.py is the name the base layer's healthcheck imports, so +# include it alongside pytest's default patterns. +python_files = test_*.py *_test.py *_tests.py diff --git a/readme.md b/readme.md index bb1660b..3856e27 100644 --- a/readme.md +++ b/readme.md @@ -28,7 +28,7 @@ app/ docs/ dev.md # Developer-facing documentation user.md # User-facing documentation - evaluation_test.py # Unittests for the main evaluation_function + evaluation_tests.py # Unittests for the main evaluation_function requirements.txt # List of packages needed for evaluation.py Dockerfile # For building the image to deploy to AWS @@ -59,7 +59,7 @@ config.json # Specifies the name of the evaluation function 4. You are now ready to start developing your function: - Edit the `app/evaluation.py` file, which ultimately gets called when the function is given the `eval` command - - Edit the `app/evaluation_test.py` file to add tests which get run: + - Edit the `app/evaluation_tests.py` file to add tests which get run: - Every time you commit to this repo, before the image is built and deployed - Whenever the `healthcheck` command is supplied to the deployed function - Edit the `app/docs/user.md` and `app/docs/dev.md` files to reflect your changes. These files are baked into the function's image and are made available using the `docs` command. This feature is used to display documentation on our [Documentation](https://lambda-feedback.github.io/Documentation/) website.