Package: chili-pepper
Asynchronous Serverless Task ExecutionChili-Pepper is a simple framework that makes it easy to execute
tasks without interrupting the main flow of your application.
It handles serverless deployment and task execution.
It allows you to run important functions in parallel with
your main application withzero downtime, zero maintenance and infinite scaling.Commandusage:chili[-h][--appAPP]{deploy}...Serverlessasynchronoustaskspositionalarguments:{deploy}Chili-PeppercommandsdeployDeployfunctionstoserverlessprovideroptionalarguments:-h,--helpshowthishelpmessageandexit--appAPP,-AAPPTheChili-PepperapplicationlocationGetting StartedInstalling Chili-Pepperpipinstallchili-pepperServerless ProviderNext, you need to configure your serverless provider credentials.Amazon Web Services (AWS)You can provide AWS credentials in many ways, including environment variables, your aws credentials file, or a server role.  Seethe boto3 documentation about credential configurationfor details.These credentials need to be allowed to create, execute and delete
AWS Lambda functions and IAM roles.You will also need an S3 bucket (with versioning enabled).AzureMicrosoft Azure Cloud is not supported at this time,
but there are plans to support it in the future.Google CloudGoogle Cloud is not supported at this time,
but there are plans to support it in the future.Creating the Chili-Pepper AppThe Chili-Pepper app will be used to identify and deploy your functions
to the serverless cloud provider.app=ChiliPepper(app_name="demo")Of course, theappvariable can have any name -
we’ll be calling itappin these examples.AWS ConfigurationYou need to pass these required AWS specific configs to the app.
For a full list of AWS configuration options, seeAws Configuration.Bucketapp.conf["aws"]["bucket_name"]="my-chili-pepper-bucket"This bucket will be used for storing AWS Lambda deployment packages.
You should enable versioning on the bucket.Runtimeapp.conf["aws"]["runtime"]="python3.7"AWS Lambda supports several python runtimes.  Seethe lambda runtime documentationfor a full list.  You must pass the “Identifier” for the runtime of your choice to the Chili-Pepper app config.Creating a TaskYou can use the Chili-Pepper app to identify tasks that should be run.@app.task()defmy_task(event,context):returnf"Hello{event['name']}!"DeployingBefore you can asynchronously call your task,
you must deploy it to your cloud provider.chilideploy--appmy_module.tasks.appAWS DeploymentCalling deploy will create a zipfile containing your code
as well as any python dependencies.
Chili-Pepper will then use upload that zipfile to your S3 bucket,
and use Cloudformation to create an AWS Lambda function
for each of the tasks you identified with theapp.task()decorator.Calling your taskNow that you’ve deployed your tasks to the cloud,
you can call them asynchronously.task_result=my_task.delay({"name":"Jalapeno"})print(task_result.get())This will printHello Jalapeno!,
after executingmy_taskin a serverless function.SupportChili-Pepper is built by a 1 person team supported bythese awesome backers, supporters and sponsors.
If you use Chili-Pepper, I would love to hear from you!
And, if I have earned your support, please consider backing meon Patreon.