-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support SDK modularization on a service basis #1543
Comments
As of right now we don't have any official guidance on slimming down the package size to remove unused services. We wouldn't be able to do the second one as it's possible to specify that you want to use older API versions. This is effectively a feature request to be able to modularize the the Python SDK in a similar fashion as some of the other SDKs (Java, ruby, etc). Marking as a feature request. |
Any updates? |
AWS JavaScript SDK V3 had pulled this off. It would be great to have the same for Boto3 which soon will be unusable for AWS Lambdas. |
For those looking for a short-term solution. A customer wrote an article demonstrating how to selectively discard services you are sure you don't use https://blog.cubieserver.de/2020/building-a-minimal-boto3-lambda-layer/ |
Any kind of hint or indication that when this would be worked on?
|
Following up as we're now at 64M - I understand this would be a huge undertaking considering how these are created today, so I'm primarily interested in hearing whether the team is considering a modularization in the future. |
+1 |
Copying my comment from #2842 (comment)
|
From https://github.com/thejcannon/botocore-a-la-carte I've started publishing E.g. |
What about different versions of API, are the old versions are still needed? |
83m! where in (not so unusual) venv all ~30 libs takes 133M (so 63% is botocore) with only cryptography 41.0.3 even close to botocore at This is so so so much, alpine linux is whole system with required disk size of 130M. And looking how the size is evolving we will see 100M in 2024 probably 😞 😢 |
I used this myself: function join_elements {
local prefix="-path */" separator=" -o "
local prefixed=("${@/#/$prefix}")
local rest=("${prefixed[@]:1}")
local separated=$(printf "%s" "${prefixed[0]}${rest[@]/#/$separator}")
echo "${separated[@]}"
}
function remove_but_latest {
local latest=$(ls -1 "botocore/data/$1" | sort -r | head -1)
find "botocore/data/$1" -mindepth 1 -maxdepth 1 -type d -not -path "*/${latest}" -exec rm -vr '{}' +
}
function keep_components {
local component
find_params=$(join_elements "$@")
set -o noglob
find botocore/data -mindepth 1 -maxdepth 1 -type d -not \( $find_params \) -prune -exec rm -vr '{}' +
set +o noglob
for component in "$@"; do remove_but_latest "$component"; done
}
keep_components cloudformation dynamodb ec2 elbv2 ssm sso sts It seems to work, and helped me reduce docker image of my application to 83MB, not sure if it can cause issues. |
Thanks! that's useful overview. I ended up with dead simple RUN mkdir /tmp/data \
&& cp -r /usr/local/lib/python3.11/site-packages/botocore/data/s3 /tmp/data/ \
&& cp -f /usr/local/lib/python3.11/site-packages/botocore/data/*.json /tmp/data \
&& rm -rf /usr/local/lib/python3.11/site-packages/botocore/data \
&& cp -r /tmp/data /usr/local/lib/python3.11/site-packages/botocore/ \
&& rm -rf /tmp/data Seems to work just fine, probably until it doesn't. PS. above code 83M -> 5M drop. |
A common use case may be to use some boto functions in a client app frozen with pyinstaller, in this case botocore will add 30MB to the install size.
Is there any plan to document how to trim the install size? For example:
install_extras
The text was updated successfully, but these errors were encountered: