Fix #4209: a saved preset's lower-case model tag reaches setup as its key

strata_cli/launch/settings.py saves the model into a preset/choices file lower-case ("--model iq3_xxs"),
and LaunchRunner.setup_args() forwarded it unchanged. setup.py's --model choices are the MODELS table's own
keys ("IQ3_XXS", "Gyro-S"), so argparse refused the argument: starting a saved preset with any choice that
differs from the installed config (--vision, --context, --kv) reran setup and stopped there. Typing the same
name on the command line worked, because cmd.py normalises it through Catalog.resolve().

setup_args() now resolves the pair through the same Catalog.resolve() and keeps the old value when it
cannot. The except is deliberately broad: the resolver reads the model table, and a table that cannot be
read here must not turn a launch that worked into a traceback - the values then go on to setup unchanged,
exactly as before. The new test drives that case with a resolver that raises.
This commit is contained in:
吴佳浩Alben authored and Niko1221 committed 2026-10-28 23:31:20 +01:00
1 parent 46c152a131
commit 2f9c6fc35c
2 files changed
+36

No files matched your search

+4
View File
@@ -880,6 +880,10 @@ class Runner:
def setup_args(self) -> list[str]:
cat, s = self.catalog, self.s
fam, model = s.family, s.model
try: # a saved preset or choices file keeps the lower-case tag ("iq3_xxs", #4209), while setup's
fam, model = cat.resolve(str(model), None if fam is None else str(fam)) # --model takes the table's own key
except Exception: # noqa: BLE001 a name the list does not hold, or a list that cannot be read here, is setup's
pass # to report: passing the values on unchanged keeps the launch behaving as it did before
args = ["--yes", "--no-start", "--family", str(fam), "--model", str(model)]
ctx = s.context
if ctx:
+32
View File
@@ -346,6 +346,38 @@ class SetupArgs(unittest.TestCase):
s = S.LaunchSettings(family="qwen", model="IQ3_XXS", context=32768, kv="q4_0", **kw)
return Runner(s, catalog=cat).setup_args()
def args_for(self, **kw):
values = dict(family="qwen", model="IQ3_XXS", context=32768, kv="q4_0", vision="off")
values.update(kw)
with Home():
return Runner(S.LaunchSettings(**values), catalog=catalog(HW_12)).setup_args()
def test_a_lower_case_tag_from_a_saved_preset_reaches_setup_as_its_key(self):
"""#4209: a preset keeps "model": "iq3_xxs", and setup's --model choices are the table's own keys
("IQ3_XXS"). Starting such a preset with any changed choice reruns setup, which then refused it."""
args = self.args_for(model="iq3_xxs")
self.assertEqual(args[args.index("--model") + 1], "IQ3_XXS")
self.assertEqual(args[args.index("--family") + 1], "qwen")
for fam, model, want in (("coder", "iq1_m", "IQ1_M"), ("gyro", "gyro-s", "Gyro-S"), ("qwen", "IQ3_S", "IQ3_S")):
args = self.args_for(family=fam, model=model)
self.assertEqual(args[args.index("--family") + 1], fam)
self.assertEqual(args[args.index("--model") + 1], want)
def test_an_unknown_model_is_still_setup_to_report(self):
args = self.args_for(model="not-a-model")
self.assertEqual(args[args.index("--model") + 1], "not-a-model")
def test_a_model_list_that_cannot_be_read_leaves_the_values_alone(self):
"""The resolver is an improvement, never a new way for the launch to fail: when it cannot answer, the
preset's own values go to setup as they did before #4209."""
with Home():
cat = catalog(HW_12)
r = Runner(S.LaunchSettings(family="qwen", model="iq3_xxs", context=32768, vision="off"), catalog=cat)
with mock.patch.object(cat, "resolve", side_effect=RuntimeError("the model list cannot be read")):
args = r.setup_args()
self.assertEqual(args[args.index("--model") + 1], "iq3_xxs")
self.assertEqual(args[args.index("--family") + 1], "qwen")
def test_pictures_default_on_the_cpu_reader_under_24_gb_and_the_gpu_reader_from_24_gb_on_every_make(self):
from tests.terminal.launch_support import HW_12 as NV
card = lambda name, gb, vendor: {**NV, "gpus": [{"index": 0, "name": name, "vram_gb": gb, "usable": True, "vendor": vendor}]} # noqa: E731