Skip to content
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

How to make use of common re-usable code with Gordon #53

Open
JDFagan opened this issue Jun 13, 2016 · 3 comments
Open

How to make use of common re-usable code with Gordon #53

JDFagan opened this issue Jun 13, 2016 · 3 comments

Comments

@JDFagan
Copy link

JDFagan commented Jun 13, 2016

See attached images below. I'm trying to make use of a common sibling directory, "group" for my 3 different lambda functions: post, get, get_detail. I'm just testing post now just trying to get simple example of importing of sibling directory references in Python. Looking at build of post by Gordon, it appears its not sucking in the relative references that would be needed to be part of build to make this code work in AWS Lambda. Error I get by AWS is "module initialization error: Attempted relative import in non-package". You can see in the screenshot that I unzipped the group_post.zip file and its missing the relative reference as it seems that Gordon only builds out one directory that encapsulates the code.py lambda file.

group_post bad build

top level settings yml

@JDFagan
Copy link
Author

JDFagan commented Jun 14, 2016

Note, I did play with this and tried to create sample that makes use of common code but either Gordon doesn't yet support this or I'm attacking it wrong. My experience with common code across lambda functions within an app (microservice) is from Serverless. See https://serverlesscode.com/post/python-on-serverless-intro/ and look for section titled "Writing Common Code". I'm trying to achieve common lib code for an app (in my case model code for Pynamodb that would be re-usable across multiple lambda functions).

@innonagle
Copy link

👍

This would be useful as well as the ability to provide the pip dependencies in a zip file that can be merged into the deployment package. E.g. anything using PyOpenSSL needs to be compiled against openssl on an Amazon Linux AMI. Python modules with native C extensions compiled on OSX, err macOS, don't work when packaged up and deployed to lambda. By don't work I mean when executing the lambda function Python is unable to load the module containing the handler.

@dotkas
Copy link

dotkas commented Sep 19, 2017

@JDFagan Have you considered overriding the build option in settings.yaml? http://gordon.readthedocs.io/en/latest/lambdas.html#build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants