git clone https://github.com/KoelLabs/server.git
- On Windows, install Git first. Recommended: use the included git-bash to run the commands in the rest of the instructions.
- Install Docker and Docker Compose
- Docker Desktop for Mac or
brew install --cask docker
with Homebrew- If it repeatedly complains about the daemon not running, make sure Docker Desktop is running and add
export DOCKER_HOST=unix:///Users/$USER/Library/Containers/com.docker.docker/Data/docker.raw.sock
to your shell profile (e.g.~/.zshrc
)
- If it repeatedly complains about the daemon not running, make sure Docker Desktop is running and add
- Docker Desktop for Windows or
choco install docker-desktop
with Chocolatey - Docker Engine for Linux or
sudo apt install docker.io
with APT on Ubuntu
- Docker Desktop for Mac or
- Duplicate the
.env.example
file and rename it to.env
. Fill in the necessary environment variables.- You can find your
HF_TOKEN
on your Settings Page. It just needs read access togated repos
.
- You can find your
- Run the application
. ./scripts/docker-run-dev.sh
to start the development server- If
http://localhost:8080
doesn't automatically open in your browser, open it manually ctrl+c
to stop the server
To add new dependencies, update the requirements.txt
file and run . ./scripts/docker-run-dev.sh
again.
git clone https://github.com/KoelLabs/server.git
- On Windows, install Git first. Recommended: use the included git-bash to run the commands in the rest of the instructions.
- Install Python 3.8.10 or higher
- Install pyenv
- Run
pyenv install 3.10.12
- Pyenv should automatically use this version in this directory. If not, run
pyenv local 3.10.12
- Create a virtual environment
- Run
python -m venv ./venv
to create it - Run
. venv/bin/activate
when you want to activate it- Run
deactivate
when you want to deactivate it
- Run
- Pro-tip: select the virtual environment in your IDE, e.g. in VSCode, click the Python version in the bottom left corner and select the virtual environment
- Run
- Install dependencies
- Run
pip install -r requirements.txt
- Install the huggingface cli with
pip install -U "huggingface_hub[cli]"
- Run
huggingface-cli login
using an Access Token with read access from your Settings Page
- Run
- Duplicate the
.env.example
file and rename it to.env
. Fill in the necessary environment variables.- You can find your
HF_TOKEN
on your Settings Page. It just needs read access togated repos
.
- You can find your
- Run the server
- Run
python src/server.py
to start the development server - Open your browser to
http://localhost:8080
ctrl+c
to stop the server
- Run
To save dependencies you pip install
, then run pip freeze > requirements.txt
.
All checks are run as github actions when you push code. You can also run them manually with . scripts/alltests.sh
.
-
We use Black for formatting. It is recommended you integrate it with your IDE to run on save. You can run it manually with
black .
. -
We scan the repo for leaked secrets with gitleaks. You can run it manually with
gitleaks detect
. -
We use zizmor for static analysis and security audits of github actions. You can run it manually with
zizmor .
. -
We use pytest for testing. Tests live in the
tests
directory and can be run withpytest
. You can run a specific test withpytest tests/test_example.py::test_example
. Place all fixtures intests/conftest.py
.
server/
├── .github/ # Actions and Templates
├── scripts/ # Shell+Python scripts
├── src/ # Flask server
│ ├── static/ # Test client
│ ├── feedback.py # Feedback logic
│ └── server.py # Routes and setup
├── tests/ # Automated tests
│ ├── conftest.py # Pytest fixtures
│ └── test_*.py # Test files
├── .env.example # Example .env file
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
├── CONTRIBUTING.md # Guidelines
├── DEVELOPMENT.md # Development setup
├── LICENSE # License information
└── README.md # Readme
main
is the default branch containing the latest code (this is where pull requests will be merged in).
test
will automatically deploy to the test environment on push/merge.
prod
will automatically deploy to the production environment on push/merge.