An API for accessing geospatial data
To create the initial venv or update it:
uv sync
To activate the venv:
source .venv/bin/activate
To update the uv lock file (e.g. when adding a new dependency):
uv lock
Linting uses ruff using the config in pyproject.toml
ruff check --fix
Formatting uses ruff using the config in pyproject.toml which follows the default black settings.
ruff format .
Static type checking is undertaken using pyright using the config values in pyproject.toml
The linting, formatting and type checking can be called as a pre-commit hook. Run below to set them up.
pre-commit install
If you need to ignore the hook for a particular commit then use the --no-verify flag.
To run the tests, ensure the localstack docker container is running, and the virtual environment is activated. Then run:
pytest
Localstack is used to create local AWS resoruces for testing the app locally. localstack-setup.sh is run when the
container is initialised which creates the buckets and loads the sample geospatial data found in ./data. If the contents of ./data are updated then the localstack docker container will need to be stopped, the volume deleted and then recreated to pick up any new changes.
To run localstack:
docker compose --profile localstack up
The API can be run either within a python shell with the venv activated using python -m geospatial_api, or via a debug session. The configuration to use within a VSCode launch.json file for debugging the API is shown below.
{
"name": "Run geospatial_api",
"type": "debugpy",
"request": "launch",
"module": "geospatial_api",
"justMyCode": false,
}
Once running locally, documentation for the API can be found at http://localhost:8000/api/docs