https://github.com/mirumee/lynara
Python ASGI applications in an AWS Lambda runtime
https://github.com/mirumee/lynara
Last synced: 4 months ago
JSON representation
Python ASGI applications in an AWS Lambda runtime
- Host: GitHub
- URL: https://github.com/mirumee/lynara
- Owner: mirumee
- License: bsd-3-clause
- Created: 2024-06-24T07:52:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-10T12:10:53.000Z (over 1 year ago)
- Last Synced: 2025-06-24T00:11:49.327Z (4 months ago)
- Language: Python
- Homepage: https://mirumee.github.io/lynara/
- Size: 650 KB
- Stars: 15
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lynara
Lynara lets you run your ASGI (Starlette, FastAPI, Django) applications in a serverless runtime like AWS Lambda. It closely follows what Uvicorn does with the exception that there's no long-lived loop and instead a Lambda event is translated to an ASGI HTTP event and served to the application accordingly.
To use Lynara in an AWS Lambda handler you can:
```python
import asyncio
from lynara import Lynara, APIGatewayProxyEventV2Interfaceapp = FastAPI()
lynara = Lynara(app=app)def lambda_handler(event, context):
return asyncio.run(lynara.run(event, context, APIGatewayProxyEventV2Interface))```
Lynara will produce a dictionary with an AWS Lambda HTTP response for your handler to respond with.
## Development
Get Hatch (pipx is a good option): https://hatch.pypa.io/latest/install/#pipx.
```
pipx install hatch
```Install all Python versions:
```
hatch python install all
```### Running tests
> https://hatch.pypa.io/1.10/tutorials/testing/overview/#passing-arguments
For development you might find the following useful to use with `pdb`:
```
hatch test -- -s -n 0 --log-cli-level
```To run a single test:
```
hatch -v test -- "tests/test_fastapi.py::test_fastapi_app_lifespan[on]"
```For HTML coverage report
```
hatch test -- --cov --cov-report=html
```## Contributing
Make sure to run tests, static checks and `mypy` before submitting a change:
```
hatch run check
```## Writing docs
```
hatch docs:serve
```