launch: ask before downloading a model that is not here; tuning table labels
This commit is contained in:
1 parent
7c2f878051
commit
436fabc466
4 files changed
+59
-2
No files matched your search
@@ -221,10 +221,27 @@ class LaunchApp(App):
|
||||
self.ctx.settings = s
|
||||
self.run_launch()
|
||||
|
||||
def run_launch(self) -> None:
|
||||
def run_launch(self, confirmed: bool = False) -> None:
|
||||
s = self.ctx.settings
|
||||
self.cancel = threading.Event()
|
||||
self.runner = Runner(s, catalog=self.ctx.catalog, emit=self._emit, cancel=self.cancel, feed=self.ctx.feed)
|
||||
gb = getattr(self.runner, "download_gb", lambda: 0.0)() if not confirmed else 0.0
|
||||
if gb >= 1.0:
|
||||
free = self.ctx.catalog.disk_free(s.data_dir or self.ctx.catalog.data_dir())
|
||||
room = (f" There is {free:,.0f} GB free in the folder." if free is not None else "")
|
||||
warn = (" That is less than the download needs; it will probably stop part way." if free is not None and free < gb + 8 else "")
|
||||
|
||||
def done(choice: str | None) -> None:
|
||||
if choice == "go":
|
||||
self.run_launch(confirmed=True)
|
||||
elif self.current == "start":
|
||||
pass
|
||||
|
||||
self.push_screen(ConfirmScreen(f"Download about {gb:.0f} GB?",
|
||||
f"This model is not on this computer yet. Strata will download about {gb:.0f} GB now; an interrupted download continues where it stopped."
|
||||
+ room + warn,
|
||||
[("go", "Download and start"), ("no", "Not now")]), done)
|
||||
return
|
||||
screen = RunScreen()
|
||||
self.run_screen = screen
|
||||
self.current = "run"
|
||||
|
||||
@@ -344,6 +344,20 @@ class Runner:
|
||||
desc = self.catalog.strata.describe_config(path)
|
||||
return path, desc
|
||||
|
||||
def download_gb(self) -> float:
|
||||
"""How much would be downloaded for this launch right now: 0 when the model is installed with these choices (or is the person's own files)."""
|
||||
s = self.s
|
||||
if s.model_path or not (s.family and s.model):
|
||||
return 0.0
|
||||
try:
|
||||
path, desc = self.installed_state()
|
||||
if path is not None and desc is not None and desc_matches(desc, s) and not files_present(read_config(path)):
|
||||
return 0.0
|
||||
row = next((r for r in self.catalog.rows() if r.family == s.family and r.model == s.model), None)
|
||||
return float(row.download_gb) if row else 0.0
|
||||
except Exception: # noqa: BLE001
|
||||
return 0.0
|
||||
|
||||
def ensure_model(self) -> Path:
|
||||
s, cat = self.s, self.catalog
|
||||
if s.model_path and not (s.family and s.model):
|
||||
|
||||
@@ -1338,7 +1338,8 @@ class RunScreen(Base):
|
||||
t.append(f" about {info['minutes_left']} min left")
|
||||
t.append("\n")
|
||||
for sp in (info.get("speeds") or [])[-6:]:
|
||||
label = sp.get("label") or sp.get("id") or "?"
|
||||
label = {"base": "Default settings", "base_aa": "Default settings, measured again"}.get(sp.get("label") or sp.get("id"),
|
||||
sp.get("label") or sp.get("id") or "?")
|
||||
val = sp.get("decode_tok_s") or sp.get("value") or sp.get("tok_s")
|
||||
t.append(f" {str(label)[:34]:<36}{val if val is not None else '-'}" + (" tokens/s" if val is not None else "") + "\n")
|
||||
t.append(" Close other heavy programs while it measures. You can stop it any time: nothing changes until it is done.\n", style=MUTE)
|
||||
|
||||
@@ -36,11 +36,15 @@ class FakeRunner:
|
||||
instances: list = []
|
||||
behaviour = "ok"
|
||||
hold = 0
|
||||
download = 0.0
|
||||
|
||||
def __init__(self, s, *, catalog=None, emit=None, cancel=None, feed=None, **kw):
|
||||
self.s, self.emit_cb, self.cancel, self.feed = s, emit, cancel, feed
|
||||
FakeRunner.instances.append(self)
|
||||
|
||||
def download_gb(self):
|
||||
return FakeRunner.download
|
||||
|
||||
def run(self, start=True):
|
||||
e = self.emit_cb
|
||||
e(Event("engine", "Engine 0.1.45 (cuda) is installed.", 100))
|
||||
@@ -85,6 +89,7 @@ class Base(unittest.TestCase):
|
||||
self.addCleanup(self.home.__exit__, None, None, None)
|
||||
FakeRunner.instances.clear()
|
||||
FakeRunner.behaviour = "ok"
|
||||
FakeRunner.download = 0.0
|
||||
p = mock.patch("strata_cli.launch.app.Runner", FakeRunner)
|
||||
p.start()
|
||||
self.addCleanup(p.stop)
|
||||
@@ -141,6 +146,26 @@ class StartScreenTests(Base):
|
||||
self.assertEqual(app.result.profile, "launch-x")
|
||||
self.run_app(case)
|
||||
|
||||
def test_a_model_that_is_not_here_asks_before_downloading(self):
|
||||
store.save(S.LaunchSettings(name="Big", family="qwen", model="IQ3_XXS", context=65536))
|
||||
FakeRunner.download = 75.8
|
||||
|
||||
async def case(app, pilot, ctx):
|
||||
await press(pilot, "enter")
|
||||
t = flat(app)
|
||||
self.assertIn("Download about 76 GB?", t)
|
||||
self.assertIn("not on this computer yet", t)
|
||||
self.assertIn("Download and start", t)
|
||||
self.assertEqual(FakeRunner.instances[-1].behaviour, "ok")
|
||||
await press(pilot, "down", "enter") # Not now
|
||||
await pilot.pause(0.3)
|
||||
self.assertIsNone(app.result)
|
||||
await press(pilot, "enter")
|
||||
await press(pilot, "enter") # Download and start
|
||||
await pilot.pause(0.8)
|
||||
self.assertIsNotNone(app.result)
|
||||
self.run_app(case)
|
||||
|
||||
def test_delete_asks_then_removes_only_the_preset(self):
|
||||
store.save(S.LaunchSettings(name="Old", family="qwen", model="Q2_0", context=32768))
|
||||
|
||||
|
||||
Reference in new issue
Block a user