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-bucketto.env - Run
pipenv run test
Metadata
Release files for tclambda 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tclambda-0.0.12.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tclambda-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / tclambda-0.0.12.tar.gz
| Download URL | tclambda-0.0.12.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed1e3724d0ec9a940c50a60fcef3037e79a7b72a072d520003a85e8de6c20590
|
|
BLAKE2b-256 checksum How to use checksums |
5ec7ffd31ae856de30527747bb1ec23d2056263334a5ce2ab8f011b4eb04dcd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.23.0
|
Release files / tclambda-0.0.12-py3-none-any.whl
| Download URL | tclambda-0.0.12-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ffc5d7026b5d065756dc18ab8d8ea8328d7f46119499d6284fbba6060257e3a
|
|
BLAKE2b-256 checksum How to use checksums |
85c279f3cc317341b04f147ab8f3449378e526d860d3962993e4ca9f1e8fb693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.23.0
|