https://pantsbuild.org/ logo
#general
Title
# general
h

happy-kitchen-89482

08/22/2019, 5:04 PM
Can you post the pex file you get from running
./pants binary
, and also your BUILD file
b

brave-policeman-49804

08/22/2019, 5:11 PM
@happy-kitchen-89482 is this okay? uploaded to git
<https://github.com/reaganrewop/lambda_pex>
h

happy-kitchen-89482

08/22/2019, 5:12 PM
That's good, but I also need the pex from your
dist
dir
b

brave-policeman-49804

08/22/2019, 5:12 PM
okay. will upload that too.
done.
h

happy-kitchen-89482

08/22/2019, 7:30 PM
I think I see the problem
you're uploading
hello-bin.pex
?
That's the non-lambda-ified pex
hello-lambda.pex
is the result of applying lambdex to
hello-bin.pex
that's the one you want to upload
Also, you mentioned that your command is
pants binary :hello-lambda
, does that mean your code is in the root of the repo? I can imagine that not working
If I run
./pants binary contrib/awslambda/python/src/python/pants/contrib/awslambda/python/examples:hello-lambda
in the pants repo, I get a valid lambda
So try uploading
hello-lambda.pex
and not
hello-bin.pex
, and if that doesn't work, also try moving the code under some subdir, like
src/python/hello
b

brave-policeman-49804

08/23/2019, 5:24 AM
Will check.
@happy-kitchen-89482 it wasn't generating hello-lambda.pex if I use the goal as
binary
but works if I use
bundle
.
tested with
lambdex test
and it works but still when I upload it as zip to lambda service, it throws the same error which I mentioned before
@happy-kitchen-89482 I was able to make it work by deploying the pex without zipping
have you faced this issue before? zipping and uploading the pex is not working.
h

happy-kitchen-89482

08/23/2019, 3:43 PM
Ah, yes, I missed that detail. The thing you need to run on the cmd line is
pants bundle <target>
. There is an unfortunate historical distinction between
binary
and
bundle
that we may want to get rid of.
And you are supposed to upload the pex itself, you do not need to zip it. A pex is just a zip file with some header magic and a .pex extension.
What instructions were you following? Clearly I need to update them and clarify them.
b

brave-policeman-49804

08/23/2019, 4:08 PM
I couldn't find any instruction, was just looking at pants code and lambdex code.
moreover, because of aws lambda size limitation I have to upload the pex file to s3 and get the link and share it to aws lambda. but if I do that It says
unzipped files should not exceed 269 mb
, eventhough the pex is just 100 mb. any reason for this?
is it trying to unzip it and telling me that the size is above 269 mb?
@happy-kitchen-89482 any follow up?
h

happy-kitchen-89482

08/25/2019, 7:39 PM
It sounds like you have this ~working? All you should need to do is
./pants bundle path/to/python_awslambda_target
, and then upload the resulting lambda pex to s3 the way you would any other lambda. According to this: https://docs.aws.amazon.com/lambda/latest/dg/limits.html you are limited to a 50MB zipped/250MB unzipped pex size. An 100MB pex is pretty huge, are you using many large 3rdparty dependencies? Are you pulling in deps you may not actually need? The pex overhead is ~500K compressed, so that shouldn't be an issue. Your next step should probably be to figure out why your resulting bundle is so huge.