You will need the following installed on your system:
If you would like to update the api, please follow the instructions below.
Don't forget to start the database before running the api. See Database for more information.
-
Create a local virtual environment and activate it:
python -m venv .venv source .venv/bin/activate
If you are using Anaconda, you can create a virtual environment with:
conda create -n fairhub-api-dev-env python=3.10 conda activate fairhub-api-dev-env
-
Install the dependencies for this package. We use Poetry to manage the dependencies:
pip install poetry==1.3.2 poetry install
You can also use version 1.2.0 of Poetry, but you will need to run
poetry lock
after installing the dependencies. -
Add your environment variables. An example is provided at
.env.example
cp .env.example .env
Make sure to update the values in
.env
to match your local setup. -
Add your modifications and run the tests:
poetry run pytest
If you need to add new python packages, you can use Poetry to add them:
poetry add <package-name>
-
Format the code:
poe format
-
Check the code quality:
poe typecheck poe lint poe flake8
You can also use
poe precommit
to run both formatting and linting. -
Run the tests and check the code coverage:
poe test poe test_with_capture # if you want to see console output
The api uses a postgres and redis database. You can create both of these locally via docker:
docker-compose -f ./dev-docker-compose.yaml up
docker-compose -f ./dev-docker-compose.yaml up -d # if you want the db to run in the background
Close the database with:
docker-compose -f ./dev-docker-compose.yaml down -v
For developer mode:
poe dev
or
flask run --debug
For production mode:
python3 app.py --host $HOST --port $PORT
This work is licensed under MIT. See LICENSE for more information.