项目作者: ZhukovAlexander

项目描述 :
AWS Lambda automation and integration for Python.
高级语言: Python
项目地址: git://github.com/ZhukovAlexander/lambdify.git
创建时间: 2016-03-09T10:54:46Z
项目社区:https://github.com/ZhukovAlexander/lambdify

开源协议:Apache License 2.0

下载


λambdify - because code is the only thing that matters

Build Status
PyPI version

DISCLAIMER: lambdify is just a POC, it’s not actively maintained and is not suitable for production use at the moment

lambdify is a tool that turns any python callable into an AWS Lambda function. Create, update and call your lambdas directly from python.

Just like that:

install lambdify

  1. $pip install lambdify

…create AWS Lambda with 4 lines of code:

  1. from lambdify import Lambda
  2. @Lambda.f(name='echo')
  3. def echo(*args, **kwargs):
  4. return args, kwargs
  5. echo.create()
  6. if __name__ == '__main__':
  7. import getpass
  8. echo(msg='Hello, {user}!'.format(user=getpass.getuser()))

Now you can head over to your AWS Lambda console and behold your echo function.
Could creating a serverless program be any easier?

The goal

Lambdify aims to unite convenient task queues API (i.e. Celery, Hue, RQ’s @job decorator) with AWS Lambda service coolest features. Ultimately, lambdify should be capable to become a good alternative to Celery or any other task queue.

At present, there are some solutions, that allow you to create and deploy lambdas, like Zappa, lambda-uploader, lambder etc., but they still have limitations of not being able to interact directly with a python program.
lambdify overcomes such limitations by using the following algorithm:

  1. Serialize the callable with it’s globals using dill

  2. Upload the .lambda.dump file containing the serialized function along with the rest of the package

  3. Special container.py module will look for the .lambda.dump file and inject deserialized function into it’s namespace

  4. ????

  5. Profit

Documentation

  1. >>>from lambdify import Lambda
  2. >>>help(Lambda)

Usecases and features

  • Workerless task queue replacement

The simpliest task queue ever

  1. @Lambda.f(name='my_job')
  2. def add(a, b):
  3. return a + b
  • Distributed computing

Lambdas can create and call other lambdas:

  1. @Lambda.f(name='child')
  2. def child_function(x, y):
  3. return x * y
  4. @Lambda.f(name='parent')
  5. def parent_function(y):
  6. # this will actually call the cloud instance of
  7. # child_function
  8. return child_function(2, y)
  9. parent_function(42)
  • Cloud Functional Reactive Programming
  • Dynamic and realtime lambda-function management

P.S. Lambdify is a POC, and at the time allows your lambda to only use site-packages, all local files won’t be packaged, so each user-defined dependency should be contained withing the same file.