Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support news title and more_info_urls fields #414

Merged
merged 14 commits into from
Jun 5, 2024
7 changes: 7 additions & 0 deletions horde/apis/models/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,13 @@ def __init__(self, api):
example="Information",
description="How critical this piece of news is.",
),
"tags": fields.List(
fields.String(description="Tags for this newspiece."),
),
"title": fields.String(description="The title of this newspiece."),
"more_info_urls": fields.List(
fields.String(description="URLs for more information about this newspiece."),
),
},
)

Expand Down
676 changes: 22 additions & 654 deletions horde/classes/base/news.py

Large diffs are not rendered by default.

825 changes: 825 additions & 0 deletions horde/data/news.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest==8.0.2
black==24.2.0
ruff==0.3.1
black==24.4.2
ruff==0.4.2
tox~=4.14.1
horde_sdk>=0.7.29

Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import requests


@pytest.fixture
@pytest.fixture(scope="session")
def CIVERSION() -> str:
return "0.1.1"


@pytest.fixture
@pytest.fixture(scope="session")
def HORDE_URL() -> str:
return "localhost:7001"


@pytest.fixture
@pytest.fixture(scope="session")
def api_key() -> str:
key_file = pathlib.Path(__file__).parent / "apikey.txt"
if key_file.exists():
Expand All @@ -23,7 +23,7 @@ def api_key() -> str:
raise ValueError("No api key file found")


@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="session")
def increase_kudos(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
headers = {"apikey": api_key, "Client-Agent": f"aihorde_ci_client:{CIVERSION}:(discord)db0#1625", "user_id": "1"}

Expand Down
11 changes: 8 additions & 3 deletions tests/test_image.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

import requests

TEST_MODELS = ["Fustercluck", "AlbedoBase XL (SDXL)"]
Expand Down Expand Up @@ -31,10 +33,12 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
async_results = async_req.json()
req_id = async_results["id"]
# print(async_results)
print(async_results)
pop_dict = {
"name": "CICD Fake Dreamer",
"models": TEST_MODELS,
"bridge_agent": "AI Horde Worker reGen:4.1.0-citests:https://github.com/Haidra-Org/horde-worker-reGen",
"bridge_agent": "AI Horde Worker reGen:8.0.1-citests:https://github.com/Haidra-Org/horde-worker-reGen",
"nsfw": True,
"amount": 10,
"max_pixels": 4194304,
"allow_img2img": True,
Expand All @@ -47,13 +51,14 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
}
pop_req = requests.post(f"{protocol}://{HORDE_URL}/api/v2/generate/pop", json=pop_dict, headers=headers)
try:
print(pop_req.text)
assert pop_req.ok, pop_req.text
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err
pop_results = pop_req.json()
# print(json.dumps(pop_results, indent=4))
print(json.dumps(pop_results, indent=4))

job_id = pop_results["id"]
try:
Expand All @@ -75,7 +80,7 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
retrieve_req = requests.get(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
assert retrieve_req.ok, retrieve_req.text
retrieve_results = retrieve_req.json()
# print(json.dumps(retrieve_results,indent=4))
print(json.dumps(retrieve_results, indent=4))
assert len(retrieve_results["generations"]) == 1
gen = retrieve_results["generations"][0]
assert len(gen["gen_metadata"]) == 0
Expand Down
3 changes: 2 additions & 1 deletion tests/test_image_extra_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
pop_dict = {
"name": "CICD Fake Dreamer",
"models": TEST_MODELS,
"bridge_agent": "AI Horde Worker reGen:5.3.0-citests:https://github.com/Haidra-Org/horde-worker-reGen",
"bridge_agent": "AI Horde Worker reGen:8.0.1-citests:https://github.com/Haidra-Org/horde-worker-reGen",
"nsfw": True,
"amount": 10,
"max_pixels": 4194304,
"allow_img2img": True,
Expand Down
Loading