Siddh12334 commited on
Commit
ac34a90
·
verified ·
1 Parent(s): 9f4f5dc

feat: stream pip output live to UI logs during unsloth install

Browse files
Files changed (1) hide show
  1. training/space_runner.py +18 -8
training/space_runner.py CHANGED
@@ -55,21 +55,31 @@ def _run_training():
55
  _pip_base = [sys.executable, "-m", "pip", "install", "--no-cache-dir", "--target", _PKGS]
56
 
57
  install_cmds = [
58
- _pip_base + ["unsloth"],
59
- _pip_base + [f"unsloth[cu121-ampere-{torch_tag}] @ git+https://github.com/unslothai/unsloth.git"],
60
- _pip_base + ["git+https://github.com/unslothai/unsloth.git"],
 
61
  ]
62
  installed = False
63
  for cmd in install_cmds:
64
- result = subprocess.run(cmd, capture_output=True, text=True)
65
- if result.returncode == 0:
 
 
 
 
 
 
 
 
 
 
66
  if _PKGS not in sys.path:
67
  sys.path.insert(0, _PKGS)
68
- _append_log("unsloth installed successfully.")
69
  installed = True
70
  break
71
- err = (result.stderr or result.stdout or "")[-600:].strip()
72
- _append_log(f"Install attempt failed:\n{err}")
73
  if not installed:
74
  _training_status = "failed"
75
  _append_log("❌ All unsloth install attempts failed. Check logs above.")
 
55
  _pip_base = [sys.executable, "-m", "pip", "install", "--no-cache-dir", "--target", _PKGS]
56
 
57
  install_cmds = [
58
+ _pip_base + ["--progress-bar", "on", "unsloth"],
59
+ _pip_base + ["--progress-bar", "on",
60
+ f"unsloth[cu121-ampere-{torch_tag}] @ git+https://github.com/unslothai/unsloth.git"],
61
+ _pip_base + ["--progress-bar", "on", "git+https://github.com/unslothai/unsloth.git"],
62
  ]
63
  installed = False
64
  for cmd in install_cmds:
65
+ proc = subprocess.Popen(
66
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
67
+ text=True, bufsize=1,
68
+ )
69
+ lines = []
70
+ for line in proc.stdout:
71
+ line = line.rstrip()
72
+ if line:
73
+ _append_log(line)
74
+ lines.append(line)
75
+ proc.wait()
76
+ if proc.returncode == 0:
77
  if _PKGS not in sys.path:
78
  sys.path.insert(0, _PKGS)
79
+ _append_log("unsloth installed successfully.")
80
  installed = True
81
  break
82
+ _append_log(f"⚠️ Install attempt failed (exit {proc.returncode}), trying next...")
 
83
  if not installed:
84
  _training_status = "failed"
85
  _append_log("❌ All unsloth install attempts failed. Check logs above.")