A missing shard is named with its file name in the CLI, the TUI and the app's plain issues (TUI stress #9, C05, #3478)
plan_import now returns missing_shards (the file names of the split set that are not in the folder). problem_words and plain_issues say "<name>-00002-of-00002.gguf is missing" instead of "some parts of the model are missing"; more than two are counted. The three call sites (models import, strata launch --model-path, the Model screen's own-files field) pass the list.
This commit is contained in:
1 parent
eb818c50ed
commit
ea67f6999a
5 files changed
+59
-7
No files matched your search
+1
-1
@@ -606,7 +606,7 @@ def _models(a: argparse.Namespace) -> int:
|
||||
def _import_problem(plan: dict) -> str:
|
||||
"""Why `models import --plan` refused, in plain words (the codes stay in --output json)."""
|
||||
from strata_control import models as own_models
|
||||
words = own_models.problem_words(plan.get("issues") or [])
|
||||
words = own_models.problem_words(plan.get("issues") or [], missing=plan.get("missing_shards"))
|
||||
text = f"These files cannot be used as they are: {words}."
|
||||
holds = next((m for m in plan.get("messages") or [] if "holds" in m), "")
|
||||
if holds:
|
||||
|
||||
@@ -1039,7 +1039,7 @@ class Runner:
|
||||
sel = plan.get("candidate_selection") or {}
|
||||
fam, model = sel.get("family"), sel.get("model")
|
||||
if not (fam and model) or plan.get("issues"):
|
||||
issues = models.problem_words(plan.get("issues") or []) or "they are not a model Strata knows"
|
||||
issues = models.problem_words(plan.get("issues") or [], missing=plan.get("missing_shards")) or "they are not a model Strata knows"
|
||||
more = " " + next((m for m in plan.get("messages") or [] if "holds" in m), "")
|
||||
raise LaunchError(f"These files cannot be used as they are ({issues}).{more.rstrip()}",
|
||||
"Choose the matching model in the list, or check that every shard is in the folder.", 5)
|
||||
|
||||
@@ -513,7 +513,7 @@ class ModelScreen(Base):
|
||||
self.menu().select((sel["family"], sel["model"]))
|
||||
self.paint()
|
||||
else:
|
||||
why = models.problem_words(plan.get("issues") or []) or "they are not a model Strata knows"
|
||||
why = models.problem_words(plan.get("issues") or [], missing=plan.get("missing_shards")) or "they are not a model Strata knows"
|
||||
holds = next((m for m in plan.get("messages") or [] if "holds" in m), "")
|
||||
self.say(f"These files cannot be used as they are ({why}). " + (holds + " " if holds else "") +
|
||||
"Check that every shard is in the folder, or pick a model from the list.", True)
|
||||
|
||||
@@ -352,11 +352,26 @@ def plain_issue(code: str) -> str:
|
||||
return f"{name}: {words}" if name else words
|
||||
|
||||
|
||||
def problem_words(issues: list, limit: int = 3) -> str:
|
||||
def missing_words(missing: list | None) -> str:
|
||||
""""x-00002-of-00002.gguf is missing" for the shards of a split model that are not in the folder (#3478); "" when none are known."""
|
||||
names = [str(n) for n in missing or []]
|
||||
if not names:
|
||||
return ""
|
||||
if len(names) == 1:
|
||||
return f"{names[0]} is missing"
|
||||
if len(names) == 2:
|
||||
return f"{names[0]} and {names[1]} are missing"
|
||||
return f"{names[0]}, {names[1]} and {len(names) - 2} more files are missing"
|
||||
|
||||
|
||||
def problem_words(issues: list, limit: int = 3, missing: list | None = None) -> str:
|
||||
"""The problems of a file set as ONE sentence part, each said once: the same reason for several files names the files together
|
||||
("a.gguf and b.gguf: the file is cut short"), a reason that was already given is not given again, and a long list is cut with a count.
|
||||
A folder that holds several models does not also say "not a size Strata knows"."""
|
||||
codes = [str(x) for x in issues or []]
|
||||
named = missing_words(missing)
|
||||
if named: # the generic "some parts are missing" is replaced by the files
|
||||
codes = [x for x in codes if x != "incomplete_or_invalid_shard_set"]
|
||||
if "multiple_model_groups" in codes:
|
||||
codes = [x for x in codes if x != "unrecognized_or_unsupported_model_variant"]
|
||||
by_reason: dict[str, list[str]] = {}
|
||||
@@ -367,7 +382,7 @@ def problem_words(issues: list, limit: int = 3) -> str:
|
||||
by_reason.setdefault(reason, []).append(name)
|
||||
else:
|
||||
by_reason.setdefault(words, [])
|
||||
parts = []
|
||||
parts = [named] if named else []
|
||||
for reason, names in by_reason.items():
|
||||
if not names:
|
||||
parts.append(reason)
|
||||
@@ -578,6 +593,7 @@ def plan_import(raw_path: str) -> dict:
|
||||
notes: list[str] = []
|
||||
folder_holds: list[dict] = []
|
||||
issues: list[str] = []
|
||||
missing_shards: list[str] = []
|
||||
if stat.S_ISDIR(details.st_mode):
|
||||
shards, ignored_auxiliary, cut = _list_gguf(path)
|
||||
if cut:
|
||||
@@ -642,8 +658,13 @@ def plan_import(raw_path: str) -> dict:
|
||||
found = {int(m.group(2)) for m in (SHARD.fullmatch(item.name) for item in members) if m} or {1}
|
||||
if total > MAX_IMPORT_SHARDS or found != set(range(1, total + 1)):
|
||||
issues.append("incomplete_or_invalid_shard_set")
|
||||
sample = next((SHARD.fullmatch(item.name) for item in members if SHARD.fullmatch(item.name)), None)
|
||||
if sample and total <= MAX_IMPORT_SHARDS: # #3478: name the files that are not there
|
||||
missing_shards = [f"{sample.group(1)}-{i:05d}-of-{total:05d}.gguf" for i in range(1, total + 1) if i not in found]
|
||||
files = []
|
||||
for item in shards:
|
||||
if missing_shards and not item.exists():
|
||||
continue # a shard that is named only to be reported missing has no header to read
|
||||
try:
|
||||
files.append(_gguf_header(item))
|
||||
except ProfileError as exc:
|
||||
@@ -699,14 +720,14 @@ def plan_import(raw_path: str) -> dict:
|
||||
return {"source": str(path), "model_dir": str(model_dir), "scope": "local_gguf_candidate", "files": files,
|
||||
"file_count": len(files), "total_bytes": sum(item["bytes"] for item in files),
|
||||
"metadata": metadata, "candidate_selection": candidate,
|
||||
"plain_issues": list(dict.fromkeys(plain_issue(i) for i in issues)),
|
||||
"plain_issues": list(dict.fromkeys((missing_words(missing_shards) if (i == "incomplete_or_invalid_shard_set" and missing_shards) else plain_issue(i)) for i in issues)),
|
||||
"observed_expert_types": sorted(observed_experts),
|
||||
"observed_tensor_count": observed_tensor_count,
|
||||
"ignored_auxiliary_files": sorted(ignored_auxiliary),
|
||||
"projectors": projectors, "messages": messages, "already_set_up": _already_set_up(shards, candidate),
|
||||
"reads_pictures": any(p["status"] in ("ok", "other_name") for p in projectors) and
|
||||
not any(i.endswith("unsupported_architecture") for i in issues),
|
||||
"folder_holds": folder_holds,
|
||||
"folder_holds": folder_holds, "missing_shards": missing_shards,
|
||||
"file_set_status": "plausible" if not issues else "invalid_or_incomplete",
|
||||
"issues": issues, "adoption_status": "requires_architecture_quantization_tokenizer_and_engine_checks",
|
||||
"execution_compatibility": "unverified", "would_write": False,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
"""0.2.3 RC stress test #9 (C05, #3478): a missing shard is named, with its file name, in the CLI and in the TUI's own-files message."""
|
||||
|
||||
from strata_control import models
|
||||
from tests.terminal.test_own_files import Base, Q2
|
||||
|
||||
|
||||
class MissingShardIsNamed(Base):
|
||||
def test_the_plan_names_the_missing_second_shard(self):
|
||||
folder = self.put(self.base / "half", Q2[:1], ["Q2_0"])
|
||||
plan = models.plan_import(str(folder))
|
||||
self.assertEqual(plan["issues"], ["incomplete_or_invalid_shard_set"])
|
||||
self.assertEqual(len(plan["missing_shards"]), 1)
|
||||
name = plan["missing_shards"][0]
|
||||
self.assertRegex(name, r"-00002-of-0000[0-9]\.gguf$")
|
||||
self.assertEqual(models.problem_words(plan["issues"], missing=plan["missing_shards"]), f"{name} is missing")
|
||||
self.assertEqual(plan["plain_issues"], [f"{name} is missing"])
|
||||
|
||||
def test_without_a_name_the_old_sentence_stays(self):
|
||||
self.assertEqual(models.problem_words(["incomplete_or_invalid_shard_set"]), "some parts of the model are missing")
|
||||
|
||||
def test_several_missing_shards_are_counted(self):
|
||||
self.assertEqual(models.missing_words(["a-00002-of-00004.gguf", "a-00003-of-00004.gguf"]),
|
||||
"a-00002-of-00004.gguf and a-00003-of-00004.gguf are missing")
|
||||
self.assertEqual(models.missing_words(["a-2", "a-3", "a-4", "a-5"]), "a-2, a-3 and 2 more files are missing")
|
||||
|
||||
def test_launch_plan_message_carries_the_file_name(self):
|
||||
from tests.terminal.launch_support import run_cli
|
||||
folder = self.put(self.base / "half2", Q2[:1], ["Q2_0"])
|
||||
code, out, err = run_cli(["launch", "--plan", "--model-path", str(folder)])
|
||||
self.assertNotEqual(code, 0)
|
||||
self.assertRegex(err + out, r"-00002-of-0000[0-9]\.gguf is missing")
|
||||
Reference in new issue
Block a user