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.11.tar.gz
(14.8 kB
view details)
Built Distribution
tclambda-0.0.11-py3-none-any.whl
(15.7 kB
view details)
File details
Details for the file tclambda-0.0.11.tar.gz
.
File metadata
- Download URL: tclambda-0.0.11.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43b5d24b53faaf2c9ed02069606bb9ad3a99a0c4818dcab63eee888171be579e |
|
MD5 | 029afb42c06d0864f18a0389496692ee |
|
BLAKE2b-256 | c481eae917052675e16c72bc6025cad499a1c7e5ead17cb09182e1664a463c0b |
Provenance
File details
Details for the file tclambda-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: tclambda-0.0.11-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 | cc87e7cb12ea9b41a91f0c2daba3b61bb6141166966a496abb5e76ac9cbceff1 |
|
MD5 | 87295a1fff8bc096c87a58b15876732d |
|
BLAKE2b-256 | 5eb9d712a10c11a9cc7da68e7472ea78c621bd99d4acc057fbeabff090ee1e8e |