-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(lambda-python): add optional poetry bundling exclusion list parameter #23670
feat(lambda-python): add optional poetry bundling exclusion list parameter #23670
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
2 similar comments
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
c22f341
to
642b4ac
Compare
Accidentally messed up my fork with a sync. It should be back to a normal state. |
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
6edf153
to
98a6fbb
Compare
add snapshot test verifying functionality
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
Story of my life, lol. |
* | ||
* @default - Empty list | ||
*/ | ||
readonly poetryAssetExcludes?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this should be scoped to poetry
only and not just be called assetExcludes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I was just trying to minimize the blast radius of this PR. But there is no real reason why this should be limited to poetry
only. I can make the change to support all the packagers.
Seems like there might be existing issues that this PR could help out with too #23313
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could definitely add support for that if you wanted, but this PR is also fine in its current scope 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed some new changes moving it to just assetExcludes
. I will definitely need help verifying and cleaning up these integration tests, that seemed to have had a bit more of an impact adding this to the other tests 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
1 similar comment
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Pull request has been modified.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
2 quick questions-- will this also allow exclusions for those of us using |
Hey @cwaldbieser - it originally was slated to be poetry-only (hence the title), but after feedback it was raised up to be for all Python build systems. I unfortunately forgot to change the title to reflect those changes. I'm not sure if there are mechanical implications in this repository to changing that title post-merge, it might complicate something that I'm unaware of so I can't safely change it. But these changes should let you utilize it regardless of packager. There should be a simple usage example in the Packaging > Excluding source files section of this specific module's README. |
A summary of this change is: change from use of
cp
torsync --exclude='x'
in the bundling commands forpoetry
based lambdas.The intention of this PR is to enable the bundling code for Poetry projects to exclude certain files and/or folders from the bundled assets. Currently, if developing a python lambda using either
virtualenv
itself or a toolchain that leverages virtual environments (re:poetry
, specifically withvirtualenv.in-project = true
, which is strongly recommended for leveraging python tools in VSCode), the bundling code will copy the entire folder passed in. This leads to copying the entire.venv
directory into the bundled assets, even though the directory is ignored. Ultimately this leads to inflating the assets by the size of unzipped dependencies (numpy
, for instance, is 50Mb by itself).I verified this concept works in another project I maintain which leverages
@aws-cdk/aws-lambda-python-alpha
by manually editing the bundling file (I mentioned it in more detail in the linked issue #22585), but this temporary approach requires manually editing files fromnode_modules
, so it is not a proper fix.fixes #22585
[Post-merge edit] This feature was extended for all Python bundle tools (pipenv, virtualenv, etc), not just Poetry. I forgot to edit the title before merge. Sorry for the confusion.
All Submissions:
Adding new Construct Runtime Dependencies:
* [ ] This PR adds new construct runtime dependencies following the process described hereNew Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?Note: I was unable to implement an integration test. My plan was to verify an asset was ignored from the existing poetry integration test sample directorypackages/@aws-cdk/aws-lambda-python/test/lambda-handler-poetry
by passing in['.ignorefile']
and confirming that asset was excluded, but I was unable to get the test working due to SSM parameters missing. I wasn't sure if I could bootstrap this and get it working.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license