Fix model-picker: drop broken readiness_score sort → mac-gate + smallest-first - #2
Conversation
…ore sort A SotA red-team found the ComfyUI dropdown sorted by `readiness_score`, but that key is never emitted on catalog.json entries — so the sort silently collapsed to alphabetical and surfaced the LEAST-ready model (gemma-4-12b-mm-warshanks: F-grade, experimental, needs_review) as the DEFAULT pick in the VLM node. Replace it: hard-gate to models usable on this Mac (available artifact, not "not_published", not explicitly non-mac — "unknown" device_support is KEPT so under-curated/community entries aren't penalized), then sort smallest-first so the lightest usable model is the honest, capability-blind default. ComfyUI no longer reads readiness_score at all, resolving the phantom-key dependency (readers stop expecting a field the catalog doesn't emit per-entry). Live result: VLM default qwen3-vl-2b (2.3GB), depth depth-anything-3-small (54.5MB), detection yolox-s (36MB), segmentation efficientsam3-tinyvit (374MB). Adds offline unit tests locking the gate + ordering. ruff clean, 12/12 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed02e203cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| match = re.match(r"([\d.]+)\s*([KMGT]?B)\b", raw, re.IGNORECASE) | ||
| if not match: | ||
| return float("inf") | ||
| return float(match.group(1)) * _SIZE_UNITS.get(match.group(2).upper(), 1) |
There was a problem hiding this comment.
Guard malformed artifact sizes while parsing
If a catalog entry that passes _runs_on_this_mac has an artifact_size with a unit but an invalid numeric part, such as 1..2GB or .MB, the regex matches and float(match.group(1)) raises ValueError. Because this runs inside the model_dropdown() sort key, one bad external catalog value would prevent ComfyUI from building the dropdown instead of sorting that unparseable size last as the helper promises.
Useful? React with 👍 / 👎.
Problema (achado pelo red-team SotA do
readiness_score)model_dropdownordenava porreadiness_score, mas essa chave nunca é emitida nas entradas docatalog.json(o readiness vive emreadiness-scores.jsonsobscore). Resultado: o sort desabava para ordem alfabética e o default pré-selecionado do nó VLM eragemma-4-12b-mm-warshanks(score 48, grade F, experimental) — o 2º menos pronto de 82 modelos. Uma feature "melhor primeiro" entregava o pior.Fix
_runs_on_this_mac): mantém só modelos utilizáveis neste Mac — artefatoavailable, nãonot_published, e não explicitamente não-mac.device_support.mac == "unknown"é mantido de propósito (não penaliza entradas da comunidade/fabric, evitando o viés de curadoria que o red-team apontou)._artifact_size_bytesparseia"969MB"/"1.7 GB"): o menor modelo utilizável vira o default — honesto e cego a "qualidade" (que o catálogo não mede).readiness_score→ resolve a chave-fantasma pelo lado do leitor (a direção decidida no red-team).Resultado ao vivo
gemma-4-12b(F, 6.4GB)qwen3-vl-2b(2.3GB)depth-anything-3-small(54.5MB)yolox-s(36MB)efficientsam3-tinyvit(374MB)Testes unitários offline (CI-safe) travando gate + ordenação. ruff limpo · 12/12 testes.
🤖 Generated with Claude Code