API service for a microdata.no datastore.
After cloning the repo, install and activate an environment with:
uv venv && uv sync && source .venv/bin/activate To run the unit and integration tests:
uv run pytestYou can run the application locally with hot reloading:
export DOCKER_HOST_NAME=localhost \
export STACK=test \
export COMMIT_ID=abc123 \
export SQLITE_URL=test.db \
export JWT_AUTH=OFF \
export JWKS_URL=http://localhost
uv run python datastore_api/main.pyThe application uses file-based SQLite migrations to manage schema changes. Migrations are executed on application startup.
- Migration filenames must start with a valid calendar date (YYYYMMDD) and be placed within the /migrations directory.
- Migration dates must be newer than the date of the last applied migration.
- Each migration file is executed once.
- Applied migrations are tracked in the
migrationstable. - If a previously applied migration file is modified (hash mismatch), startup will fail.
There are currently 3 active rules: Ruff-format, Ruff-lint and sync lock file. Install pre-commit
pip install pre-commitIf you've made changes to the pre-commit-config.yaml or its a new project install the hooks with:
pre-commit installNow it should run when you do:
git commitBy default it only runs against changed files. To force the hooks to run against all files:
pre-commit run --all-filesif you dont have it installed on your system you can use: (but then it wont run when you use the git-cli)
uv run pre-commitRead more about pre-commit