Mdrnfox commited on
Commit
582209c
·
verified ·
1 Parent(s): bba84bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -3,20 +3,34 @@ import spaces
3
  import subprocess
4
  import requests
5
  import datetime
 
6
 
7
- @spaces.GPU
8
  def run_peft_eval():
9
- subprocess.run(["python3", "run_eval.py"], check=True)
10
- print("Evaluation complete.")
11
  try:
12
- requests.post(os.environ["HF_ENDPOINT_SHUTDOWN"]) # Shutdown space after run
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  except Exception as e:
14
  print("Failed to shutdown:", e)
15
- return f"PEFT-Bench completed at {datetime.datetime.utcnow():%Y-%m-%d %H:%M UTC}"
 
16
 
17
  with gr.Blocks() as demo:
18
- gr.Markdown("### Running PEFT-Bench Evaluation...\nThis Space will shut down when done.")
19
- output = gr.Textbox(label="Status")
20
  demo.load(fn=run_peft_eval, outputs=output)
21
 
22
  demo.launch()
 
3
  import subprocess
4
  import requests
5
  import datetime
6
+ import os
7
 
8
+ @spaces.GPU
9
  def run_peft_eval():
10
+ print("Starting evaluation via run_eval.py")
 
11
  try:
12
+ result = subprocess.run(["python3", "run_eval.py"], capture_output=True, text=True, check=True)
13
+ print(result.stdout)
14
+ except subprocess.CalledProcessError as e:
15
+ print("❌ Evaluation script failed:")
16
+ print(e.stderr)
17
+ return "Evaluation failed. Check logs."
18
+
19
+ print("Evaluation complete. Attempting shutdown.")
20
+ try:
21
+ shutdown_url = os.environ.get("HF_ENDPOINT_SHUTDOWN")
22
+ if shutdown_url:
23
+ requests.post(shutdown_url)
24
+ else:
25
+ print("No shutdown endpoint found.")
26
  except Exception as e:
27
  print("Failed to shutdown:", e)
28
+
29
+ return f"✅ PEFT-Bench completed at {datetime.datetime.utcnow():%Y-%m-%d %H:%M UTC}"
30
 
31
  with gr.Blocks() as demo:
32
+ gr.Markdown("Running PEFT-Bench Evaluation...\nThis Space will shut down when done.")
33
+ output = gr.Textbox(label="Status", lines=2)
34
  demo.load(fn=run_peft_eval, outputs=output)
35
 
36
  demo.launch()