AWS Lambda Library
Project description
DO NOT USE, THIS IS PRE-ALPHA, HAS NO TESTS, NO MONITORING, BAD LOGGING
tclambda
AWS Lambda calling library
Works together with functions defined in tc-sam-cli
Configuration of AWS Lambda
# app.py
import tclambda
from numpy.polynomial.polynomial import polyfit as np_polyfit
handler = tclambda.LambdaHandler()
@handler.register()
def polyfit(*args, **kwargs):
return list(np_polyfit(*args, **kwargs))
The registered handler must return something that is json serializable.
Usage in other projects
Configuration is primarely done by environmental variables.
TC_NUMPY_QUEUE="https://sqs.eu-west-1.amazonaws.com/12345/NumpySqs"
TC_NUMPY_BUCKET="s3-result-bucket"
from tclambda.auto_functions import numpy
lambda_result = numpy.polyfit([1, 2], [2, 1], 1)
print(lambda_result.result())
# Output: [2.999999999999998, -0.9999999999999992]
Retry lambda
import tclambda
import requests
handler = tclambda.LambdaHandler()
@handler.register()
def web_data(*args, **kwargs):
try:
response = requests.get("https://example.com")
response.raise_for_status()
except Exception as e:
raise tclambda.RetryException(e)
return response.text
Error handling
Sentry
Install tclambda together with sentry pip install tclambda[sentry]
Setting up sentry is done automatically through environmental variables.
- SENTRY_DSN
- SENTRY_RELEASE
- SENTRY_ENVIRONMENT
Tests
- Create an S3 bucket to test live against
- Add
TC_THIS_BUCKET=my-test-s3-bucket
to.env
- Run
pipenv run test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tclambda-0.0.9.tar.gz
(14.4 kB
view details)
Built Distribution
tclambda-0.0.9-py3-none-any.whl
(15.7 kB
view details)
File details
Details for the file tclambda-0.0.9.tar.gz
.
File metadata
- Download URL: tclambda-0.0.9.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33e93b3bdd530304a12730b16c9d1eedc6cede6e70fe49ecdb7098e877d8de62 |
|
MD5 | b3b0d7ee6bacdbe3a3ecd8f085ab2ca3 |
|
BLAKE2b-256 | 866a114a92461600eaaa3bce437e909def9d642bfc6107469491e18f1bb230b1 |
Provenance
File details
Details for the file tclambda-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: tclambda-0.0.9-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a35372602d2771f0fe9a56a7ef6d0842a2197ff45718f343aa88bcfe88af871 |
|
MD5 | 699a97deabe9ea1170e79ad7b53aa4d6 |
|
BLAKE2b-256 | 3c217467768ae9dae9f87d259ec8b10a1b9690ea27d905208afcdccb5019e145 |