Skip to content

Commit

Permalink
Merge pull request #2 from AIPowerGrid/urek
Browse files Browse the repository at this point in the history
Upgrading core
  • Loading branch information
websines authored Dec 6, 2024
2 parents 135503a + 0419020 commit 14b3b32
Show file tree
Hide file tree
Showing 66 changed files with 3,583 additions and 543 deletions.
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ repos:
rev: 24.4.2
hooks:
- id: black
exclude: ^hordelib/nodes/.*\..*$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: ruff
repos:
- repo: https://github.com/fsfe/reuse-tool
- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
hooks:
- id: reuse

71 changes: 71 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,77 @@ SPDX-License-Identifier: AGPL-3.0-or-later

# Changelog

# 4.44.3

* Fix image validation warnings being sent to the wrong requests
* Validate request with styles, only after style is applied

# 4.44.2

* Allow trusted users to also create styles
* Fix styles always returning 1 image
* Fix style reward not being taken from the requesting user

# 4.44.1

* Various fixes around styles
* Added `/.well-known/serviceinfo`

# 4.44.0

* Adds styles
* Adds TabbyAPI as approved LLM backend

# 4.43.9

* Prevent anon gens being visible at their profile page

# 4.43.7

* fixes setting team for worker
* aborted jobs can't be restarted anymore


# 4.43.6

* Fix returning `done` when a job was restarted.

# 4.43.5

* Fix: Added check to ensure the redis servers are still available.

# 4.43.4

* Fix logic error when setting censored key

# 4.43.3

* Add new `information` metadata key

# 4.43.2

* Horde more accurately reports which images are nsfw or csam censored

# 4.43.1

* Fix to prevent limit_max_steps picking up WPs with empty model lists

# 4.43.0

* Adjused TTL formula to be algorithmic
* prevent workers without flux support picking up flux jobs
* Adds `extra_slow_workers` bool for image gen async
* Adds `extra_slow_worker` bool for worker pop
* Adds `limit_max_steps` for worker pop

# 4.42.0

* Adds support for the Flux family of models

# 4.41.0

* Adds support for extra backends behind LLM bridges, and for knowing which are validated.

# 4.40.3

* Ensure jobs don't expire soon after being picked up
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SPDX-License-Identifier: AGPL-3.0-or-later
* start server with `python server.py -vvvvi --horde stable`
* You can now connect to http://localhost:7001

To run the AI Horde with Docker or Docker Compose, see the [README_docker.md](README_docker.md).

# How to contribute to the AI Horde code

We are happy you have ideas to improve this service and we welcome all contributors.
Expand Down Expand Up @@ -85,4 +87,4 @@ Note that the pre-commit will not complain if you forget to add your copyright n

# Code of Conduct

We expect all contributors to follow the [Anarchist code of conduct](https://wiki.dbzer0.com/the-anarchist-code-of-conduct/). Do not drive away other contributors due to intended or unintended on bigotry.
We expect all contributors to follow the [Anarchist code of conduct](https://wiki.dbzer0.com/the-anarchist-code-of-conduct/). Do not drive away other contributors due to intended or unintended on bigotry.
43 changes: 35 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
# SPDX-FileCopyrightText: 2024 Tazlin
# SPDX-FileCopyrightText: 2024 ceruleandeep
#
# SPDX-License-Identifier: AGPL-3.0-or-later

# Use a slim base image for Python 3.10
FROM python:3.10-slim
FROM python:3.10-slim AS python


##
## BUILD STAGE
##
FROM python AS python-build-stage

# Install Git
RUN apt-get update && apt-get install -y git

# Set the working directory
RUN --mount=type=cache,target=/root/.cache pip install --upgrade pip

# Build dependencies
COPY ./requirements.txt .
RUN --mount=type=cache,target=/root/.cache \
pip wheel --wheel-dir /usr/src/app/wheels \
-r requirements.txt


##
## RUN STAGE
##
FROM python AS python-run-stage

# git is required in the run stage because one dependency is not available in PyPI
RUN apt-get update && apt-get install -y git

RUN --mount=type=cache,target=/root/.cache pip install --upgrade pip

# Install dependencies
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
COPY ./requirements.txt .
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ \
-r requirements.txt \
&& rm -rf /wheels/

WORKDIR /app

# Copy the source code to the container
COPY . /app

# Install the dependencies
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir --prefer-binary -r requirements.txt

# Set the environment variables
ENV PROFILE=
ENV PROFILE=""

# Set the command to run when the container starts
CMD ["python", "server.py", "-vvvvi", "--horde", "stable"]
Expand Down
23 changes: 18 additions & 5 deletions README_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,29 @@ Run the following command in your project root folder (the folder where your Doc
docker build -t aihorde:latest .
```

## with Docker-compose
## with Docker Compose

Create `.env_docker` file to deliver access information of services used together such as Redis and Postgres.
[docker-compose.yaml](docker-compose.yaml) is provided to run the AI-Horde with Redis and Postgres.

Copy the `.env_template` file in the root folder to create the .env_docker file.
Copy the `.env_template` file in the root folder to create the `.env_docker` file.

[docker-compose.yaml](docker-compose.yaml) Change the file as needed.
```bash
cp .env_template .env_docker
```

To use the supplied `.env_template` with the supplied `docker-compose.yaml`, you will need to set:

```bash
# .env_docker
REDIS_IP="redis"
REDIS_SERVERS='["redis"]'
USE_SQLITE=0
POSTGRES_URL="postgres"
```

Then run the following command in your project root folder:

```bash
# run in background
docker-compose up -d
docker compose up --build -d
```
25 changes: 19 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# SPDX-FileCopyrightText: 2024 Tazlin
# SPDX-FileCopyrightText: 2024 ceruleandeep
#
# SPDX-License-Identifier: AGPL-3.0-or-later

version: '3'
services:
aihorde:
build:
context: .
dockerfile: Dockerfile
image: aihorde:latest
container_name: aihorde
ports:
- "7001:7001"
# The port number written in front of the colon (:) is the port number to be exposed to the outside, so if you change it, you can access it with localhost:{changePort}.
environment:
- PROFILE=docker # If you write a profile, the .env_{PROFILE} file is read.
# Flask obtains its environment variables from the .env file.
# If you set a profile, the .env_{PROFILE} file is read instead.
- PROFILE=docker
volumes:
- .env_docker:/app/.env_docker # You can replace the local pre-built .env file with the container's file.
# .env_{PROFILE} is copied into the image when it is built.
# So that you can change the environment variables without rebuilding the image, mount the .env file.
- .env_docker:/app/.env_docker
# Likewise, you can mount the horde directory to change the source code without rebuilding the image.
- ./horde:/app/horde
networks:
- aihorde_network
depends_on:
Expand All @@ -27,9 +36,10 @@ services:
container_name: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: admin
POSTGRES_DB: postgres
POSTGRES_PASSWORD: changeme
volumes:
# Use a named volume to persist the data even if the container is deleted.
- postgres_data:/var/lib/postgresql/data/
ports:
- "5432:5432"
networks:
Expand All @@ -47,3 +57,6 @@ services:
networks:
aihorde_network:
driver: bridge

volumes:
postgres_data:
3 changes: 2 additions & 1 deletion horde/apis/apiv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from flask_restx import Api

from horde.apis.v2 import api as v2
from horde.consts import HORDE_API_VERSION
from horde.vars import horde_contact_email, horde_title

blueprint = Blueprint("apiv2", __name__, url_prefix="/api")
api = Api(
blueprint,
version="2.0",
version=str(HORDE_API_VERSION),
title=f"{horde_title}",
description=f"The API documentation for the {horde_title}",
contact_email=horde_contact_email,
Expand Down
Loading

0 comments on commit 14b3b32

Please sign in to comment.