-
Notifications
You must be signed in to change notification settings - Fork 72
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 does this work #6
Comments
I put my "main.py" file the same level as the lib (and other) directories in the example at https://github.com/ryansb/sklearn-build-lambda/blob/master/sample-site-packages-2016-02-20.zip. You also must specify the handler function in that file in the Amazon Lambda config. |
Also, I don't use sklearn, just numpy and scipy, and ever since AWS Lambda started supporting the lib directory on the default search path, I have found NO NEED for this (slowish) loading step from the README.md example: import ctypes
for d, _, files in os.walk('lib'):
for f in files:
if f.endswith('.a'):
continue
ctypes.cdll.LoadLibrary(os.path.join(d, f)) |
Oh, really? Thanks @thunderfish24 I'll have to test that out. I'd love to dump that hack 😄 |
@thunderfish24 How the import section of your lambda handler looks like? Cheers, |
The directory structure for the lambda deploy looks like (recall that I don't use sklearn):
After some other deploy pre-processing for my specific application, I use this bash command to zip up all the files FROM WITHIN THE lambda_function_package DIRECTORY: # Zip it up at maximum compression
zip -r9 ../lambda_function_package.zip * -x "*.pyc" -x "*tests*" The handler function main.py looks like: import numpy as np
import scipy as sp
import my_package
def handler(event, context):
...handler code...
# Allow testing from command line
if __name__ == "__main__":
# Create test event
event = ...
print(handler(event, None)) |
This is great. Thanks. I cannot figure why, though, my directory structure looks so different after running the build.sh: lambda_function_package Any idea how to bring the packages (opencv-python, sklearn, etc...) to the top level? |
Hi
The text was updated successfully, but these errors were encountered: