Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: do not offer a local model that is short a shard (#8985)
sts-change88cfd0681e68
diff --git a/studio/backend/hub/services/models/local_inventory.py b/studio/backend/hub/services/models/local_inventory.pyindex 2b90522bb36..7ffa8c09eed 100644--- a/studio/backend/hub/services/models/local_inventory.py+++ b/studio/backend/hub/services/models/local_inventory.py@@ -8,7 +8,10 @@ from __future__ import annotationsimport asyncioimport os+import reimport stat+import threading+from collections import OrderedDictfrom pathlib import Pathfrom typing import List, NamedTuple, Optional@@ -224,6 +227,101 @@ def nested_scan_roots(folder_path: Path) -> list[Path]:return roots+_SHARD_EVIDENCE_RE = re.compile(r"-\d+-of-\d+\.|\.index\.json$", re.IGNORECASE)+_PAYLOAD_SUFFIXES = (".safetensors", ".gguf", *model_common._LOCAL_CHECKPOINT_EXTENSIONS)+_PAYLOAD_VERDICT_CACHE_MAX = 4096+_payload_verdicts: "OrderedDict[str, tuple[tuple, bool]]" = OrderedDict()+_payload_verdicts_lock = threading.Lock()+++def _payload_evidence(scan_path: Path) -> tuple[bool, bool, tuple]:+ """Whether weights / quants could be torn (numbered shard, index, empty weight), plus a fingerprint of every file."""+ weights = quants = False+ fingerprint = []+ for dirpath, _dirnames, filenames in os.walk(scan_path):+ for name in filenames:+ path = os.path.join(dirpath, name)+ try:+ st = os.stat(path)+ entry = (path, st.st_size, st.st_mtime_ns, st.st_ino)+ empty = st.st_size <= 0+ except OSError:+ entry = (path, -1, -1, -1)+ empty = True+ fingerprint.append(entry)+ lower = name.lower()+ torn = _SHARD_EVIDENCE_RE.search(name) is not None or (+ empty and lower.endswith(_PAYLOAD_SUFFIXES)+ )+ if torn:+ if lower.endswith(".gguf"):+ quants = True+ else:+ weights = True+ return weights, quants, tuple(sorted(fingerprint))+++def _weights_complete(scan_path: Path, fingerprint: tuple) -> bool:+ # Files are the judge's only input. Quants are not cached: their judge also reads the account's scan folders.+ key = os.path.abspath(scan_path)+ with _payload_verdicts_lock:+ hit = _payload_verdicts.get(key)+ if hit is not None and hit[0] == fingerprint:+ _payload_verdicts.move_to_end(key)+ return hit[1]+ complete = hf_cache_scan.snapshot_holds_a_complete_payload(scan_path, quants = False)+ with _payload_verdicts_lock:+ _payload_verdicts[key] = (fingerprint, complete)+ _payload_verdicts.move_to_end(key)+ while len(_payload_verdicts) > _PAYLOAD_VERDICT_CACHE_MAX:+ _payload_verdicts.popitem(last = False)+ return complete+++def _apply_payload_partial(scan_path: Path, rows: List[LocalModelInfo]) -> List[LocalModelInfo]:+ """Local folders carry no downloader markers, so only the payload shows a torn download. ``unknown`` is skipped: a diffusers pipeline's weights live in component subdirs."""+ if not rows:+ return rows+ if scan_path.is_file():+ # A loose quant, split or not: llama-server opens every part, so a missing or empty one fails the load.+ from utils.models.model_config import colocated_split_shards++ candidates = [scan_path]+ try:+ if scan_path.is_symlink():+ # Same fallback as _local_gguf_load_path: a lone link loads from its target's set.+ candidates.append(scan_path.resolve())+ except OSError:+ pass+ for candidate in candidates:+ shards, complete = colocated_split_shards(candidate)+ try:+ if complete and all(shard.stat().st_size > 0 for shard in shards):+ return rows+ except OSError:+ continue+ return _apply_format_aware_partial(rows, snapshot_partial = False, gguf_partial = True)+ if not scan_path.is_dir():+ return rows+ judged = {row.model_format for row in rows} - {"unknown"}+ if not judged:+ return rows+ weights, quants, fingerprint = _payload_evidence(scan_path)+ snapshot_partial = (+ weights and bool(judged - {"gguf"}) and not _weights_complete(scan_path, fingerprint)+ )+ gguf_partial = (+ quants+ and "gguf" in judged+ and not hf_cache_scan.snapshot_holds_a_complete_payload(scan_path, quants = True)+ )+ if not snapshot_partial and not gguf_partial:+ return rows+ return _apply_format_aware_partial(+ rows, snapshot_partial = snapshot_partial, gguf_partial = gguf_partial+ )++def _resolve_hf_cache_dir() -> Path:from utils.hf_cache_settings import get_hf_cache_pathsreturn get_hf_cache_paths().hub_cache@@ -261,11 +359,12 @@ def _scan_models_dir(updated_at = models_dir.stat().st_mtimeexcept OSError:updated_at = None- return _classify_local_path(+ rows = _classify_local_path(models_dir,"models_dir",updated_at = updated_at,)+ return _apply_payload_partial(models_dir, rows)found: List[LocalModelInfo] = []visited = 0@@ -303,6 +402,7 @@ def _scan_models_dir("models_dir",updated_at = updated_at,)+ rows = _apply_payload_partial(child, rows)if limit is not None:rows = rows[: max(0, limit - len(found))]found.extend(rows)@@ -571,11 +671,12 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = lm_dir.stat().st_mtimeexcept OSError:updated_at = None- return _classify_local_path(+ rows = _classify_local_path(lm_dir,"lmstudio",updated_at = updated_at,)+ return _apply_payload_partial(lm_dir, rows)found: List[LocalModelInfo] = []visited = 0@@ -604,13 +705,12 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = child.stat().st_mtimeexcept OSError:updated_at = None- found.extend(- _classify_local_path(- child,- "lmstudio",- updated_at = updated_at,- )+ rows = _classify_local_path(+ child,+ "lmstudio",+ updated_at = updated_at,)+ found.extend(_apply_payload_partial(child, rows))continue# A child that is itself a model dir is surfaced directly, not as a publisher; a diffusers pipeline counts, or its component subdirs are walked as models.@@ -619,13 +719,12 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = child.stat().st_mtimeexcept OSError:updated_at = None- found.extend(- _classify_local_path(- child,- "lmstudio",- updated_at = updated_at,- )+ rows = _classify_local_path(+ child,+ "lmstudio",+ updated_at = updated_at,)+ found.extend(_apply_payload_partial(child, rows))continue# child is a publisher directory -- scan its sub-directories@@ -643,15 +742,14 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = model_dir.stat().st_mtimeexcept OSError:updated_at = None- found.extend(- _classify_local_path(- model_dir,- "lmstudio",- display_name = model_dir.name,- model_id = model_id,- updated_at = updated_at,- )+ rows = _classify_local_path(+ model_dir,+ "lmstudio",+ display_name = model_dir.name,+ model_id = model_id,+ updated_at = updated_at,)+ found.extend(_apply_payload_partial(model_dir, rows))elif (model_dir.suffix.lower() == ".gguf"and model_dir.is_file()@@ -661,14 +759,13 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = model_dir.stat().st_mtimeexcept OSError:updated_at = None- found.extend(- _classify_local_path(- model_dir,- "lmstudio",- model_id = f"{child.name}/{model_dir.stem}",- updated_at = updated_at,- )+ rows = _classify_local_path(+ model_dir,+ "lmstudio",+ model_id = f"{child.name}/{model_dir.stem}",+ updated_at = updated_at,)+ found.extend(_apply_payload_partial(model_dir, rows))except OSError:continueif exhausted:diff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.pyindex bde050d027b..a2e608934ec 100644--- a/studio/backend/hub/tests/test_model_services.py+++ b/studio/backend/hub/tests/test_model_services.py@@ -7915,6 +7915,261 @@ def test_local_inventory_retries_when_the_cache_changes_during_classification(moassert [row.id for row in listed.models] == ["scan2"]+def _write_sharded_safetensors(model_dir: Path, *, total: int, present: int) -> Path:+ model_dir.mkdir(parents = True, exist_ok = True)+ (model_dir / "config.json").write_text('{"model_type": "qwen3"}', encoding = "utf-8")+ names = [f"model-{i + 1:05d}-of-{total:05d}.safetensors" for i in range(total)]+ (model_dir / "model.safetensors.index.json").write_text(+ json.dumps({"weight_map": {f"layer.{i}": n for i, n in enumerate(names)}}),+ encoding = "utf-8",+ )+ for name in names[:present]:+ (model_dir / name).write_bytes(b"weights")+ return model_dir+++def _write_split_gguf(model_dir: Path, *, total: int, present: int) -> Path:+ model_dir.mkdir(parents = True, exist_ok = True)+ for i in range(present):+ (model_dir / f"Muse-Q4_K_M-{i + 1:05d}-of-{total:05d}.gguf").write_bytes(b"quant")+ return model_dir+++_LOCAL_SCANNERS = pytest.mark.parametrize(+ "scan",+ [local_inventory._scan_lmstudio_dir, local_inventory._scan_models_dir],+ ids = ["lmstudio", "models_dir"],+)+++@_LOCAL_SCANNERS+def test_a_local_dir_missing_shards_is_reported_partial(tmp_path, scan):+ # Local folders carry no downloader markers, so only the payload can show a torn download.+ _write_sharded_safetensors(tmp_path / "Muse-Glimmer-30B-4bit", total = 4, present = 1)++ rows = scan(tmp_path)++ assert [r.model_format for r in rows] == ["safetensors"]+ assert rows[0].partial is True+ assert rows[0].capabilities.can_chat is False, "a model short a shard cannot be loaded"+++@_LOCAL_SCANNERS+def test_a_complete_local_dir_stays_whole(tmp_path, scan):+ _write_sharded_safetensors(tmp_path / "Complete-4bit", total = 4, present = 4)++ rows = scan(tmp_path)++ assert rows[0].partial is False+ assert rows[0].capabilities.can_chat is True+++@_LOCAL_SCANNERS+def test_an_unsharded_local_dir_stays_whole(tmp_path, scan):+ model_dir = tmp_path / "Single"+ model_dir.mkdir()+ (model_dir / "config.json").write_text('{"model_type": "qwen3"}', encoding = "utf-8")+ (model_dir / "model.safetensors").write_bytes(b"weights")++ rows = scan(tmp_path)++ assert rows[0].partial is False+++@_LOCAL_SCANNERS+def test_a_whole_folder_with_no_shard_evidence_is_not_judged(tmp_path, scan):+ # consolidated.safetensors is never opened by from_pretrained; the full judge would call this folder torn.+ model_dir = tmp_path / "Mistral-Native"+ model_dir.mkdir()+ (model_dir / "config.json").write_text('{"model_type": "mistral"}', encoding = "utf-8")+ (model_dir / "params.json").write_text("{}", encoding = "utf-8")+ (model_dir / "consolidated.safetensors").write_bytes(b"weights")++ rows = scan(tmp_path)++ assert [r.partial for r in rows] == [False]+++def test_a_cached_verdict_follows_the_files(tmp_path):+ # The verdict is reused across rescans, so each change to the payload must still reach it.+ model_dir = _write_sharded_safetensors(tmp_path / "Arriving", total = 2, present = 1)+ scan = lambda: [r.partial for r in local_inventory._scan_models_dir(tmp_path)]+ assert scan() == [True]+ assert scan() == [True]+ (model_dir / "model-00002-of-00002.safetensors").write_bytes(b"weights")+ assert scan() == [False]+ assert scan() == [False]+ (model_dir / "model-00001-of-00002.safetensors").unlink()+ assert scan() == [True]+ (model_dir / "model-00001-of-00002.safetensors").write_bytes(b"")+ assert scan() == [True]+ (model_dir / "model-00001-of-00002.safetensors").write_bytes(b"weights")+ assert scan() == [False]++[email protected]("parts", [1, 3], ids = ["torn", "whole"])[email protected]("under_publisher", [False, True], ids = ["loose", "publisher"])+def test_a_loose_split_gguf_is_judged_on_its_siblings(tmp_path, parts, under_publisher):+ folder = tmp_path / "pub" if under_publisher else tmp_path+ folder.mkdir(exist_ok = True)+ for i in range(parts):+ (folder / f"Muse-Q4_K_M-{i + 1:05d}-of-00003.gguf").write_bytes(b"quant")++ for scan in (local_inventory._scan_models_dir, local_inventory._scan_lmstudio_dir):+ if under_publisher and scan is local_inventory._scan_models_dir:+ continue+ rows = scan(tmp_path)+ assert rows and all(r.partial is (parts < 3) for r in rows)+++ "names",+ [["Muse-Q4_K_M.gguf"], ["Muse-Q4-00001-of-00002.gguf", "Muse-Q4-00002-of-00002.gguf"]],+ ids = ["single", "split"],+)+def test_an_empty_loose_gguf_is_partial(tmp_path, names):+ for name in names:+ (tmp_path / name).write_bytes(b"quant")+ (tmp_path / names[-1]).write_bytes(b"")++ for scan in (local_inventory._scan_models_dir, local_inventory._scan_lmstudio_dir):+ rows = scan(tmp_path)+ assert rows and all(r.partial for r in rows if r.model_format == "gguf")++[email protected]("target_parts", [2, 1], ids = ["whole-target", "torn-target"])+def test_a_symlinked_split_gguf_is_judged_on_its_target_set(tmp_path, target_parts):+ store = tmp_path / "store"+ store.mkdir()+ for i in range(target_parts):+ (store / f"Muse-Q4-{i + 1:05d}-of-00002.gguf").write_bytes(b"quant")+ models = tmp_path / "models"+ models.mkdir()+ try:+ (models / "Muse-Q4-00001-of-00002.gguf").symlink_to(store / "Muse-Q4-00001-of-00002.gguf")+ except (OSError, NotImplementedError):+ pytest.skip("symlinks unavailable")++ rows = local_inventory._scan_models_dir(models)++ assert [r.partial for r in rows] == [target_parts < 2]++[email protected]("suffix", [".ckpt", ".h5", ".msgpack", ".npz"])+def test_an_empty_checkpoint_of_any_recognised_suffix_is_partial(tmp_path, suffix):+ model_dir = tmp_path / "Legacy"+ model_dir.mkdir()+ (model_dir / "config.json").write_text('{"model_type": "qwen3"}', encoding = "utf-8")+ (model_dir / f"model{suffix}").write_bytes(b"")++ rows = local_inventory._scan_models_dir(tmp_path)++ assert [r.partial for r in rows] == [True]+++def test_a_models_dir_pointed_straight_at_a_short_model_is_partial(tmp_path):+ model_dir = _write_sharded_safetensors(tmp_path / "Short", total = 4, present = 1)++ rows = local_inventory._scan_models_dir(model_dir)++ assert rows[0].partial is True++[email protected]("weights", [b"", b"weights"], ids = ["torn", "whole"])+def test_an_adapter_is_judged_on_its_own_payload(tmp_path, weights):+ adapter = tmp_path / "Lora"+ adapter.mkdir()+ (adapter / "adapter_config.json").write_text(+ '{"peft_type": "LORA", "base_model_name_or_path": "org/base"}', encoding = "utf-8"+ )+ (adapter / "adapter_model.safetensors").write_bytes(weights)++ rows = local_inventory._scan_models_dir(tmp_path)++ assert [r.model_format for r in rows] == ["adapter"]+ assert rows[0].partial is (weights == b"")++[email protected]("present", [1, 2], ids = ["torn", "whole"])+def test_a_checkpoint_family_is_judged_on_its_own_payload(tmp_path, present):+ model_dir = tmp_path / "Legacy"+ model_dir.mkdir()+ (model_dir / "config.json").write_text('{"model_type": "qwen3"}', encoding = "utf-8")+ names = [f"pytorch_model-{i + 1:05d}-of-00002.bin" for i in range(2)]+ (model_dir / "pytorch_model.bin.index.json").write_text(+ json.dumps({"weight_map": {f"layer.{i}": n for i, n in enumerate(names)}}),+ encoding = "utf-8",+ )+ for name in names[:present]:+ (model_dir / name).write_bytes(b"weights")++ rows = local_inventory._scan_models_dir(tmp_path)++ assert [r.model_format for r in rows] == ["checkpoint"]+ assert rows[0].partial is (present < 2)+++def test_a_locally_judged_row_claims_no_resumable_transport(tmp_path):+ _write_sharded_safetensors(tmp_path / "Short", total = 4, present = 1)++ rows = local_inventory._scan_models_dir(tmp_path)++ assert rows[0].partial is True+ assert rows[0].partial_transport is None+++def test_a_complete_diffusers_pipeline_is_not_called_short_a_shard(tmp_path):+ # Every weight lives in a component subdir, so a root-level judge would call it torn.+ pipeline = tmp_path / "FluxLike"+ (pipeline / "transformer").mkdir(parents = True)+ (pipeline / "model_index.json").write_text('{"_class_name": "FluxPipeline"}', encoding = "utf-8")+ (pipeline / "transformer" / "config.json").write_text("{}", encoding = "utf-8")+ (pipeline / "transformer" / "diffusion_pytorch_model.safetensors").write_bytes(b"weights")++ rows = local_inventory._scan_lmstudio_dir(tmp_path)++ assert [r.model_format for r in rows] == ["unknown"]+ assert rows[0].partial is False+++def test_a_local_dir_missing_gguf_parts_is_reported_partial(tmp_path):+ _write_split_gguf(tmp_path / "publisher" / "Muse-GGUF", total = 3, present = 1)++ rows = local_inventory._scan_lmstudio_dir(tmp_path)++ assert [r.model_format for r in rows] == ["gguf"]+ assert rows[0].partial is True+ assert rows[0].capabilities.can_chat is False+++def test_a_complete_split_gguf_dir_stays_whole(tmp_path):+ _write_split_gguf(tmp_path / "publisher" / "Muse-GGUF", total = 3, present = 3)++ rows = local_inventory._scan_lmstudio_dir(tmp_path)++ assert rows[0].partial is False+ assert rows[0].capabilities.can_chat is True+++ ("shards_present", "quant_parts_present", "expected"),+ [+ (4, 1, {"safetensors": False, "gguf": True}),+ (1, 3, {"safetensors": True, "gguf": False}),+ ],+ ids = ["torn-quant-whole-weights", "whole-quant-torn-weights"],+)+def test_a_hybrid_dir_reports_each_row_on_its_own_evidence(+ tmp_path, shards_present, quant_parts_present, expected+):+ model_dir = _write_sharded_safetensors(tmp_path / "Hybrid", total = 4, present = shards_present)+ _write_split_gguf(model_dir, total = 3, present = quant_parts_present)++ rows = local_inventory._scan_lmstudio_dir(tmp_path)++ assert {r.model_format: r.partial for r in rows} == expected++def _gguf_with_architecture(path: Path, architecture: str) -> None:"""A minimal valid GGUF carrying just ``general.architecture``."""import structdiff --git a/studio/backend/hub/utils/inventory_scan.py b/studio/backend/hub/utils/inventory_scan.pyindex 82a0abc9a96..a5940be0a4e 100644--- a/studio/backend/hub/utils/inventory_scan.py+++ b/studio/backend/hub/utils/inventory_scan.py@@ -1025,6 +1025,13 @@ def _snapshot_payload(snapshot_dir: Path) -> Optional[_SnapshotPayload]:# Selected by its own name, so it counts even when the walk grouped no shard of it, and every weight_map entry resolves against the index.root_indexes: set[str] = set()unusable_root_indexes: set[str] = set()+ parsed: dict[Path, object] = {}++ def index_shards(index_path: Path):+ if index_path not in parsed:+ parsed[index_path] = _read_index_shards(index_path)+ return parsed[index_path]+for suffix, canonical in _LOADER_WEIGHT_NAMES["base"].items():index_path = snapshot_dir / f"{canonical}.index.json"try:@@ -1033,7 +1040,7 @@ def _snapshot_payload(snapshot_dir: Path) -> Optional[_SnapshotPayload]:except OSError:continueroot_indexes.add(suffix)- if _index_cannot_serve_its_shards(index_path, set()):+ if _index_cannot_serve_its_shards(index_path, set(), index_shards(index_path)):unusable_root_indexes.add(suffix)for family in groups["base"]:# Only the canonical index is probed, so a set behind any other name is one it never opens.@@ -1046,7 +1053,9 @@ def _snapshot_payload(snapshot_dir: Path) -> Optional[_SnapshotPayload]:present = Falseif not present:invisible.add(family)- elif _index_cannot_serve_its_shards(index_path, shard_names.get(family, set())):+ elif _index_cannot_serve_its_shards(+ index_path, shard_names.get(family, set()), index_shards(index_path)+ ):unloadable.add(family)# peft resolves only the singular adapter_model.*, so it never looks at a numbered adapter set.invisible |= set(groups["adapter"])@@ -1067,42 +1076,57 @@ def _snapshot_payload(snapshot_dir: Path) -> Optional[_SnapshotPayload]:)-def _index_cannot_serve_its_shards(index_path: Path, family_files: set[str]) -> bool:+def _index_cannot_serve_its_shards(+ index_path: Path,+ family_files: set[str],+ shards: object = None,+) -> bool:"""Whether *index_path* would fail to hand ``from_pretrained`` the family in *family_files*. Existing is not enough: the loader parses it and opens every ``weight_map`` name, so a truncated index or one naming a shard never written is as unloadable as no index at all, and the map is also the only list of files read, so one covering part of the numbered family silently drops the rest."""+ if shards is None:+ shards = _read_index_shards(index_path)+ if shards is False:+ return True+ named = {shard.name for shard in shards}+ # Coverage matters only for the family this index describes: the loader opens weight_map and nothing else.+ return not family_files <= named and not named.isdisjoint(family_files)+++def _read_index_shards(index_path: Path):+ """The shards *index_path* names if each is a non-empty file and every numbered set is whole, else False."""try:if not index_path.is_file() or index_path.stat().st_size <= 0:- return True+ return Falsewith index_path.open(encoding = "utf-8") as handle:index = json.load(handle)except (OSError, UnicodeDecodeError, ValueError, RecursionError):# RecursionError escapes every caller's fail-open guard, and the loader parses this index with the same json module, so one too deep to parse there cannot serve its shards here either.- return True+ return Falseweight_map = index.get("weight_map") if isinstance(index, dict) else Noneif not isinstance(weight_map, dict) or not weight_map:- return True+ return False+ # Per unique shard, not per tensor: a MoE index maps tens of thousands of tensors onto a few dozen files.+ try:+ names = set(weight_map.values())+ except TypeError:+ return Falseshards: set[PurePosixPath] = set()- for shard in weight_map.values():- # Names are relative to the index: anything reaching outside is not a shard of this family.+ for shard in names:if not isinstance(shard, str) or not shard:- return True+ return False+ # Names are relative to the index: anything reaching outside is not a shard of this family.parts = PurePosixPath(shard.replace("\\", "/"))# is_absolute() is per flavour: PurePosixPath reads "C:/weights/x.safetensors" as a relative "C:" subdirectory, but the join below is a platform Path, so on Windows that name replaces the index directory outright.windows = PureWindowsPath(shard)if parts.is_absolute() or ".." in parts.parts or windows.is_absolute() or windows.drive:- return True+ return Falseshards.add(parts)- named = {shard.name for shard in shards}- # Coverage matters only for the family this index describes: the loader opens weight_map and nothing else.- if not family_files <= named and not named.isdisjoint(family_files):- return Truefor shard in shards:try:- named = index_path.parent / shard- shard_stat = named.stat()+ shard_stat = (index_path.parent / shard).stat()if not stat.S_ISREG(shard_stat.st_mode) or shard_stat.st_size <= 0:- return True+ return Falseexcept (OSError, ValueError):- return True+ return False# A shard names its own total, so an index listing one of a set has to list the whole set: the loader silently drops whatever the map leaves out.declared: dict[tuple[str, str, int], set[int]] = {}for shard in shards:@@ -1111,7 +1135,9 @@ def _index_cannot_serve_its_shards(index_path: Path, family_files: set[str]) ->continuekey = (str(shard.parent), shard.name[: match.start()], int(match.group(2)))declared.setdefault(key, set()).add(int(match.group(1)))- return any(total <= 0 or len(seen) < total for (_d, _p, total), seen in declared.items())+ if any(total <= 0 or len(seen) < total for (_d, _p, total), seen in declared.items()):+ return False+ return shardsdef _snapshot_lacks_a_complete_weight_family(snapshot_dir: Path) -> bool: