PrijateliTree
is a FastAPI application used to play lab games.
The games are a means to provide insights into social learning, the economics of languages and other human behaviors.
- Python 🐍 version >= v
3.11
- Poetry package manager. If you need information on how to download poetry, check here.
- PostgreSQL v14.
- Enter the
poetry shell
command from the base folder repository. - Run the command
make
from the base directory. - Access the application via the URL
localhost:8000
.
make lint
: Runs thepre-commit
processes and lints the repository.make create_requirements
: Creates arequirements.txt
file based off of the imported packages in thepyproject.toml
file.make build
: Builds the Docker images for the application and the database pass through.make start
: Starts the Docker containers based on the images created in themake build
step.make create_db
: Runs the alembic scripts. This MUST be run before you run themake start
command, or it will error.make update_db
: Updates the DB to the latest Alembic version.make stop
: Stops the running Docker containers.make clean
: Removes all Docker containers.make clean_all
: Removes the database link between the Docker containers and the self-hosted version of PostgreSQL.make test
: Runs all the tests in theprijateli_tree/tests
folder using a Dockerized version of SQLite.make process_translations
: Runsprocess_translations.py
-- ensure the latest excel file is in/app/languages/
and adjust the filename inconstants
if necessary.
- If you are failing the
Format-and-Fail
GitHub Action, you must runmake lint
and make any changes it requests. - If you have already run the
make
command, you cannot run it again UNLESS you delete all the tables in your hosted database.- This is because the command will attempt to run the Alembic scripts again which will error since all the tables already exist.
To run a data migration, you need to run the following steps:
- Before you make any changes to the
database.py
file in theapp
directory, run the following command from your terminal:docker-compose run web alembic --config=./prijateli_tree/migrations/alembic.ini stamp head
- You can also use the command
make stamp
- You can also use the command
- Make your modifications to the
database.py
file in theapp
directory. - Run the following command from your terminal to produce your migration:
docker-compose run web alembic --config=./prijateli_tree/migrations/alembic.ini revision --autogenerate
- You can also use the command
make create_revision
- You can also use the command
- You should then see a file added to the
migrations/versions
folder. Modify that as is necessary as Alembic isn't guaranteed to make all the necessary changes. - Run the following command and your migration should be run on the database:
docker-compose run web alembic --config=./prijateli_tree/migrations/alembic.ini upgrade head
- You can also use the command
make upgrade_db
- You can also use the command