Spaces:
Running on Zero
fix(app): tell signed-out visitors to sign in when ZeroGPU refuses them
Browse filesMost refusals on the Space come from callers ZeroGPU could not identify,
and Hugging Face gives them too little GPU time to run this app at all.
The app sent them the wrong way: a runs-limit refusal showed "Daily GPU
quota used up ... upgrade Pro", and "larger than the maximum allowed"
showed "Try Fast preset or a shorter video", which never helps because
the GPU ask does not depend on the video length.
_classify now returns unlogged for any text spaces only gives an
unidentified caller (the token hint, "exceeded your ZeroGPU quota" with
no account word, the older "Unlogged user"), whatever the title, and
for the runs-limit sentence unless an API caller's suffix shows a free
or PRO account. spaces 0.51.1 picks that sentence by res.wait == 0 for
any caller; every one seen on the Space carried the signed-out suffix,
and none was seen without one, so the bare sentence is treated as
signed out. The checks come before illegal_duration, after oom and
expired_token. Free and PRO quota refusals keep the quota card.
The unlogged card now says to sign in and why. The illegal_duration
card addresses both readers, because ZeroGPU's text does not say
whether the caller is signed out or on a free account.
- app.py +12 -6
- backend.py +13 -2
- tests/test_app_errors.py +58 -0
- tests/test_backend.py +92 -2
|
@@ -887,14 +887,20 @@ _FRIENDLY_ERRORS: dict[str, tuple[str, str]] = {
|
|
| 887 |
"you'll keep your spot in the GPU queue.",
|
| 888 |
),
|
| 889 |
"illegal_duration": (
|
| 890 |
-
"GPU
|
| 891 |
-
"
|
| 892 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 893 |
),
|
| 894 |
"unlogged": (
|
| 895 |
-
"Sign
|
| 896 |
-
"
|
| 897 |
-
"
|
|
|
|
|
|
|
| 898 |
),
|
| 899 |
"quota_exceeded": (
|
| 900 |
"Daily GPU quota used up",
|
|
|
|
| 887 |
"you'll keep your spot in the GPU queue.",
|
| 888 |
),
|
| 889 |
"illegal_duration": (
|
| 890 |
+
"More GPU time than your account allows",
|
| 891 |
+
"If you are not signed in to Hugging Face, sign in at huggingface.co and "
|
| 892 |
+
"reload this page (API callers: send your Hugging Face token): signed-out "
|
| 893 |
+
"visitors get too little GPU time to run this app. If you are signed in "
|
| 894 |
+
"with a free account, try Text → Video or Image → Video with the Fast or "
|
| 895 |
+
"Balanced preset, which need the least GPU time; other modes and the "
|
| 896 |
+
"Quality preset usually need PRO.",
|
| 897 |
),
|
| 898 |
"unlogged": (
|
| 899 |
+
"Sign in to Hugging Face",
|
| 900 |
+
"Signed-out visitors get too little GPU time from Hugging Face to run this "
|
| 901 |
+
"app. Sign in at huggingface.co, reload this page and click Generate again "
|
| 902 |
+
"(API callers: send your Hugging Face token). A free account covers one "
|
| 903 |
+
"short Text → Video or Image → Video clip a day.",
|
| 904 |
),
|
| 905 |
"quota_exceeded": (
|
| 906 |
"Daily GPU quota used up",
|
|
@@ -558,10 +558,21 @@ def _classify(exc: Exception) -> str:
|
|
| 558 |
return "oom"
|
| 559 |
if "expired zerogpu proxy token" in msg or "expired" in msg and "token" in msg:
|
| 560 |
return "expired_token"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
if "illegal duration" in msg:
|
| 562 |
return "illegal_duration"
|
| 563 |
-
if "unlogged user" in msg:
|
| 564 |
-
return "unlogged"
|
| 565 |
# spaces titles every quota refusal "ZeroGPU quota exceeded", but most of the
|
| 566 |
# messages under that title never say "exceeded your ... GPU".
|
| 567 |
if "zerogpu quota exceeded" in msg or ("exceeded your" in msg and "gpu" in msg):
|
|
|
|
| 558 |
return "oom"
|
| 559 |
if "expired zerogpu proxy token" in msg or "expired" in msg and "token" in msg:
|
| 560 |
return "expired_token"
|
| 561 |
+
# spaces says these only to a caller it could not identify, whatever the title.
|
| 562 |
+
if (
|
| 563 |
+
"unlogged user" in msg
|
| 564 |
+
or "authenticate with a hugging face token" in msg
|
| 565 |
+
or "exceeded your zerogpu quota" in msg
|
| 566 |
+
):
|
| 567 |
+
return "unlogged"
|
| 568 |
+
# The runs-limit sentence goes to any caller; only an API caller's suffix says
|
| 569 |
+
# it has an account. Every one seen on the Space carried the signed-out suffix.
|
| 570 |
+
if "runs limit" in msg and not (
|
| 571 |
+
"subscribe to hugging face pro" in msg or "add credits to keep using zerogpu" in msg
|
| 572 |
+
):
|
| 573 |
+
return "unlogged"
|
| 574 |
if "illegal duration" in msg:
|
| 575 |
return "illegal_duration"
|
|
|
|
|
|
|
| 576 |
# spaces titles every quota refusal "ZeroGPU quota exceeded", but most of the
|
| 577 |
# messages under that title never say "exceeded your ... GPU".
|
| 578 |
if "zerogpu quota exceeded" in msg or ("exceeded your" in msg and "gpu" in msg):
|
|
@@ -1,6 +1,31 @@
|
|
| 1 |
"""User-facing translation of backend error categories."""
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
import app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def test_friendly_error_explains_a_workflow_that_produced_no_video():
|
|
@@ -15,3 +40,36 @@ def test_friendly_error_explains_a_workflow_that_produced_no_video():
|
|
| 15 |
def test_friendly_error_falls_back_for_unknown_categories():
|
| 16 |
title, _body = app._friendly_error("totally_unknown", "raw message")
|
| 17 |
assert title == "Generation failed"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""User-facing translation of backend error categories."""
|
| 2 |
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
import app
|
| 7 |
+
import backend
|
| 8 |
+
|
| 9 |
+
# Verbatim from the Space's runtime log on 2026-11-15 (spaces 0.51.3): what a signed-out
|
| 10 |
+
# caller is told. The second names no caller; a free account gets the same sentence.
|
| 11 |
+
_SIGNED_OUT_REFUSALS = [
|
| 12 |
+
gr.Error(
|
| 13 |
+
"You have exceeded your ZeroGPU runs limit. Authenticate with a Hugging Face token "
|
| 14 |
+
"for more quota - https://huggingface.co/settings/tokens",
|
| 15 |
+
title="ZeroGPU quota exceeded",
|
| 16 |
+
),
|
| 17 |
+
gr.Error(
|
| 18 |
+
"The requested GPU duration (297s) is larger than the maximum allowedSubscribe to "
|
| 19 |
+
"Hugging Face PRO to allow GPU tasks up to 40 min - "
|
| 20 |
+
"https://huggingface.co/subscribe/pro?from=ZeroGPU",
|
| 21 |
+
title="ZeroGPU illegal duration",
|
| 22 |
+
),
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _card_text(category):
|
| 27 |
+
title, body = app._FRIENDLY_ERRORS[category]
|
| 28 |
+
return f"{title} {body}".lower()
|
| 29 |
|
| 30 |
|
| 31 |
def test_friendly_error_explains_a_workflow_that_produced_no_video():
|
|
|
|
| 40 |
def test_friendly_error_falls_back_for_unknown_categories():
|
| 41 |
title, _body = app._friendly_error("totally_unknown", "raw message")
|
| 42 |
assert title == "Generation failed"
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def test_unlogged_card_asks_the_visitor_to_sign_in_and_says_why():
|
| 46 |
+
assert app._FRIENDLY_ERRORS["unlogged"][0] == "Sign in to Hugging Face"
|
| 47 |
+
text = _card_text("unlogged")
|
| 48 |
+
assert "sign in" in text
|
| 49 |
+
assert "huggingface.co" in text
|
| 50 |
+
assert "too little gpu time" in text
|
| 51 |
+
for wrong_advice in ("shorter video", "fast preset", "25 min"):
|
| 52 |
+
assert wrong_advice not in text
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def test_illegal_duration_card_covers_signed_out_and_free_readers():
|
| 56 |
+
"""ZeroGPU's text does not say who the caller is, so the card has to address both."""
|
| 57 |
+
assert app._FRIENDLY_ERRORS["illegal_duration"][0] == "More GPU time than your account allows"
|
| 58 |
+
text = _card_text("illegal_duration")
|
| 59 |
+
assert "not signed in" in text and "sign in at huggingface.co" in text
|
| 60 |
+
assert "free account" in text and "fast or balanced preset" in text
|
| 61 |
+
assert "shorter video" not in text
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@pytest.mark.parametrize("exc", _SIGNED_OUT_REFUSALS, ids=["runs-limit", "larger-than-allowed"])
|
| 65 |
+
def test_signed_out_refusals_end_on_a_card_that_asks_to_sign_in(exc):
|
| 66 |
+
title, body = app._friendly_error(backend._classify(exc), str(exc))
|
| 67 |
+
assert "sign in" in f"{title} {body}".lower()
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def test_quota_exceeded_card_is_unchanged():
|
| 71 |
+
assert app._FRIENDLY_ERRORS["quota_exceeded"] == (
|
| 72 |
+
"Daily GPU quota used up",
|
| 73 |
+
"You've used today's GPU minutes. Wait for the rolling 24-hour "
|
| 74 |
+
"reset, or upgrade Pro at huggingface.co/subscribe/pro for more.",
|
| 75 |
+
)
|
|
@@ -68,6 +68,34 @@ def _html_string(html_contents: str, text_contents: str) -> str:
|
|
| 68 |
_QUOTA = "ZeroGPU quota exceeded"
|
| 69 |
_WAIT = "(240s requested vs. 12s left). Try again in 1:23:45"
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
# Each exception is built the way spaces/zero/client.py:schedule raises it.
|
| 73 |
@pytest.mark.parametrize(
|
|
@@ -96,14 +124,76 @@ _WAIT = "(240s requested vs. 12s left). Try again in 1:23:45"
|
|
| 96 |
),
|
| 97 |
pytest.param(
|
| 98 |
gr.Error("You have exceeded your runs limit.", title=_QUOTA),
|
| 99 |
-
"
|
| 100 |
id="quota-runs-limit-plain",
|
| 101 |
),
|
| 102 |
pytest.param(
|
| 103 |
_HTMLError("You have exceeded your runs limit.", title=_QUOTA),
|
| 104 |
-
"
|
| 105 |
id="quota-runs-limit-html",
|
| 106 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
pytest.param(
|
| 108 |
_HTMLError(
|
| 109 |
_html_string(
|
|
|
|
| 68 |
_QUOTA = "ZeroGPU quota exceeded"
|
| 69 |
_WAIT = "(240s requested vs. 12s left). Try again in 1:23:45"
|
| 70 |
|
| 71 |
+
# spaces 0.51 wording. The first four are verbatim from the Space's runtime log on
|
| 72 |
+
# 2026-11-15 (spaces 0.51.3); the rest follow schedule() in spaces 0.51.1
|
| 73 |
+
# zero/client.py, which adds a suffix by account only for API callers.
|
| 74 |
+
_SIGNED_OUT_RUNS_LIMIT_API = (
|
| 75 |
+
"You have exceeded your ZeroGPU runs limit. Authenticate with a Hugging Face token "
|
| 76 |
+
"for more quota - https://huggingface.co/settings/tokens"
|
| 77 |
+
)
|
| 78 |
+
_FREE_ACCOUNT_QUOTA_API = (
|
| 79 |
+
"You have exceeded your free ZeroGPU quota (279s requested vs. 21s left). Try again in "
|
| 80 |
+
"23:56:38. Subscribe to Hugging Face PRO to get 40 min of ZeroGPU quota a day - "
|
| 81 |
+
"https://huggingface.co/subscribe/pro?from=ZeroGPU"
|
| 82 |
+
)
|
| 83 |
+
_PRO_ACCOUNT_QUOTA_API = (
|
| 84 |
+
"You have exceeded your Pro ZeroGPU quota (360s requested vs. 184s left). Try again in "
|
| 85 |
+
"0:12:33. Add credits to keep using ZeroGPU. $1 for 10 minutes of ZeroGPU inference - "
|
| 86 |
+
"https://huggingface.co/settings/billing?add-credits=true"
|
| 87 |
+
)
|
| 88 |
+
_LARGER_THAN_ALLOWED = (
|
| 89 |
+
"The requested GPU duration (297s) is larger than the maximum allowedSubscribe to "
|
| 90 |
+
"Hugging Face PRO to allow GPU tasks up to 40 min - "
|
| 91 |
+
"https://huggingface.co/subscribe/pro?from=ZeroGPU"
|
| 92 |
+
)
|
| 93 |
+
_AUTHENTICATE_SUFFIX = (
|
| 94 |
+
"Authenticate with a Hugging Face token for more quota - https://huggingface.co/settings/tokens"
|
| 95 |
+
)
|
| 96 |
+
_RUNS_LIMIT_PAGE = "You have exceeded your ZeroGPU runs limit. "
|
| 97 |
+
_NO_ACCOUNT_QUOTA_PAGE = f"You have exceeded your ZeroGPU quota {_WAIT}. "
|
| 98 |
+
|
| 99 |
|
| 100 |
# Each exception is built the way spaces/zero/client.py:schedule raises it.
|
| 101 |
@pytest.mark.parametrize(
|
|
|
|
| 124 |
),
|
| 125 |
pytest.param(
|
| 126 |
gr.Error("You have exceeded your runs limit.", title=_QUOTA),
|
| 127 |
+
"unlogged",
|
| 128 |
id="quota-runs-limit-plain",
|
| 129 |
),
|
| 130 |
pytest.param(
|
| 131 |
_HTMLError("You have exceeded your runs limit.", title=_QUOTA),
|
| 132 |
+
"unlogged",
|
| 133 |
id="quota-runs-limit-html",
|
| 134 |
),
|
| 135 |
+
pytest.param(
|
| 136 |
+
gr.Error(_SIGNED_OUT_RUNS_LIMIT_API, title=_QUOTA),
|
| 137 |
+
"unlogged",
|
| 138 |
+
id="runs-limit-signed-out-api",
|
| 139 |
+
),
|
| 140 |
+
pytest.param(
|
| 141 |
+
gr.Error(_RUNS_LIMIT_PAGE, title=_QUOTA),
|
| 142 |
+
"unlogged",
|
| 143 |
+
id="runs-limit-from-page",
|
| 144 |
+
),
|
| 145 |
+
pytest.param(
|
| 146 |
+
gr.Error(
|
| 147 |
+
_RUNS_LIMIT_PAGE + "Subscribe to Hugging Face PRO to get 40 min of ZeroGPU "
|
| 148 |
+
"quota a day - https://huggingface.co/subscribe/pro?from=ZeroGPU",
|
| 149 |
+
title=_QUOTA,
|
| 150 |
+
),
|
| 151 |
+
"quota_exceeded",
|
| 152 |
+
id="runs-limit-free-account-api",
|
| 153 |
+
),
|
| 154 |
+
pytest.param(
|
| 155 |
+
gr.Error(
|
| 156 |
+
_RUNS_LIMIT_PAGE + "Add credits to keep using ZeroGPU. $1 for 10 minutes of "
|
| 157 |
+
"ZeroGPU inference - https://huggingface.co/settings/billing?add-credits=true",
|
| 158 |
+
title=_QUOTA,
|
| 159 |
+
),
|
| 160 |
+
"quota_exceeded",
|
| 161 |
+
id="runs-limit-pro-account-api",
|
| 162 |
+
),
|
| 163 |
+
pytest.param(
|
| 164 |
+
gr.Error(_NO_ACCOUNT_QUOTA_PAGE, title=_QUOTA),
|
| 165 |
+
"unlogged",
|
| 166 |
+
id="no-account-quota-from-page",
|
| 167 |
+
),
|
| 168 |
+
pytest.param(
|
| 169 |
+
gr.Error(_NO_ACCOUNT_QUOTA_PAGE + _AUTHENTICATE_SUFFIX, title=_QUOTA),
|
| 170 |
+
"unlogged",
|
| 171 |
+
id="no-account-quota-api",
|
| 172 |
+
),
|
| 173 |
+
pytest.param(
|
| 174 |
+
gr.Error(_FREE_ACCOUNT_QUOTA_API, title=_QUOTA),
|
| 175 |
+
"quota_exceeded",
|
| 176 |
+
id="free-account-quota-api",
|
| 177 |
+
),
|
| 178 |
+
pytest.param(
|
| 179 |
+
gr.Error(_PRO_ACCOUNT_QUOTA_API, title=_QUOTA),
|
| 180 |
+
"quota_exceeded",
|
| 181 |
+
id="pro-account-quota-api",
|
| 182 |
+
),
|
| 183 |
+
pytest.param(
|
| 184 |
+
gr.Error(_LARGER_THAN_ALLOWED, title="ZeroGPU illegal duration"),
|
| 185 |
+
"illegal_duration",
|
| 186 |
+
id="larger-than-allowed-names-no-caller",
|
| 187 |
+
),
|
| 188 |
+
pytest.param(
|
| 189 |
+
gr.Error(
|
| 190 |
+
"The requested GPU duration (297s) is larger than the maximum allowed"
|
| 191 |
+
+ _AUTHENTICATE_SUFFIX,
|
| 192 |
+
title="ZeroGPU illegal duration",
|
| 193 |
+
),
|
| 194 |
+
"unlogged",
|
| 195 |
+
id="larger-than-allowed-signed-out-suffix",
|
| 196 |
+
),
|
| 197 |
pytest.param(
|
| 198 |
_HTMLError(
|
| 199 |
_html_string(
|