Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,30 @@ import os
|
|
| 8 |
@spaces.GPU
|
| 9 |
def run_peft_eval():
|
| 10 |
print("Starting evaluation...", flush=True)
|
|
|
|
| 11 |
try:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
return "Evaluation failed. Check logs."
|
| 17 |
|
|
|
|
| 18 |
try:
|
| 19 |
shutdown_url = os.environ.get("HF_ENDPOINT_SHUTDOWN")
|
| 20 |
if shutdown_url:
|
|
@@ -23,13 +40,15 @@ def run_peft_eval():
|
|
| 23 |
except Exception as e:
|
| 24 |
print("Shutdown failed:", e, flush=True)
|
| 25 |
|
| 26 |
-
return f"PEFT-Bench completed at {datetime.datetime.utcnow():%Y-%m-%d %H:%M UTC}"
|
| 27 |
|
| 28 |
with gr.Blocks() as demo:
|
| 29 |
-
gr.Markdown("PEFT-Bench GPU Evaluator")
|
| 30 |
-
gr.Markdown("Click the button below to
|
|
|
|
| 31 |
status = gr.Textbox(label="Status", lines=2)
|
| 32 |
btn = gr.Button("Start Evaluation")
|
|
|
|
| 33 |
btn.click(fn=run_peft_eval, outputs=status)
|
| 34 |
|
| 35 |
demo.launch(show_error=True)
|
|
|
|
| 8 |
@spaces.GPU
|
| 9 |
def run_peft_eval():
|
| 10 |
print("Starting evaluation...", flush=True)
|
| 11 |
+
|
| 12 |
try:
|
| 13 |
+
process = subprocess.Popen(
|
| 14 |
+
["python3", "run_eval.py"],
|
| 15 |
+
stdout=subprocess.PIPE,
|
| 16 |
+
stderr=subprocess.STDOUT,
|
| 17 |
+
universal_newlines=True,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
log_lines = []
|
| 21 |
+
for line in process.stdout:
|
| 22 |
+
print(line, end='', flush=True)
|
| 23 |
+
log_lines.append(line)
|
| 24 |
+
|
| 25 |
+
process.wait()
|
| 26 |
+
|
| 27 |
+
if process.returncode != 0:
|
| 28 |
+
return "Evaluation failed. See logs above."
|
| 29 |
+
|
| 30 |
+
except Exception as e:
|
| 31 |
+
print("Eval script failed:", e, flush=True)
|
| 32 |
return "Evaluation failed. Check logs."
|
| 33 |
|
| 34 |
+
# Optional shutdown trigger (Spaces-only feature)
|
| 35 |
try:
|
| 36 |
shutdown_url = os.environ.get("HF_ENDPOINT_SHUTDOWN")
|
| 37 |
if shutdown_url:
|
|
|
|
| 40 |
except Exception as e:
|
| 41 |
print("Shutdown failed:", e, flush=True)
|
| 42 |
|
| 43 |
+
return f"✅ PEFT-Bench completed at {datetime.datetime.utcnow():%Y-%m-%d %H:%M UTC}"
|
| 44 |
|
| 45 |
with gr.Blocks() as demo:
|
| 46 |
+
gr.Markdown("### PEFT-Bench GPU Evaluator")
|
| 47 |
+
gr.Markdown("Click the button below to run `run_eval.py`. The Space will automatically shut down when complete.")
|
| 48 |
+
|
| 49 |
status = gr.Textbox(label="Status", lines=2)
|
| 50 |
btn = gr.Button("Start Evaluation")
|
| 51 |
+
|
| 52 |
btn.click(fn=run_peft_eval, outputs=status)
|
| 53 |
|
| 54 |
demo.launch(show_error=True)
|