Local development
Prerequisites
-
uv (it installs Python 3.12 itself, pinned by
.python-version). -
Git access to the private
github.com/Payabilityrepos —uvfetchespyb-flask-utils,eventloggerandmessagingfrom git tags ([tool.uv.sources]inpyproject.toml). -
AWS SAM CLI, only for
make build/make deploy. -
AWS SSO profiles
dev(account 605668041275) andprod(account 625663093496).
Everyday commands
make install # uv sync: .venv with runtime + dev dependencies
make test # offline unit tests
make lint # ruff (pyflakes rules)
make help # everything else
Dependencies are declared in pyproject.toml and locked in uv.lock. Add one with
uv add <pkg>==<version> (or uv add --dev …), commit both files. requirements.txt is generated
for sam build by make requirements and is not committed.
Tests
make test runs python -m unittest discover -s tests -t .. The suite needs no AWS access:
-
tests/init.pysetsAWS_SECRETS_MANAGER=Falseand dummy values for every required setting before the app is imported (-t .makestestsa package so this runs first); -
DynamoDB is mocked with moto (
mock_aws, tables created fromdynamo_tables); -
WORKER_FUNCTION_NAMEis unset, so@async_taskfunctions run inline; -
HTTP calls to other services are mocked with
requests-mock/mock.
Running the API locally
cp .env.example .env # fill in the values (see the comments in the file)
make run # uv run --env-file .env: Flask under gevent on http://localhost:5555
PyCharm users: the committed run configuration .idea/runConfigurations/Run.xml loads .env
through the EnvFile plugin and runs run_locally.py.
Two ways to provide secrets locally:
| Mode | Set |
|---|---|
Explicit values (default in |
|
From the stage secret |
|
The local app uses the _staging tables of whichever account your credentials point at.
The Lambda entry points in lambda_handlers.py are not run locally; tests/test_lambda_handlers.py
covers the API Gateway translation and every Worker event shape
(async/worker.adoc#events). To exercise the real Worker, invoke the stage one by hand
(Running things by hand).