Can you post the pex file you get from running `./...
# general
h
Can you post the pex file you get from running
./pants binary
, and also your BUILD file
b
@happy-kitchen-89482 is this okay? uploaded to git
<https://github.com/reaganrewop/lambda_pex>
h
That's good, but I also need the pex from your
dist
dir
b
okay. will upload that too.
done.
h
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
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
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
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
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.