This document provides instructions on how to run and work with this project. It includes guidelines for setting up a development environment, working with branches, and ensuring code quality using pre-commit, black, and flake8.
To start working on the project, clone the repository to your local machine (! USE SSH !):
git clone <repository-url>
cd <repository-directory>A virtual environment has been set up to manage dependencies. Activate the virtual environment before running the project:
python3 -m venv venv!!! If you cannot get the virtual environment to start, try creating it with the command
/usr/bin/python3 -m venv .venvand repeat the following steps.
venv\Scripts\activatesource venv/bin/activateInstall the required dependencies using pip:
pip install -r requirements.txtOnce the virtual environment is activated, you can run the project and any necessary commands.
All development work should be done in separate branches created from the dev branch. Follow these steps to ensure a smooth workflow:
- Pull the latest changes from dev:
git checkout dev
git pull origin dev- Create a new branch for your feature or bug fix:
git checkout -b your-feature-branchThis project uses pre-commit hooks to enforce code quality standards. Before committing any changes, ensure you follow these steps:
- Run black for Code Formatting (black is a code formatter that ensures your code adheres to PEP8 standards. This command formats all the Python files in your project.) Run it before committing your code :
black .- Run flake8 for Code Linting (flake8 checks your code for linting errors.) If flake8 identifies any issues, fix them before proceeding with the commit. Run it before committing your code:
flake8 .Once your code is formatted and linted -> add changes -> commit them -> and push! The pre-commit hooks will automatically run black and flake8 to check the code formatting and linting. If any issues are found, the commit process will be interrupted, and you will need to fix these issues before committing again.
If errors are detected during the commit (for example, from black or flake8), you will see messages in your terminal indicating what went wrong. Here's how to handle these errors:
-
Check the log output:
Carefully read the output in your terminal. The log will tell you which files or lines have issues and what those issues are.
-
Fix the identified issues:
Based on the log output, correct the errors in your code. This might involve reformatting code according to
blackor fixing linting issues reported byflake8. -
Re-run the pre-commit checks:
After fixing the issues, stage the changes again.
If you install any new dependencies, you must update the requirements.txt file so that others can easily install them.
- Install the new package:
pip install <package-name>- Update requirements.txt:
pip freeze > requirements.txt- Commit the updated requirements.txt (step 5 and 6). Make sure that you included the updated requirements.txt in your Pull Request!!!