Skip to content

Commit 0cfae17

Browse files
authored
adding python3.10 (#324)
* adding python3.10 * stringify python-version params in build.yml
1 parent dc51d52 commit 0cfae17

File tree

93 files changed

+3063
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3063
-539
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
max-parallel: 4
4343
matrix:
44-
python-version: [3.7, 3.8, 3.9]
44+
python-version: ['3.7', '3.8', '3.9', '3.10']
4545

4646
steps:
4747
- name: Checkout
@@ -68,7 +68,7 @@ jobs:
6868
runs-on: ubuntu-latest
6969
strategy:
7070
matrix:
71-
runtime-param: [3.7, 3.8, 3.9]
71+
runtime-param: ['3.7', '3.8', '3.9', '3.10']
7272
steps:
7373
- name: Checkout
7474
uses: actions/checkout@v3

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Module",
9+
"type": "python",
10+
"request": "launch",
11+
"module": "unittest",
12+
"justMyCode": true
13+
}
14+
]
15+
}

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"python.pythonPath": "/usr/local/bin/python3",
3-
"python.formatting.provider": "black"
3+
"python.formatting.provider": "black",
4+
"python.testing.unittestArgs": ["-v", "-s", "./tests", "-p", "test*.py"],
5+
"python.testing.pytestEnabled": false,
6+
"python.testing.unittestEnabled": true
47
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Slack](https://chat.datadoghq.com/badge.svg?bg=632CA6)](https://chat.datadoghq.com/)
77
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-python/blob/main/LICENSE)
88

9-
Datadog Lambda Library for Python (3.7, 3.8, and 3.9) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
9+
Datadog Lambda Library for Python (3.7, 3.8, 3.9, and 3.10) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
1010

1111
## Installation
1212

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919
"Programming Language :: Python :: 3.7",
2020
"Programming Language :: Python :: 3.8",
2121
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
2223
]
2324

2425
[tool.poetry.dependencies]

scripts/add_new_region.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
# Copy layers from us-east-1 to new region
99
# args: [new-region]
1010

11-
set -e
11+
set -e
1212

1313
OLD_REGION='us-east-1'
1414

15-
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.9")
16-
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python39")
15+
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM")
16+
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.8" "python3.9" "python3.9" "python3.10" "python3.10")
1717
NEW_REGION=$1
1818

1919
publish_layer() {
@@ -68,11 +68,11 @@ for layer_name in "${LAYER_NAMES[@]}"; do
6868
fi
6969

7070
# run for each version of layer
71-
for i in $(seq 1 $last_layer_version); do
71+
for i in $(seq 1 $last_layer_version); do
7272
layer_path=$layer_name"_"$i.zip
7373
aws_version_key="${PYTHON_VERSIONS_FOR_AWS_CLI[$j]}"
7474

75-
# download layer versions
75+
# download layer versions
7676
URL=$(AWS_REGION=$OLD_REGION aws lambda get-layer-version --layer-name $layer_name --version-number $i --query Content.Location --output text)
7777
curl $URL -o $layer_path
7878

@@ -82,4 +82,4 @@ for layer_name in "${LAYER_NAMES[@]}"; do
8282
done
8383

8484
j=$(expr $j + 1)
85-
done
85+
done

scripts/build_layers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set -e
1414

1515
LAYER_DIR=".layers"
1616
LAYER_FILES_PREFIX="datadog_lambda_py"
17-
AVAILABLE_PYTHON_VERSIONS=("3.7" "3.8" "3.9")
17+
AVAILABLE_PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10")
1818

1919
# Determine which Python versions to build layers for
2020
if [ -z "$PYTHON_VERSION" ]; then

scripts/check_layer_size.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 24 \* 1024)
1414

1515
LAYER_FILES_PREFIX="datadog_lambda_py"
1616
LAYER_DIR=".layers"
17-
VERSIONS=("3.7" "3.8" "3.9")
17+
VERSIONS=("3.7" "3.8" "3.9" "3.10")
1818

1919
for version in "${VERSIONS[@]}"
2020
do

scripts/list_layers.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
set -e
1212

13-
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM")
13+
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM")
1414
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
1515
LAYERS_MISSING_REGIONS=()
1616

@@ -63,6 +63,6 @@ done
6363

6464
if [ ${#LAYERS_MISSING_REGIONS[@]} -gt 0 ]; then
6565
echo "WARNING: Following regions missing layers: ${LAYERS_MISSING_REGIONS[@]}"
66-
echo "Please run ./add_new_region.sh <new_region> to add layers to the missing regions"
66+
echo "Please run ./add_new_region.sh <new_region> to add layers to the missing regions"
6767
exit 1
68-
fi
68+
fi

scripts/publish_layers.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ set -e
1313
# Makes sure any subprocesses will be terminated with this process
1414
trap "pkill -P $$; exit 1;" INT
1515

16-
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.8" "python3.9" "python3.9")
17-
LAYER_PATHS=(".layers/datadog_lambda_py-amd64-3.7.zip" ".layers/datadog_lambda_py-amd64-3.8.zip" ".layers/datadog_lambda_py-arm64-3.8.zip" ".layers/datadog_lambda_py-amd64-3.9.zip" ".layers/datadog_lambda_py-arm64-3.9.zip")
18-
AVAILABLE_LAYERS=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM")
19-
ARCHS=("amd64" "amd64" "amd64""amd64" "amd64" "arm64")
16+
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.8" "python3.9" "python3.9" "python3.10" "python3.10")
17+
LAYER_PATHS=(".layers/datadog_lambda_py-amd64-3.7.zip" ".layers/datadog_lambda_py-amd64-3.8.zip" ".layers/datadog_lambda_py-arm64-3.8.zip" ".layers/datadog_lambda_py-amd64-3.9.zip" ".layers/datadog_lambda_py-arm64-3.9.zip" ".layers/datadog_lambda_py-amd64-3.10.zip" ".layers/datadog_lambda_py-arm64-3.10.zip")
18+
AVAILABLE_LAYERS=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM")
19+
ARCHS=("amd64" "amd64" "amd64""amd64" "amd64" "arm64" "amd64" "arm64")
2020
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
2121

2222
# Check that the layer files exist
@@ -129,7 +129,7 @@ do
129129

130130
# This shouldn't happen unless someone manually deleted the latest version, say 28
131131
# and then try to republish it again. The published version is actually be 29, because
132-
# Lambda layers are immutable and AWS will skip deleted version and use the next number.
132+
# Lambda layers are immutable and AWS will skip deleted version and use the next number.
133133
if [ $latest_version -gt $VERSION ]; then
134134
echo "ERROR: Published version $latest_version is greater than the desired version $VERSION!"
135135
echo "Exiting"

scripts/run_integration_tests.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -e
1111
# These values need to be in sync with serverless.yml, where there needs to be a function
1212
# defined for every handler_runtime combination
1313
LAMBDA_HANDLERS=("async-metrics" "sync-metrics")
14-
RUNTIMES=("python37" "python38" "python39")
14+
RUNTIMES=("python37" "python38" "python39" "python310")
1515

1616
LOGS_WAIT_SECONDS=20
1717

@@ -31,8 +31,9 @@ mismatch_found=false
3131
python37=("python3.7" "3.7" $(xxd -l 4 -c 4 -p < /dev/random))
3232
python38=("python3.8" "3.8" $(xxd -l 4 -c 4 -p < /dev/random))
3333
python39=("python3.9" "3.9" $(xxd -l 4 -c 4 -p < /dev/random))
34+
python310=("python3.10" "3.10" $(xxd -l 4 -c 4 -p < /dev/random))
3435

35-
PARAMETERS_SETS=("python37" "python38" "python39")
36+
PARAMETERS_SETS=("python37" "python38" "python39" "python310")
3637

3738
if [ -z "$RUNTIME_PARAM" ]; then
3839
echo "Python version not specified, running for all python versions."
@@ -111,7 +112,7 @@ python version : ${!python_version} and run id : ${!run_id}"
111112
for input_event_file in "${input_event_files[@]}"; do
112113
# Get event name without trailing ".json" so we can build the snapshot file name
113114
input_event_name=$(echo "$input_event_file" | sed "s/.json//")
114-
snapshot_path="./snapshots/return_values/${handler_name}_${parameters_set}_${input_event_name}.json"
115+
snapshot_path="./snapshots/return_values/${handler_name}_${input_event_name}.json"
115116

116117
return_value=$(PYTHON_VERSION=${!python_version} RUNTIME=$parameters_set SERVERLESS_RUNTIME=${!serverless_runtime} \
117118
serverless invoke --stage ${!run_id} -f "$function_name" --path "./input_events/$input_event_file")

scripts/run_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Run unit tests in Docker
99
set -e
1010

11-
PYTHON_VERSIONS=("3.7" "3.8" "3.9")
11+
PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10")
1212

1313
for python_version in "${PYTHON_VERSIONS[@]}"
1414
do
@@ -18,7 +18,7 @@ do
1818
--build-arg python_version=$python_version
1919
docker run -w /test \
2020
datadog-lambda-python-test:$python_version \
21-
nose2 -v
21+
nose2 -v
2222
docker run -w /test \
2323
datadog-lambda-python-test:$python_version \
2424
flake8 datadog_lambda/

scripts/sign_layers.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ LAYER_FILES=(
1414
"datadog_lambda_py-arm64-3.8.zip"
1515
"datadog_lambda_py-amd64-3.9.zip"
1616
"datadog_lambda_py-arm64-3.9.zip"
17+
"datadog_lambda_py-amd64-3.10.zip"
18+
"datadog_lambda_py-arm64-3.10.zip"
1719
)
1820
SIGNING_PROFILE_NAME="DatadogLambdaSigningProfile"
1921

@@ -38,7 +40,7 @@ fi
3840

3941
for LAYER_FILE in "${LAYER_FILES[@]}"
4042
do
41-
echo
43+
echo
4244
echo "${LAYER_FILE}"
4345
echo "-------------------------"
4446

@@ -68,7 +70,7 @@ do
6870
do
6971
sleep 3
7072
SECONDS_WAITED_SO_FAR=$((SECONDS_WAITED_SO_FAR + 3))
71-
73+
7274
SIGNING_JOB_DESCRIPTION=$(aws signer describe-signing-job \
7375
--job-id $SIGNING_JOB_ID \
7476
--region $REGION\

0 commit comments

Comments
 (0)