This proof of concept will explore migrating the DaaP API to a single python container organised around a python framework (FastAPI).
- This project requires python 3.11 and Postgres.
- To run postgres locally via docker, run
docker-compose up -d - Run
poetry installto install python dependencies - Run
poetry run alembic upgrade headto create the development database tables
Any environment variables set in the .env file will overwrite the configuration.
e.g. to disable Azure Active Directory authentication:
echo AUTH_ENABLED=False >> .env
- Run
poetry run uvicorn daap_api.main:app --reload - The API is served at http://localhost:8000/
- Example endpoint: http://localhost:8000/v1/data-products
- The docs are served at http://localhost:8000/docs or http://localhost:8000/redoc
poetry run pytestpoetry run pytest tests/unitto just run the unit tests
- Python:
poetry run python -i -m daap_api.main - PSQL:
docker-compose exec -u postgres postgres_db psql daap_api_dev
Schema migrations for the metadata store are written as alembic migrations.
These are a set of operations such as op.create_table and op.drop_table,
which correspond to the SQL required to upgrade/downgrade the schema to/from a new version.
For more info see: https://alembic.sqlalchemy.org/en/latest/tutorial.html#tutorial
Useful commands:
poetry run alembic upgrade head- apply all database migrations to the development databasepoetry run alembic revision -m 'Add a column'- create a candidate migration file in/migrationspoetry run alembic downgrade -1- revert the most recent migrationpoetry run alembic downgrade base- reset database to the starting statepoetry run alembic current- show the databases's current version