Spaces:
Running on Zero
Running on Zero
Shubhamm-02 commited on
Commit ·
8db2efe
1
Parent(s): 26ba4fe
Add ZeroGPU startup probe for HF free tier
Browse files- app.py +13 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -28,6 +28,19 @@ from pr_review_agent.tools import (
|
|
| 28 |
parse_pr_ref,
|
| 29 |
)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Build the agent once at startup and reuse it across requests.
|
| 32 |
_agent = build_agent()
|
| 33 |
|
|
|
|
| 28 |
parse_pr_ref,
|
| 29 |
)
|
| 30 |
|
| 31 |
+
# Hugging Face's free Gradio Spaces run on ZeroGPU, which refuses to start unless a
|
| 32 |
+
# @spaces.GPU function exists. Review Pilot only does network I/O (it calls a hosted
|
| 33 |
+
# model), so it needs no GPU — this tiny no-op just satisfies that startup check.
|
| 34 |
+
# Wrapped in try/except so local dev (where `spaces` isn't installed) is unaffected.
|
| 35 |
+
try: # pragma: no cover - only runs on Hugging Face Spaces
|
| 36 |
+
import spaces
|
| 37 |
+
|
| 38 |
+
@spaces.GPU(duration=15)
|
| 39 |
+
def _zerogpu_startup_probe() -> bool:
|
| 40 |
+
return True
|
| 41 |
+
except Exception:
|
| 42 |
+
pass
|
| 43 |
+
|
| 44 |
# Build the agent once at startup and reuse it across requests.
|
| 45 |
_agent = build_agent()
|
| 46 |
|
requirements.txt
CHANGED
|
@@ -13,3 +13,4 @@ ollama==0.6.2 # ollama backend (local dev)
|
|
| 13 |
|
| 14 |
mcp==1.29.1
|
| 15 |
python-dotenv==1.2.3
|
|
|
|
|
|
| 13 |
|
| 14 |
mcp==1.29.1
|
| 15 |
python-dotenv==1.2.3
|
| 16 |
+
spaces
|