Skip to content
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

feat: Remove requests and all its dependencies. #547

Merged
merged 13 commits into from
Jan 28, 2025
Merged
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ RUN rm -rf ./python/lib/$runtime/site-packages/botocore*
RUN rm -rf ./python/lib/$runtime/site-packages/setuptools
RUN rm -rf ./python/lib/$runtime/site-packages/jsonschema/tests
RUN find . -name 'libddwaf.so' -delete
RUN rm -rf ./python/lib/$runtime/site-packages/urllib3*
RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so
# Comment this line out for now since ddtrace now tries to import it
#RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so
RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_stacktrace*.so
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/libdd_wrapper*.so
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/ddup/_ddup.*.so
Expand All @@ -32,6 +32,14 @@ RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/st
RUN find ./python/lib/$runtime/site-packages/*.dist-info -not -name "entry_points.txt" -type f -delete
RUN find ./python/lib/$runtime/site-packages -type d -empty -delete

# Remove requests and dependencies
RUN rm -rf \
./python/lib/$runtime/site-packages/requests* \
./python/lib/$runtime/site-packages/urllib3* \
./python/lib/$runtime/site-packages/certifi* \
./python/lib/$runtime/site-packages/idna* \
./python/lib/$runtime/site-packages/charset_normalizer*

# Precompile all .pyc files and remove .py files. This speeds up load time.
# Compile with optimization level 2 (-OO) and PYTHONNODEBUGRANGES=1 to redtce
# size of .pyc files.
Expand Down
1 change: 1 addition & 0 deletions ci/input_files/build.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
- *install-node
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh
- yarn global add serverless@^3.38.0 --prefix /usr/local
- yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local
- cd integration_tests && yarn install && cd ..
script:
- RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.8.0,<4"
datadog = ">=0.41.0,<1.0.0"
datadog = ">=0.51.0,<1.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we also need to run a poetry update to refresh the poetry lock file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good call

wrapt = "^1.11.2"
ddtrace = ">=2.17.0"
ujson = ">=5.9.0"
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"devDependencies": {
"serverless-plugin-datadog": "^2.18.0"
"serverless-plugin-datadog": "^2.18.0",
"serverless-python-requirements": "^6.1.1"
}
}
4 changes: 4 additions & 0 deletions tests/integration/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
certifi==2024.12.14
charset-normalizer==3.4.1
idna==3.10
requests==2.32.3
19 changes: 15 additions & 4 deletions tests/integration/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ provider:
iam:
# IAM permissions require that all functions are deployed with this role
role: "arn:aws:iam::425362996713:role/serverless-integration-test-lambda-role"
layers:
- { Ref: PythonLambdaLayer }
- { Ref: PythonRequirementsLambdaLayer }

plugins:
- serverless-python-requirements

custom:
pythonRequirements:
pythonBin: python3
pipCmdExtraArgs:
- --no-deps # install just requests
layer:
compatibleRuntimes:
- ${env:SERVERLESS_RUNTIME}
Comment on lines +25 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add new requirements? Could you give me a brief explanation so I understand it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed requests from the lambda layer, yet the tests still rely on it. So we must add requests back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I imagine these are the ones that ping URLs?


layers:
python:
Expand All @@ -32,8 +47,6 @@ functions:
name: integration-tests-python-${sls:stage}-async-metrics_${env:RUNTIME}
handler: handle.handle
runtime: ${env:SERVERLESS_RUNTIME}
layers:
- { Ref: PythonLambdaLayer }
environment:
DD_FLUSH_TO_LOG: true

Expand All @@ -42,5 +55,3 @@ functions:
name: integration-tests-python-${sls:stage}-sync-metrics_${env:RUNTIME}
handler: handle.handle
runtime: ${env:SERVERLESS_RUNTIME}
layers:
- { Ref: PythonLambdaLayer }
Loading
Loading