Skip to content

Include python 3.10 and 3.11 as supported versions #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-on-push-and-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.11'
- name: Run 'pr' target
run: make pr
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setup-codebuild-agent:

.PHONY: test-smoke
test-smoke: setup-codebuild-agent
CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.9
CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.11

.PHONY: test-integ
test-integ: setup-codebuild-agent
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ We have open-sourced a set of software packages, Runtime Interface Clients (RIC)
base images to be Lambda compatible.
The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to receive requests from and send requests to the Lambda service.

The Lambda Python Runtime Interface Client is vended through [pip](https://pypi.org/project/awslambdaric).
The Lambda Python Runtime Interface Client is vended through [pip](https://pypi.org/project/awslambdaric).
You can include this package in your preferred base image to make that base image Lambda compatible.

## Requirements
The Python Runtime Interface Client package currently supports Python versions:
- 3.7.x up to and including 3.9.x
- 3.7.x up to and including 3.11.x

## Usage

Expand Down Expand Up @@ -104,18 +104,18 @@ def handler(event, context):

### Local Testing

To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator.
To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator.

*To install the emulator and test your Lambda function*

1) From your project directory, run the following command to download the RIE from GitHub and install it on your local machine.
1) From your project directory, run the following command to download the RIE from GitHub and install it on your local machine.

```shell script
mkdir -p ~/.aws-lambda-rie && \
curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \
chmod +x ~/.aws-lambda-rie/aws-lambda-rie
```
2) Run your Lambda image function using the docker run command.
2) Run your Lambda image function using the docker run command.

```shell script
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
Expand All @@ -124,9 +124,9 @@ docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
/usr/local/bin/python -m awslambdaric app.handler
```

This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`.
This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`.

3) Post an event to the following endpoint using a curl command:
3) Post an event to the following endpoint using a curl command:

```shell script
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
Expand Down Expand Up @@ -175,4 +175,4 @@ If you discover a potential security issue in this project we ask that you notif

## License

This project is licensed under the Apache-2.0 License.
This project is licensed under the Apache-2.0 License.
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import os
import platform
from subprocess import check_call, check_output

from setuptools import Extension, find_packages, setup

from awslambdaric import __version__


Expand Down Expand Up @@ -88,6 +90,8 @@ def read_requirements(req="base.txt"):
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/codebuild/buildspec.os.alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/codebuild/buildspec.os.amazonlinux.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down Expand Up @@ -98,4 +100,4 @@ phases:
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
- docker network rm "${TEST_NAME}-network" || true
4 changes: 3 additions & 1 deletion tests/integration/codebuild/buildspec.os.amazonlinux.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down Expand Up @@ -107,4 +109,4 @@ phases:
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
- docker network rm "${TEST_NAME}-network" || true
4 changes: 3 additions & 1 deletion tests/integration/codebuild/buildspec.os.centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down Expand Up @@ -107,4 +109,4 @@ phases:
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
- docker network rm "${TEST_NAME}-network" || true
4 changes: 3 additions & 1 deletion tests/integration/codebuild/buildspec.os.debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down Expand Up @@ -110,4 +112,4 @@ phases:
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
- docker network rm "${TEST_NAME}-network" || true
4 changes: 3 additions & 1 deletion tests/integration/codebuild/buildspec.os.ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ batch:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
phases:
pre_build:
commands:
Expand Down Expand Up @@ -108,4 +110,4 @@ phases:
- docker rm --force "${TEST_NAME}-app" || true
- docker stop "${TEST_NAME}-tester" || true
- docker rm --force "${TEST_NAME}-tester" || true
- docker network rm "${TEST_NAME}-network" || true
- docker network rm "${TEST_NAME}-network" || true
19 changes: 13 additions & 6 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ def raise_exception_handler(json_input, lambda_context):

self.assertEqual(mock_stdout.getvalue(), error_logs)

@patch("sys.stdout", new_callable=StringIO)
@patch("importlib.import_module")
@patch("sys.stdout", new_callable=StringIO)
def test_handle_event_request_fault_exception_logging_syntax_error(
self, mock_import_module, mock_stdout
self, mock_stdout, mock_import_module
):
try:
eval("-")
Expand Down Expand Up @@ -616,10 +616,17 @@ def test_handle_event_request_fault_exception_logging_syntax_error(

sys.stderr.write(mock_stdout.getvalue())

error_logs = (
"[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': "
"unexpected EOF while parsing (<string>, line 1)\r"
)
if sys.version_info < (3, 10):
error_logs = (
"[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': "
"unexpected EOF while parsing (<string>, line 1)\r"
)
else:
error_logs = (
"[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': "
"invalid syntax (<string>, line 1)\r"
)

error_logs += "Traceback (most recent call last):\r"
error_logs += '  File "<string>" Line 1\r'
error_logs += "    -\n"
Expand Down