File size: 1,199 Bytes
c3483b0
 
 
 
 
582209c
c3483b0
582209c
c3483b0
2d819a2
c3483b0
582209c
2d819a2
582209c
2d819a2
 
582209c
 
 
 
 
2d819a2
582209c
c3483b0
2d819a2
582209c
3360b16
c3483b0
 
2d819a2
3360b16
 
 
 
c3483b0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import spaces
import subprocess
import requests
import datetime
import os

@spaces.GPU
def run_peft_eval():
    print("Starting evaluation via run_eval.py", flush=True)
    try:
        result = subprocess.run(["python3", "run_eval.py"], capture_output=True, text=True, check=True)
        print(result.stdout, flush=True)
    except subprocess.CalledProcessError as e:
        print("Evaluation script failed:", flush=True)
        print(e.stderr, flush=True)
        return "Evaluation failed. Check logs."

    try:
        shutdown_url = os.environ.get("HF_ENDPOINT_SHUTDOWN")
        if shutdown_url:
            print("Evaluation done. Shutting down...", flush=True)
            requests.post(shutdown_url)
    except Exception as e:
        print("Failed to shutdown:", e, flush=True)

    return f"PEFT-Bench completed at {datetime.datetime.utcnow():%Y-%m-%d %H:%M UTC}"

with gr.Blocks() as demo:
    gr.Markdown("## PEFT-Bench Evaluation")
    gr.Markdown("This Space runs evaluation and shuts down when finished.")
    status = gr.Textbox(label="Status", lines=2)
    btn = gr.Button("Start Evaluation Now")
    btn.click(run_peft_eval, outputs=status)

demo.launch()