Skip to content

AI-READI/fairhub-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fairhub-api

Getting started

Prerequisites/Dependencies

You will need the following installed on your system:

Setup

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.

  1. 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
  2. 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.

  3. 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.

  4. 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>
  5. Format the code:

    poe format
  6. Check the code quality:

    poe typecheck
    poe lint
    poe flake8

    You can also use poe precommit to run both formatting and linting.

  7. Run the tests and check the code coverage:

    poe test
    poe test_with_capture # if you want to see console output

Database

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

Running

For developer mode:

poe dev

or

flask run --debug

For production mode:

python3 app.py --host $HOST --port $PORT

License

This work is licensed under MIT. See LICENSE for more information.

AI-READI logo