Spaces:
Sleeping
Sleeping
Restore known-good launch structure; GPU probe for provisioning only
Browse files- app/__pycache__/app.cpython-312.pyc +0 -0
- app/app.py +40 -57
app/__pycache__/app.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/app.cpython-312.pyc and b/app/__pycache__/app.cpython-312.pyc differ
|
|
|
app/app.py
CHANGED
|
@@ -64,23 +64,37 @@ from app import panels, theme
|
|
| 64 |
# ZeroGPU runs limit" while every local test passed, because locally the
|
| 65 |
# decorator is documented as effect-free.
|
| 66 |
#
|
| 67 |
-
#
|
| 68 |
-
#
|
| 69 |
-
#
|
| 70 |
-
# and
|
|
|
|
|
|
|
| 71 |
#
|
| 72 |
-
#
|
| 73 |
-
#
|
| 74 |
-
#
|
| 75 |
-
#
|
| 76 |
-
#
|
| 77 |
-
# ZeroGPU scheduler, and HuggingFace lists it as a required step independently
|
| 78 |
-
# of decorating anything. So: import it, decorate nothing.
|
| 79 |
try: # pragma: no cover - the Hub runtime always provides this
|
| 80 |
-
import spaces
|
| 81 |
except ImportError: # local development, CI, the test suite
|
| 82 |
spaces = None
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
ROOT = Path(__file__).resolve().parent.parent
|
| 85 |
ASSETS = ROOT / "app" / "assets"
|
| 86 |
MODELS = ROOT / "outputs" / "models"
|
|
@@ -877,55 +891,24 @@ def build_interface() -> gr.Blocks:
|
|
| 877 |
return demo
|
| 878 |
|
| 879 |
|
| 880 |
-
#: Module-level, and named `demo`, because the Spaces runner IMPORTS this module
|
| 881 |
-
#: and looks for exactly that name -- with the interface built only inside
|
| 882 |
-
#: main(), the Space started a server, found no `demo`, and exited with
|
| 883 |
-
#: RUNTIME_ERROR while `python app/app.py` worked perfectly on a laptop.
|
| 884 |
-
demo = build_interface()
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
# Gradio 6 moved `theme` and `css` off Blocks and onto launch(), and the Spaces
|
| 888 |
-
# runner calls demo.launch() ITSELF with its own arguments. Passing styling only
|
| 889 |
-
# inside main() therefore deploys a completely unstyled console -- the theme is
|
| 890 |
-
# silently dropped, and nothing fails loudly enough to notice. Binding the
|
| 891 |
-
# defaults onto the object makes the styling survive whichever process launches
|
| 892 |
-
# it, locally or on the Hub.
|
| 893 |
-
_raw_launch = demo.launch
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
def _styled_launch(*args, **kwargs):
|
| 897 |
-
kwargs.setdefault("theme", theme.build_theme())
|
| 898 |
-
kwargs.setdefault("css", theme.CSS)
|
| 899 |
-
return _raw_launch(*args, **kwargs)
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
demo.launch = _styled_launch
|
| 903 |
-
|
| 904 |
-
|
| 905 |
def main() -> None:
|
| 906 |
"""Launch the console.
|
| 907 |
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
|
|
|
|
|
|
| 914 |
"""
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
# already running under a reload manager -- `if self._is_running_in_reload_thread:
|
| 922 |
-
# return` -- which is how the Spaces runner serves the app. Locally there is
|
| 923 |
-
# no reload thread, so launch() blocks and the script stays up; on the Space
|
| 924 |
-
# it fell straight through, __main__ ended, and the process exited taking the
|
| 925 |
-
# SSR Node server with it ("Stopping Node.js server..."). The Space reported
|
| 926 |
-
# RUNTIME_ERROR seconds after a successful bind, and no local run could
|
| 927 |
-
# reproduce it. If launch() did block, this line is simply never reached.
|
| 928 |
-
demo.block_thread()
|
| 929 |
|
| 930 |
|
| 931 |
if __name__ == "__main__":
|
|
|
|
| 64 |
# ZeroGPU runs limit" while every local test passed, because locally the
|
| 65 |
# decorator is documented as effect-free.
|
| 66 |
#
|
| 67 |
+
# SO THE INFERENCE PATH IS NOT DECORATED. What the platform still needs is a
|
| 68 |
+
# GPU entry point to exist at all: with no `@spaces.GPU` anywhere the Space sat
|
| 69 |
+
# at `hardware: None` against `requested_hardware: zero-a10g`, bound its port,
|
| 70 |
+
# and served 503 on every request -- the ZeroGPU container was never
|
| 71 |
+
# provisioned. HuggingFace's own instructions list importing `spaces` and
|
| 72 |
+
# decorating a GPU function as the steps that make a ZeroGPU Space work.
|
| 73 |
#
|
| 74 |
+
# The resolution is to declare ONE minimal GPU entry point that the console
|
| 75 |
+
# never calls on any user path. It satisfies provisioning; it consumes no quota
|
| 76 |
+
# because it is never invoked. This is a platform accommodation, stated plainly
|
| 77 |
+
# rather than dressed up as a computational need: nothing in this project uses
|
| 78 |
+
# a GPU, and no model was changed to pretend otherwise.
|
|
|
|
|
|
|
| 79 |
try: # pragma: no cover - the Hub runtime always provides this
|
| 80 |
+
import spaces
|
| 81 |
except ImportError: # local development, CI, the test suite
|
| 82 |
spaces = None
|
| 83 |
|
| 84 |
+
|
| 85 |
+
if spaces is not None: # pragma: no cover - only meaningful on ZeroGPU
|
| 86 |
+
|
| 87 |
+
@spaces.GPU(duration=1)
|
| 88 |
+
def _zerogpu_provisioning_probe() -> str:
|
| 89 |
+
"""Declared so ZeroGPU provisions the Space. Never called by the UI.
|
| 90 |
+
|
| 91 |
+
Every user-facing path -- prediction, grading, the shift check --
|
| 92 |
+
deliberately avoids this function. See the note above on why decorating
|
| 93 |
+
the real inference path exhausted a 5-minute daily quota in one page
|
| 94 |
+
load.
|
| 95 |
+
"""
|
| 96 |
+
return "cpu-bound console; no GPU work is performed"
|
| 97 |
+
|
| 98 |
ROOT = Path(__file__).resolve().parent.parent
|
| 99 |
ASSETS = ROOT / "app" / "assets"
|
| 100 |
MODELS = ROOT / "outputs" / "models"
|
|
|
|
| 891 |
return demo
|
| 892 |
|
| 893 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 894 |
def main() -> None:
|
| 895 |
"""Launch the console.
|
| 896 |
|
| 897 |
+
Theme and CSS are passed to launch() rather than to Blocks: Gradio 6 moved
|
| 898 |
+
them there, and `show_api` was removed in the same release.
|
| 899 |
+
|
| 900 |
+
DELIBERATELY PLAIN. Successive attempts to out-guess the Spaces runner --
|
| 901 |
+
exposing a module-level `demo`, wrapping `launch` to re-inject styling,
|
| 902 |
+
ceding the port, forcing `block_thread()` -- each fixed an imagined problem
|
| 903 |
+
and left the Space unprovisioned at `hardware: None`. The structure below is
|
| 904 |
+
the one that actually reached RUNNING on ZeroGPU with the theme intact.
|
| 905 |
"""
|
| 906 |
+
build_interface().launch(
|
| 907 |
+
server_name="0.0.0.0",
|
| 908 |
+
server_port=7860,
|
| 909 |
+
theme=theme.build_theme(),
|
| 910 |
+
css=theme.CSS,
|
| 911 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 912 |
|
| 913 |
|
| 914 |
if __name__ == "__main__":
|