Note! Ahti project has ended and is no longer being actively developed.
🌊 AHTI API ⚓
Development with Docker
Prerequisites:
- Docker engine: 18.06.0+
- Docker compose 1.22.0+
-
Create a
docker-compose.env.yaml
file in the project folder:- You can use
docker-compose.env.yaml.template
as a base, it does not need any changes if you want all features enabled. - Change
DEBUG
and the rest of the Django settings if needed.TOKEN_AUTH_AUTHSERVER_URL
, URL for tunnistamo authentication service
- Set entrypoint/startup variables according to taste.
CREATE_SUPERUSER
, creates a superuser with credentialsadmin
:admin
(admin@example.com)APPLY_MIGRATIONS
, applies migrations on startupIMPORT_FEATURES
, imports features from configured sources on startup
- You can use
-
Run
docker-compose up
The project is now running at localhost:8082
Prerequisites:
- PostgreSQL 10
- PostGIS 2.5
- Python 3.8
- Run
pip install -r requirements.txt
- Run
pip install -r requirements-dev.txt
(development requirements)
To setup a database compatible with default database settings:
Create user and database
sudo -u postgres createuser -P -R -S ahti # use password `ahti`
sudo -u postgres createdb -O ahti ahti
Create extensions in the database
sudo -u postgres psql ahti -c "CREATE EXTENSION postgis;"
Allow user to create test database
sudo -u postgres psql -c "ALTER USER ahti CREATEDB;"
- Create
.env
file:touch .env
- Set the
DEBUG
environment variable to1
. - Run
python manage.py migrate
- Run
python manage.py createsuperuser
- Run
python manage.py runserver localhost:8082
The project is now running at localhost:8082
In order to get updates to imported features, ./manage.py import_features
needs to be run periodically.
-
Install
pip-tools
:pip install pip-tools
-
Add new packages to
requirements.in
orrequirements-dev.in
-
Update
.txt
file for the changed requirements file:pip-compile requirements.in
pip-compile requirements-dev.in
-
If you want to update dependencies to their newest versions, run:
pip-compile --upgrade requirements.in
-
To install Python requirements run:
pip-sync requirements.txt
This project uses
black
,
flake8
and
isort
for code formatting and quality checking. Project follows the basic
black config, without any modifications.
Basic black
commands:
- To let
black
do its magic:black .
- To see which files
black
would change:black --check .
pre-commit
can be used to install and
run all the formatting tools as git hooks automatically before a
commit.
- Set the
DEBUG
environment variable to1
. - Run
pytest
.
View the API documentation by visiting your local environment and see
the Documentation Explorer
section.
For a complete service the following additional components are also required:
- ahti-ui provides UI