Percy3822 commited on
Commit
0e88f74
·
verified ·
1 Parent(s): a174668

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -40,23 +40,21 @@ def start_training():
40
  "--block_size", "256",
41
  "--learning_rate", "5e-5",
42
  ]
43
- # run training (blocking) and capture logs
44
  with open(LOG, "a", encoding="utf-8") as lf:
45
  code = subprocess.Popen(cmd, stdout=lf, stderr=subprocess.STDOUT).wait()
46
 
47
- # after process exits, show result
48
  if code == 0 and ZIP.exists():
49
  info = f"✅ Training complete. Saved: {OUT.name} | Zip: {ZIP.name}"
50
- return info, gr.File.update(value=str(ZIP), visible=True), ls_workspace(), read_logs()
51
  else:
52
  info = f"❌ Training failed (exit {code}). See logs."
53
- return info, gr.File.update(visible=False), ls_workspace(), read_logs()
54
 
55
  def read_logs():
56
  return LOG.read_text(encoding="utf-8")[-20000:] if LOG.exists() else "⏳ Waiting…"
57
 
58
  def refresh_download():
59
- return gr.File.update(value=str(ZIP), visible=ZIP.exists()), ls_workspace()
60
 
61
  # ---------------- Test tab ----------------
62
  def list_models():
 
40
  "--block_size", "256",
41
  "--learning_rate", "5e-5",
42
  ]
 
43
  with open(LOG, "a", encoding="utf-8") as lf:
44
  code = subprocess.Popen(cmd, stdout=lf, stderr=subprocess.STDOUT).wait()
45
 
 
46
  if code == 0 and ZIP.exists():
47
  info = f"✅ Training complete. Saved: {OUT.name} | Zip: {ZIP.name}"
48
+ return info, gr.update(value=str(ZIP), visible=True), ls_workspace(), read_logs()
49
  else:
50
  info = f"❌ Training failed (exit {code}). See logs."
51
+ return info, gr.update(visible=False), ls_workspace(), read_logs()
52
 
53
  def read_logs():
54
  return LOG.read_text(encoding="utf-8")[-20000:] if LOG.exists() else "⏳ Waiting…"
55
 
56
  def refresh_download():
57
+ return gr.update(value=str(ZIP), visible=ZIP.exists()), ls_workspace()
58
 
59
  # ---------------- Test tab ----------------
60
  def list_models():