feat: stream pip output live to UI logs during unsloth install
Browse files- 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 + [
|
| 60 |
-
|
|
|
|
| 61 |
]
|
| 62 |
installed = False
|
| 63 |
for cmd in install_cmds:
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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.")
|