GitHub Actions commited on
Commit
7063d0f
·
1 Parent(s): f2521a8

Add ZeroGPU startup probe

Browse files
Files changed (3) hide show
  1. app.py +21 -0
  2. pyproject.toml +4 -0
  3. requirements.txt +1 -0
app.py CHANGED
@@ -11,10 +11,31 @@ from typing import Any
11
 
12
  import gradio as gr
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  APP_TITLE = "HearthNet"
15
  APP_SUBTITLE = "Phase 1 browser-mesh coordination, resilient AI assistance, and traceable local-first workflows."
16
 
17
 
 
 
 
 
 
18
  @dataclass
19
  class CoreAdapter:
20
  name: str
 
11
 
12
  import gradio as gr
13
 
14
+ try:
15
+ import spaces
16
+ except ImportError:
17
+
18
+ class _SpacesFallback:
19
+ @staticmethod
20
+ def GPU( # pylint: disable=invalid-name
21
+ *_args: object, **_kwargs: object
22
+ ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
23
+ def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
24
+ return func
25
+
26
+ return decorator
27
+
28
+ spaces = _SpacesFallback()
29
+
30
  APP_TITLE = "HearthNet"
31
  APP_SUBTITLE = "Phase 1 browser-mesh coordination, resilient AI assistance, and traceable local-first workflows."
32
 
33
 
34
+ @spaces.GPU(duration=1)
35
+ def zero_gpu_startup_probe() -> str:
36
+ return "HearthNet ZeroGPU probe ready"
37
+
38
+
39
  @dataclass
40
  class CoreAdapter:
41
  name: str
pyproject.toml CHANGED
@@ -6,6 +6,7 @@ readme = "README.md"
6
  requires-python = ">=3.12"
7
  dependencies = [
8
  "gradio>=6.16.0,<7.0",
 
9
  ]
10
 
11
  [tool.ruff]
@@ -48,6 +49,9 @@ ignore = [
48
  "hearthnet/types.py" = [
49
  "A005",
50
  ]
 
 
 
51
 
52
  [tool.ruff.format]
53
  quote-style = "double"
 
6
  requires-python = ">=3.12"
7
  dependencies = [
8
  "gradio>=6.16.0,<7.0",
9
+ "spaces>=0.30.0",
10
  ]
11
 
12
  [tool.ruff]
 
49
  "hearthnet/types.py" = [
50
  "A005",
51
  ]
52
+ "app.py" = [
53
+ "N802",
54
+ ]
55
 
56
  [tool.ruff.format]
57
  quote-style = "double"
requirements.txt CHANGED
@@ -1 +1,2 @@
1
  gradio>=6.16.0,<7.0
 
 
1
  gradio>=6.16.0,<7.0
2
+ spaces>=0.30.0