Skip to content

Commit

Permalink
extra slow workers count
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Sep 13, 2024
1 parent 39d1585 commit 9e7fdcb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
6 changes: 6 additions & 0 deletions horde/database/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,12 @@ def count_skipped_image_wp(worker, models_list=None, blacklist=None, priority_us
).count()
if skipped_wps > 0:
ret_dict["performance"] = skipped_wps
if worker.extra_slow_worker is True:
skipped_wps = open_wp_list.filter(
ImageWaitingPrompt.extra_slow_workers == False, # noqa E712
).count()
if skipped_wps > 0:
ret_dict["performance"] = ret_dict.get("performance",0) + skipped_wps
# Count skipped WPs requiring trusted workers
if worker.user.trusted is False:
skipped_wps = open_wp_list.filter(
Expand Down
34 changes: 32 additions & 2 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_flux_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
"sampler_name": "k_euler",
},
"models": TEST_MODELS_FLUX,
"extra_slow_workers": True,
# "extra_slow_workers": True,
}
protocol = "http"
if HORDE_URL in ["dev.stablehorde.net", "stablehorde.net"]:
Expand All @@ -140,9 +140,10 @@ def test_flux_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
"allow_controlnet": True,
"allow_sdxl_controlnet": True,
"allow_lora": True,
"extra_slow_worker": True,
"extra_slow_worker": False,
"limit_max_steps": True,
}
# Test limit_max_steps
pop_req = requests.post(f"{protocol}://{HORDE_URL}/api/v2/generate/pop", json=pop_dict, headers=headers)
try:
print(pop_req.text)
Expand All @@ -153,6 +154,35 @@ def test_flux_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
raise err
pop_results = pop_req.json()
print(json.dumps(pop_results, indent=4))
try:
assert pop_results["id"] is None, pop_results
assert pop_results["skipped"]["step_count"] == 1, pop_results
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
# Test extra_slow_worker
pop_dict["limit_max_steps"] = False
pop_dict["extra_slow_worker"] = True
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))
try:
assert pop_results["id"] is None, pop_results
assert pop_results["skipped"]["step_count"] == 1, pop_results
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err


job_id = pop_results["id"]
try:
Expand Down

0 comments on commit 9e7fdcb

Please sign in to comment.