High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
flake8
), import & formatting standards (isort
, black
), enforced on every commit.--no-root
option in Dockerfile--no-root
to build step.isort
- import sortingpre-commit
- application of commit hooksdetails: pipenv
has a number of quality of life issues that poetry
solves outright.
details: both Dockerfiles now install & launch the application on Python 3.8.
details: clone this repository to your local, then run asdf install
. that's it - no more making sure you have the right version.
pipenv run
without pipenv's headachesdetails: add aliases for shell commands you depend on
poetry run task compose-up
, replaces pipenv run docker-compose -f docker-compose.local.yml -f docker-compose.worker.yml -f docker-compose.yml up --build
poetry run task app
, replaces pipenv run uvicorn app.main:app --reload
poetry run task worker
, replaces arq app.worker.WorkerSettings --watch ./
fastapi
to 0.54.1gino
to 1.0.0arq
to 0.19sqlalchemy-utils
to `0.36.5alembic
to 1.4.2psycopg2-binary
to 2.8.5uvicorn
to 0.11.5email_validator
to 1.0.5sentry-sdk
to 0.14.3gino-starlette
for starlette
support in gino
1.0taskipy
for pipenv
-style commands in poetrydetails: arq's architecture is similar to FastAPI & natively distributes, handles, runs coroutines as background functions. Multiple jobs (potentially hundreds) can be run simultaneously using a pool of asyncio Tasks
tasks
folder: use app/tasks
to store & expose foreground + background tasksapp/workers.py
file configures, launches arq worker.ARQ_BACKGROUND_FUNCTIONS
global: set a list of function references (app.tasks.example.function, app.tasks.another.function
) in env, app/worker.py
will listen for that function in task queue.Dockerfile
, docker-compose.worker.yml
, updated docker-compose.local.yml
for local & automated testing.arq
, watchgod
(in dev)dept: sentry-sdk w/ asgi, gino integration
details: updated readme.md
& app/main.py
: you can now choose between running locally w/ auto-reload, or you can use app/main.py
with a python debugger.
dept: email-validator
to 1.0.5
dept: fastapi
to 0.42.0
dept: psycopg2-binary
to 2.8.4
dept: sqlalchemy-utils
to 0.34.2
dept: uvicorn
to 0.9.1
dept: black
to dev dependencies
dept: bandit
to dev dependencies
dept: flake8
to dev dependencies
dept: rope
to dev dependencies
rationale: cuts runtime size by a third, dramatically improves image security. Google's Container Scan now detect 0 exploits, down from 600+ from vanilla python3.7.
alembic upgrade head
rationale: 'Prestart.sh' used to run scripts before app is instantiated. currently configured to run migrations post-build, pre-server init.
rationale: Runs postgres as a docker service, connects app. for local development purposes.