launch: the Folder screen says that model files already stored are moved into a new folder
This commit is contained in:
1 parent
78fc321cd3
commit
e819ba0bd0
2 files changed
+34
No files matched your search
@@ -600,8 +600,26 @@ class FolderScreen(Base):
|
||||
out.append(f" Not enough for {need:.0f} GB. You can still go on, but the download is likely to stop; pick a bigger drive.", style=WARN)
|
||||
else:
|
||||
out.append("The free space of that folder could not be read.", style=MUTE)
|
||||
moving = self.models_that_would_move(value)
|
||||
if moving:
|
||||
out.append(f"\nModel files Strata already keeps in {moving} are moved into this folder when you start "
|
||||
"(quick on the same drive; on another drive they stay where they are and are used from there).", style=WARN)
|
||||
self.query_one("#folderinfo", Static).update(out)
|
||||
|
||||
def models_that_would_move(self, value: str) -> str | None:
|
||||
"""The folder holding model files today when a different one is typed (setup gathers the model files into the data folder), else None."""
|
||||
try:
|
||||
old = Path(self.ctx.catalog.data_dir())
|
||||
new = Path(value).expanduser() if value else old
|
||||
if os.path.normcase(str(new.resolve())) == os.path.normcase(str(old.resolve())):
|
||||
return None
|
||||
models = old / "models"
|
||||
if models.is_dir() and any(models.iterdir()):
|
||||
return str(old)
|
||||
except OSError:
|
||||
pass
|
||||
return None
|
||||
|
||||
def explain(self) -> Text:
|
||||
return Text("Models are large files. Strata keeps them in one folder; the default is Strata's own data folder. "
|
||||
"Press Enter to keep it, or type another folder (it is created if it does not exist).", style=MUTE)
|
||||
|
||||
@@ -315,6 +315,22 @@ class FolderStep(Base):
|
||||
self.assertIn("How much text should it remember at once?", text_of(app))
|
||||
self.run_app(case)
|
||||
|
||||
def test_a_new_folder_says_that_the_models_already_stored_will_move(self):
|
||||
async def case(app, pilot, ctx):
|
||||
old = self.home.base / "old-data"
|
||||
(old / "models" / "Q2_0").mkdir(parents=True)
|
||||
(old / "models" / "Q2_0" / "x.gguf").write_text("x")
|
||||
with mock.patch.object(type(ctx.catalog), "data_dir", return_value=old):
|
||||
await press(pilot, "enter", "enter")
|
||||
self.assertNotIn("are moved into this folder", text_of(app))
|
||||
f = app.screen.query_one("#folderpath")
|
||||
f.value = ""
|
||||
await typed(pilot, str(self.home.base / "new-data"))
|
||||
t = " ".join(text_of(app).replace("\n", " ").split())
|
||||
self.assertIn("Model files Strata already keeps in", t)
|
||||
self.assertIn("are moved into this folder when you start", t)
|
||||
self.run_app(case)
|
||||
|
||||
def test_keeping_the_default_stores_nothing(self):
|
||||
async def case(app, pilot, ctx):
|
||||
await press(pilot, "enter", "enter", "enter")
|
||||
|
||||
Reference in new issue
Block a user