Giter Club home page Giter Club logo

Comments (9)

FutureSharks avatar FutureSharks commented on May 27, 2024

Hi Chris,
What OS are running pip3 install invokust --target=python-packages on? And where do you see that error message? In AWS Lambda console? Or are you trying to run it locally?

from invokust.

yavor-atanasov avatar yavor-atanasov commented on May 27, 2024

Hey @FutureSharks

I can confirm that error. I am doing the build on a centos7 machine (latest minimal build) with python3 installed. Ran the exact build commands you've documented (I've removed their output as they succeed)

$ git clone [email protected]:FutureSharks/invokust.git
$ cd invokust/
$ pip3 install invokust --target=python-packages
$ zip -q -r lambda_locust.zip lambda_locust.py locustfile_example.py python-packages
$ aws lambda update-function-code --function-name test-invokust-lambda --zip-file fileb://lambda_locust.zip
$ aws lambda invoke --function-name test-invokust-lambda --invocation-type RequestResponse --payload '{"locustfile": "locustfile_example.py", "host":"https://example.com", "num_requests":"20", "num_clients": "1", "hatch_rate": "1"}' output.txt
{
    "FunctionError": "Unhandled",
    "StatusCode": 200
}
$ cat output.txt
{"errorMessage": "Unable to import module 'lambda_locust'"}

The error from the lambda logs in CloudWatch says:

Unable to import module 'lambda_locust': No module named 'greenlet'

I suspect the greenlet module expects some C header file (since it's a C module) that is not present in the AWS lambda environment. (I'll keep this thread updated if I have findings or solutions to this)

from invokust.

yavor-atanasov avatar yavor-atanasov commented on May 27, 2024

I can also add that doing the build using mock to create a new clean centos7 chroot and virtualenv inside that has the same result (and the built zip package is identical).

from invokust.

FutureSharks avatar FutureSharks commented on May 27, 2024

Hmmm interesting. Could you use my docker example to create python-packages for the zip file? If this works, then it's a problem with libraries/dependencies.

from invokust.

yavor-atanasov avatar yavor-atanasov commented on May 27, 2024

Yes, doing the build inside the docker container you specified in your docs does produce a package that works inside the lambda environment:

$ docker run -it --volume=$PWD/python-packages:/python-packages python:3.6 bash -c "pip install invokust --target=/python-packages"
$ zip -q -r lambda_locust.zip lambda_locust.py locustfile_example.py python-packages
$ aws lambda update-function-code --function-name test-invokust-lambda --zip-file fileb://lambda_locust.zip
$ aws lambda invoke --function-name test-invokust-lambda --invocation-type RequestResponse --payload '{"locustfile": "locustfile_example.py", "host":"https://example.com", "num_requests":"20", "num_clients": "1", "hatch_rate": "1"}' output.txt
{
    "StatusCode": 200
}

Really annoying. Ideally AWS should provide an image with the exact lambda environment for these exact scenarios where you are using modules that need to be compiled against that environment.

Not sure how we can address this...other than put a note in the docs that warns against this problem

from invokust.

FutureSharks avatar FutureSharks commented on May 27, 2024

That is strange.

I would have thought it would be fine any Linux x86_64 host. There is some into here:
https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

Perhaps I should just only include the Docker way in my notes?

from invokust.

yavor-atanasov avatar yavor-atanasov commented on May 27, 2024

Yeah, I've seen those docs (we use lambdas extensively) and we build them inside virtualenvs copying the site-packages.

I'll try to verify this, but it might be some low level incompatibility between python3.4 and python3.6 (because on centos7 you can only get up to python3.4 in a sane way). If that's the case you can at least document that you have a hard dependency on python3.6 since that's the runtime AWS lambda uses (there's no 3.4 runtime).

Thank you for your responses.

from invokust.

FutureSharks avatar FutureSharks commented on May 27, 2024

I'll close this. Feel free to reopen if you still have a problem.

from invokust.

bennyhartnett avatar bennyhartnett commented on May 27, 2024

I have been having the same exact issue whether I use docker or not. I am using Amazon Linux 2.

from invokust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.