[PR #4888] [TUI] strata models explain: show why a model folder is or is not found under models/ #5239

Open
opened 2026-11-07 16:33:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4888
Author: @XiaoBinGan
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: feat/models-explain


📝 Commits (1)

  • f816be6 [TUI] strata models explain: show why a model folder is or is not found under models/

📊 Changes

6 files changed (+320 additions, -18 deletions)

View changed files

📝 docs/TERMINAL.md (+2 -1)
📝 docs/TERMINAL_LAUNCH.md (+7 -0)
📝 strata_cli/cli.py (+57 -1)
📝 strata_cli/launch/catalog.py (+64 -13)
📝 strata_control/discovery.py (+6 -3)
➕ tests/terminal/test_models_explain.py (+184 -0)

📄 Description

Problem and result

0.2.7 fixed #3996 by resolving a model's folder with a chain: setup's own spelling (models/IQ3_S), then the lower-case run-config tag (models/iq3_s), then a folder that differs only in letter case, and a fallback to setup's spelling. The fix is right, but when a model still shows as "not on this computer" there is no command that says what the launch looked for and why it did not find the folder — the person sees "about X GB to download" and has to guess folder names inside the data folder.

This adds strata models explain NAME, a read-only subcommand that shows the whole decision:

$ strata models explain iq3_s --data-dir C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc
qwen IQ3_S (folder tag: iq3_s)
Data folder: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc
  C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\IQ3_S  exists: yes  (setup's spelling)
  C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\iq3_s  exists: yes  (the run-config tag (lower case))
Chosen: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\IQ3_S (the exact (setup) spelling)
2 .gguf file(s), 1,250 bytes in total

Nothing found, so it names the folders that are there instead:

$ strata models explain Gyro-S --data-dir C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc
gyro Gyro-S (folder tag: gyro-gyro-s)
Data folder: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc
  C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-Gyro-S  exists: no  (setup's spelling)
  C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-gyro-s  exists: no  (the run-config tag (lower case))
Chosen: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-Gyro-S (fallback: nothing found, so setup's spelling (where a download would go))
0 .gguf file(s), 0 bytes in total
No model folder found. Closest folders under models/: IQ3_S, IQ3_XXS

--output json (and the --json alias, like the other models commands) returns the same report as data. This Windows checkout's NTFS is case-insensitive, so both candidate paths open the same folder there; on a case-sensitive disk the second one is exists: no (the tests make that disk):

{"schema_version": 1, "ok": true, "family": "qwen", "model": "IQ3_S", "tag": "iq3_s", "data_dir": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc", "models_dir": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models", "candidates": [{"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\IQ3_S", "spelling": "setup's spelling", "exists": true}, {"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\iq3_s", "spelling": "the run-config tag (lower case)", "exists": true}], "chosen": {"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\IQ3_S", "exists": true, "reason": "exact spelling"}, "found": true, "gguf": {"shard_count": 2, "bytes": 1250}, "nearby_folders": []}

The reason is one of exact spelling, lower-case tag, case-insensitive match or fallback; the parsed family/model/tag and the data folder are in the report as well. The name is resolved with the same Catalog.resolve() the launch uses, so IQ3_S, iq3_s, --family qwen and the family/model spelling used by the model table (qwen/IQ3_S) all work.

#3996 is the case-sensitive-disk report whose fix (in 0.2.7) added the folder chain; it is closed, so the scope for this diagnostic was posted in #4887. No default path changes: new subcommand only.

Approach

  • Catalog.model_folder() keeps its exact rules but now shares them with a module-level _pick_model_folder() (the same two candidate folders in the same order, the same case-insensitive match, the same fallback). The report and the launch walk the same rule, so they cannot drift; the five existing tests in tests/terminal/test_model_folder_case.py pass unchanged.
  • Catalog.explain_model(base, family, model) builds the report. It lists the data folder, counts *.gguf files and reads their sizes; nearby_folders is at most 8 names ranked by difflib similarity, names only.
  • strata_cli/cli.py adds the explain subcommand after move in the models group, with human lines and --output json/--json, --family and --data-dir (default: the resolved data folder). The default base comes from data_dir_choice(sync=False), so it does not sync the Terminal/app data-folder settings files; every existing caller keeps the old default (sync=True).
  • Docs: a line in docs/TERMINAL.md and a short paragraph in docs/TERMINAL_LAUNCH.md (the section that already explains where the launch looks for models).

Validation

Environment: Windows 10 19045 (AMD64), Python 3.11.16, source checkout at c62d5e3a plus this change.

Passed: python -m pytest tests/terminal/test_models_explain.py -q → 9 passed in 0.44s. The new tests (temp directories; Path.is_dir patched to answer from the names the folder really lists, the same technique the existing #3996 test uses) cover: setup's models/IQ3_S with two fake .gguf shards counted (1000 + 250 bytes, a notes.txt not counted); a lower-case models/iq3_s; a case-insensitive models/Iq3_S; the fallback with the closest folder names; the CLI JSON for iq3_s and qwen/IQ3_S; the human output; an unknown name refused with the closest models; and that the data folder and the other settings file are not written.

Passed: python -m pytest tests/terminal/test_models_explain.py tests/terminal/test_model_folder_case.py tests/terminal/test_tui2_023_plan.py -q → 23 passed in 1.16s.

Passed: python -m pytest tests/terminal/test_tui2_023_plan.py -q → 9 passed in 0.82s, and python -m pytest tests/terminal/test_model_folder_case.py -q → 5 passed in 0.15s, both the same as a pristine origin/main worktree.

Passed: A/B on the two behaviours the change depends on. With the case-insensitive match removed, the new "differs only in letter case" test and the existing test_model_folder_case.py case both fail. With data_dir_choice() called without sync=False (the previous behaviour), the read-only settings test fails because the older settings file is rewritten with the newer folder.

Failed: the wider launch/model subset has pre-existing failures on this Windows checkout, identical on a pristine origin/main worktree: python -m pytest tests/terminal/test_launch.py tests/terminal/test_shared_models_folder.py tests/terminal/test_models.py tests/terminal/test_model_folder_case.py tests/terminal/test_models_explain.py tests/terminal/test_tui2_023_plan.py -q → this change: 62 failed, 144 passed, 1 skipped; pristine origin/main without the new test file: 62 failed, 135 passed, 1 skipped (the 9 extra passes are the new tests). The 62 failing test names are identical in both runs (compared with Compare-Object; no output).

Not run: the full tests/terminal suite. Collection stops on optional packages this environment does not have (rich, ...): 11 errors on a pristine origin/main worktree as well. The curated subset above is what was run.

Not run: a real multi-GB downloaded model on a real btrfs (case-sensitive) disk. The case-sensitive cases are covered by the Path.is_dir patch, not by a case-sensitive filesystem.

Limits

  • The report is the not-installed lookup. If the model already has a run config, the launch uses the folder that config names (data_dir_for); explain does not read installed configs.
  • Every *.gguf in the chosen folder is counted. The download plan (modelstate.assess) also skips names starting with mmproj; a folder that holds only an mmproj file would show as shards here and as 0 GB in the plan.
  • nearby_folders is a similarity hint (at most 8 names), not a match; it reads only directory names.
  • Constructing the catalog is the same construction the launch does, and it ensures the install folder exists (mkdir exist_ok). The command writes no settings, run configs or model files; with --data-dir it creates no folder either.
  • The output format is new, so nothing depends on it yet. The reason values and the JSON keys are the contract; a later change to them would be a compatibility change to state in a PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4888 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/models-explain` --- ### 📝 Commits (1) - [`f816be6`](https://github.com/Niko1221/Strata/commit/f816be6ffaeaf3d584c92799f3e2d09a03f2bf52) [TUI] strata models explain: show why a model folder is or is not found under models/ ### 📊 Changes **6 files changed** (+320 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/TERMINAL.md` (+2 -1) 📝 `docs/TERMINAL_LAUNCH.md` (+7 -0) 📝 `strata_cli/cli.py` (+57 -1) 📝 `strata_cli/launch/catalog.py` (+64 -13) 📝 `strata_control/discovery.py` (+6 -3) ➕ `tests/terminal/test_models_explain.py` (+184 -0) </details> ### 📄 Description ## Problem and result 0.2.7 fixed #3996 by resolving a model's folder with a chain: setup's own spelling (`models/IQ3_S`), then the lower-case run-config tag (`models/iq3_s`), then a folder that differs only in letter case, and a fallback to setup's spelling. The fix is right, but when a model still shows as "not on this computer" there is no command that says what the launch looked for and why it did not find the folder — the person sees "about X GB to download" and has to guess folder names inside the data folder. This adds `strata models explain NAME`, a read-only subcommand that shows the whole decision: ```text $ strata models explain iq3_s --data-dir C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc qwen IQ3_S (folder tag: iq3_s) Data folder: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\IQ3_S exists: yes (setup's spelling) C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\iq3_s exists: yes (the run-config tag (lower case)) Chosen: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\IQ3_S (the exact (setup) spelling) 2 .gguf file(s), 1,250 bytes in total ``` Nothing found, so it names the folders that are there instead: ```text $ strata models explain Gyro-S --data-dir C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc gyro Gyro-S (folder tag: gyro-gyro-s) Data folder: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-Gyro-S exists: no (setup's spelling) C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-gyro-s exists: no (the run-config tag (lower case)) Chosen: C:\Users\HP\AppData\Local\Temp\strata-explain-demo2-c77edfdc\models\gyro-Gyro-S (fallback: nothing found, so setup's spelling (where a download would go)) 0 .gguf file(s), 0 bytes in total No model folder found. Closest folders under models/: IQ3_S, IQ3_XXS ``` `--output json` (and the `--json` alias, like the other `models` commands) returns the same report as data. This Windows checkout's NTFS is case-insensitive, so both candidate paths open the same folder there; on a case-sensitive disk the second one is `exists: no` (the tests make that disk): ```json {"schema_version": 1, "ok": true, "family": "qwen", "model": "IQ3_S", "tag": "iq3_s", "data_dir": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc", "models_dir": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models", "candidates": [{"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\IQ3_S", "spelling": "setup's spelling", "exists": true}, {"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\iq3_s", "spelling": "the run-config tag (lower case)", "exists": true}], "chosen": {"path": "C:\\Users\\HP\\AppData\\Local\\Temp\\strata-explain-demo2-c77edfdc\\models\\IQ3_S", "exists": true, "reason": "exact spelling"}, "found": true, "gguf": {"shard_count": 2, "bytes": 1250}, "nearby_folders": []} ``` The reason is one of `exact spelling`, `lower-case tag`, `case-insensitive match` or `fallback`; the parsed family/model/tag and the data folder are in the report as well. The name is resolved with the same `Catalog.resolve()` the launch uses, so `IQ3_S`, `iq3_s`, `--family qwen` and the `family/model` spelling used by the model table (`qwen/IQ3_S`) all work. ## Related discussion #3996 is the case-sensitive-disk report whose fix (in 0.2.7) added the folder chain; it is closed, so the scope for this diagnostic was posted in #4887. No default path changes: new subcommand only. ## Approach - `Catalog.model_folder()` keeps its exact rules but now shares them with a module-level `_pick_model_folder()` (the same two candidate folders in the same order, the same case-insensitive match, the same fallback). The report and the launch walk the same rule, so they cannot drift; the five existing tests in `tests/terminal/test_model_folder_case.py` pass unchanged. - `Catalog.explain_model(base, family, model)` builds the report. It lists the data folder, counts `*.gguf` files and reads their sizes; `nearby_folders` is at most 8 names ranked by `difflib` similarity, names only. - `strata_cli/cli.py` adds the `explain` subcommand after `move` in the `models` group, with human lines and `--output json`/`--json`, `--family` and `--data-dir` (default: the resolved data folder). The default base comes from `data_dir_choice(sync=False)`, so it does not sync the Terminal/app data-folder settings files; every existing caller keeps the old default (`sync=True`). - Docs: a line in `docs/TERMINAL.md` and a short paragraph in `docs/TERMINAL_LAUNCH.md` (the section that already explains where the launch looks for models). ## Validation Environment: Windows 10 19045 (AMD64), Python 3.11.16, source checkout at `c62d5e3a` plus this change. **Passed:** `python -m pytest tests/terminal/test_models_explain.py -q` → `9 passed in 0.44s`. The new tests (temp directories; `Path.is_dir` patched to answer from the names the folder really lists, the same technique the existing #3996 test uses) cover: setup's `models/IQ3_S` with two fake `.gguf` shards counted (1000 + 250 bytes, a `notes.txt` not counted); a lower-case `models/iq3_s`; a case-insensitive `models/Iq3_S`; the fallback with the closest folder names; the CLI JSON for `iq3_s` and `qwen/IQ3_S`; the human output; an unknown name refused with the closest models; and that the data folder and the other settings file are not written. **Passed:** `python -m pytest tests/terminal/test_models_explain.py tests/terminal/test_model_folder_case.py tests/terminal/test_tui2_023_plan.py -q` → `23 passed in 1.16s`. **Passed:** `python -m pytest tests/terminal/test_tui2_023_plan.py -q` → `9 passed in 0.82s`, and `python -m pytest tests/terminal/test_model_folder_case.py -q` → `5 passed in 0.15s`, both the same as a pristine `origin/main` worktree. **Passed:** A/B on the two behaviours the change depends on. With the case-insensitive match removed, the new "differs only in letter case" test and the existing `test_model_folder_case.py` case both fail. With `data_dir_choice()` called without `sync=False` (the previous behaviour), the read-only settings test fails because the older settings file is rewritten with the newer folder. **Failed:** the wider launch/model subset has pre-existing failures on this Windows checkout, identical on a pristine `origin/main` worktree: `python -m pytest tests/terminal/test_launch.py tests/terminal/test_shared_models_folder.py tests/terminal/test_models.py tests/terminal/test_model_folder_case.py tests/terminal/test_models_explain.py tests/terminal/test_tui2_023_plan.py -q` → this change: `62 failed, 144 passed, 1 skipped`; pristine `origin/main` without the new test file: `62 failed, 135 passed, 1 skipped` (the 9 extra passes are the new tests). The 62 failing test names are identical in both runs (compared with `Compare-Object`; no output). **Not run:** the full `tests/terminal` suite. Collection stops on optional packages this environment does not have (`rich`, ...): 11 errors on a pristine `origin/main` worktree as well. The curated subset above is what was run. **Not run:** a real multi-GB downloaded model on a real btrfs (case-sensitive) disk. The case-sensitive cases are covered by the `Path.is_dir` patch, not by a case-sensitive filesystem. ## Limits - The report is the not-installed lookup. If the model already has a run config, the launch uses the folder that config names (`data_dir_for`); `explain` does not read installed configs. - Every `*.gguf` in the chosen folder is counted. The download plan (`modelstate.assess`) also skips names starting with `mmproj`; a folder that holds only an `mmproj` file would show as shards here and as 0 GB in the plan. - `nearby_folders` is a similarity hint (at most 8 names), not a match; it reads only directory names. - Constructing the catalog is the same construction the launch does, and it ensures the install folder exists (`mkdir exist_ok`). The command writes no settings, run configs or model files; with `--data-dir` it creates no folder either. - The output format is new, so nothing depends on it yet. The `reason` values and the JSON keys are the contract; a later change to them would be a compatibility change to state in a PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5239
No description provided.