Development¶
Quickstart¶
# start the docker compose stack
docker compose -f docker/compose.dev.yaml up -d --force-recreate
# set some env variables
export PYGEOAPI_ROOT="wherever-you-cloned-pygeoapi-repo"
POTTO__DATABASE_DSN="postgresql+psycopg://potto:pottopass@localhost:55432/potto"
export POTTO__DEBUG=true
export POTTO__PYGEOAPI_CONFIG_FILE=pygeoapi-config-example.yml
export POTTO__RELOAD_DIRS=$(pwd -P)
export POTTO__UVICORN_LOG_CONFIG_FILE=uvicorn-log-config-example.yml
# start the server
uv run potto run-server
Contribution guidelines¶
Read the contribution guidelines, to be added...
Setup¶
Contributing to potto requires a couple of pre-requisites to be met:
You should be running a linux distribution. Development might also be possible on other OS, but you'll be mostly on your own with regard to how to set up your working environment
Additionally, the following tools need to be installed on your machine:
Please refer to each tool's own documentation for how to get it installed
Finally, a PostgreSQL database with PostGIS installed. You can either use the potto-provided docker compose
file, which is suitable for development and includes a db service or install PostgreSQL and PostGIS in
whatever way you prefer and then create a database to be used for development.
Workflow¶
If you are not a core committer to potto, be sure to always open an issue that describes the problem, feature or changes you'd like to materialize. This will provide visibility and give the potto devs a chance to offer some feedback. If you don't do this, there is a risk that your work will be refused.
Warning
Just in case you skipped the previous paragraph - the potto team does not accept PRs without a corresponding issue.
potto's code is developed by following the forking workflow collaboration strategy. In short:
- Fork potto's repo
- Clone your fork locally
- Create a new branch
- Make changes to the code
- Open a Pull Request (PR) to get the changes integrated into the main potto repository
- Follow the PR review process, responding to any comments or change requests
- Rejoice when your PR is merged
Installation¶
After having git cloned your fork of the potto repository and having set up both origin and upstream
remotes:
-
Have your database up and running. If you are using the docker compose file that comes with the potto repository, you can run:
-
Ensure you have these environment variables set:
PYGEOAPI_ROOT="/datadisk/dev/pygeoapi" POTTO__DATABASE_DSN="postgresql+psycopg://<user>:<password>@localhost:<port>/<db>" POTTO__TEST_DATABASE_DSN="postgresql+psycopg://potto:pottopass@localhost:55433/potto_test" POTTO__DEBUG="true" POTTO__UVICORN_LOG_CONFIG_FILE="/datadisk/dev/potto/uvicorn-log-config-no-db.yml"A good strategy is to create a
potto-dev.envfile with the variables and then load it: -
Install the pre-commit hooks:
These will ensure that your code is properly formatted and perform some basic linting and static analysis whenever you try to commit changes.
-
Install potto with uv:
-
Use the
pottoCLI to initialize the databaseuv run potto db upgrade
You are now ready to start working on the code.
-
Use the
pottoCLI to start the potto web application server:
Code formatting and static analysis¶
The pre-commit hook uses ruff and ty to format the code and perform linting and static analysis. These tools also run in CI and you can run them yourself with:
Running tests¶
potto uses pytest and running the tests requires the existence of an additional database.
-
Ensure you define the
POTTO__TEST_DATABASE_DSNenvironment variable. Create this test database and then put this in yourpotto-dev.envfile:Note
Don't forget to export the contents of your
potto-dev.envfile before running the tests -
Run tests with:
API linting¶
potto uses spectral for enforcing API style and security-related rules. This tool runs in CI and you can also run it yourself in one of two ways:
-
by exporting the OpenAPI document to a file and then running spectral on it:
-
by using the dynamically generated openapi whenever the potto server is running. As an example, assuming it is running on
localhost:3001:
Note
Using spectral locally requires that you first install it with something like:
Check the spectral installation docs for more detail.
Working on documentation¶
potto's docs are built with zensical.