mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
strata_cli: the Advanced table does not call an environment setting a typing mistake (#5136)
build_rows gave every name without a Param the description "(not in this engine's list: newer flag or a typing mistake)" and known=False (drawn in the error colour), and an environment name without a value the default "off". The rows come from --help, the tuner's arms and the speed switches, so environment settings the engine reads, including ones setup writes (STRATA_ROUTE_TAIL_SKIP, STRATA_NO_ARENA_THP), were shown as typos with a default the table does not know. check_name already checks only flags. An environment name with no row now gets a neutral description, known True, and its run-config value as the default, or none (shown as "-"). A flag that --help does not list is still flagged. Rows with a Param are unchanged. Test: tests/terminal/test_launch.py Advanced.test_an_environment_setting_without_a_row_is_not_a_typing_mistake (fails without the change, passes with it).
This commit is contained in:
1 parent
146df3c468
commit
b5176a3ca9
2 files changed
+26
-3
No files matched your search
@@ -186,16 +186,24 @@ def build_rows(engine_help: str | None, base_args: list[Any], tuned_args: list[A
|
||||
d = (base_env or {}).get(name) if is_env else base.get(name)
|
||||
t = (tuned_env or {}).get(name) if is_env else tuned.get(name)
|
||||
if d is None:
|
||||
d = (p.help_default if p and p.help_default else ("off" if is_env else ""))
|
||||
d = (p.help_default if p and p.help_default else ("off" if is_env and p else ""))
|
||||
if is_env:
|
||||
t = t if t is not None else d
|
||||
else:
|
||||
t = t if t is not None else ""
|
||||
shown = lambda v: "on" if v == "" and not is_env and name in (base if v is d else tuned) else v # noqa: E731
|
||||
y = extra.get(name, "")
|
||||
# #5136: the engine reads environment settings that its --help does not list, so a name with no row here is not a typing
|
||||
# mistake, and its default is not known (the run config's value is shown when it has one). Only a flag is checked.
|
||||
if p:
|
||||
description = p.full or p.short
|
||||
elif is_env:
|
||||
description = "(an environment setting this table has no description for)"
|
||||
else:
|
||||
description = "(not in this engine's list: newer flag or a typing mistake)"
|
||||
rows.append(Row(name=name, default=str(d) if d else "", tuned=str(t) if t else "", yours=str(y),
|
||||
description=((p.full or p.short) if p else "(not in this engine's list: newer flag or a typing mistake)"),
|
||||
experimental=bool(p and p.experimental), known=bool(p) or not params))
|
||||
description=description, experimental=bool(p and p.experimental),
|
||||
known=bool(p) or is_env or not params))
|
||||
in_use = lambda r: (r.name in base or r.name in tuned or r.name in extra or r.name in (base_env or {}) or r.name in (tuned_env or {})) # noqa: E731
|
||||
rows.sort(key=lambda r: (not in_use(r), switch_order.get(r.name, len(switch_order)), r.name))
|
||||
return rows
|
||||
|
||||
@@ -281,6 +281,21 @@ class Advanced(unittest.TestCase):
|
||||
self.assertIsNone(params.check_name("--prefill", ["--prefill"]))
|
||||
self.assertIsNone(params.check_name("--prefil", None)) # no list to check against: no warning
|
||||
|
||||
def test_an_environment_setting_without_a_row_is_not_a_typing_mistake(self):
|
||||
"""#5136: the engine reads environment settings its --help does not list, so the table cannot call one a newer flag or a
|
||||
typing mistake, and it shows no default it does not know. A flag is still checked against --help."""
|
||||
rows = {r.name: r for r in params.build_rows(self.HELP, ["--kv", "int8"], None, {"STRATA_ROUTE_TAIL_SKIP": "0"}, {},
|
||||
{"STRATA_IQ_MT_MIN": "1", "--prefil": "1"})}
|
||||
config, typed = rows["STRATA_ROUTE_TAIL_SKIP"], rows["STRATA_IQ_MT_MIN"]
|
||||
self.assertEqual((config.default, config.tuned, config.yours), ("0", "0", "")) # the run config's value
|
||||
self.assertEqual(typed.cells(), ("STRATA_IQ_MT_MIN", "-", "-", "1")) # not "off": the table does not know
|
||||
for r in (config, typed):
|
||||
self.assertTrue(r.known)
|
||||
self.assertNotIn("not in this engine's list", r.description)
|
||||
self.assertNotIn("typing mistake", r.description)
|
||||
self.assertFalse(rows["--prefil"].known)
|
||||
self.assertIn("not in this engine's list", rows["--prefil"].description)
|
||||
|
||||
def test_extra_becomes_argv_and_env(self):
|
||||
a, e = S.as_argv_changes({"--prefill": "65536", "--kv-grow": "", "--spec": "off", "STRATA_PIN_BY_NEED": "1"}, frozenset({"--kv-grow"}))
|
||||
self.assertEqual(a, {"--prefill": "65536", "--kv-grow": True, "--spec": None})
|
||||
|
||||
Reference in new issue
Block a user