okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221rc1 merge split switch (15fb6ffe3): strata_cli/launch/cmd.py conflicted at --drafting help text; df2-primary's help kept, SFNX's --split-engine argument keptabd9b4581

main
2.6 KiB46 linesraw
1"""`strata launch --split-engine auto|on|off`: the owner's switch for the all-cards split engine (strata_control/split_engine.py).
2auto (nothing written) is the default; the choice is listed in --help, in the copyable flags, in the launch config and in a saved preset, so an
3"off" survives updates and restarts; the launcher's apply_split_engine honours it (off: nothing, auto: silent on a refusal, on: one line)."""
4
5from __future__ import annotations
6
7import unittest
8
9from strata_cli.launch import settings as S
10from strata_cli.launch.runner import derive_config
11from strata_control import split_engine as SE
12from tests.terminal.launch_support import run_cli
13
14
15class Flag(unittest.TestCase):
16    BASE = {"exe": "component:strata-engine", "args": ["--pack", "/d/packs/x", "--mtp", "/d/mtp/rt"], "port": 8080, "model_name": "m"}
17
18    def test_the_flag_is_listed_checked_copyable_and_saved_in_the_launch_config(self):
19        code, out, _ = run_cli(["launch", "--help"])
20        self.assertIn("--split-engine", out)
21        self.assertIn("auto|on|off", out)
22        for mode in S.SPLIT_MODES:
23            cfg = derive_config(self.BASE, S.LaunchSettings(split_engine=mode), bool_flags=frozenset())
24            self.assertEqual(cfg["split_engine"], mode)
25            self.assertEqual(SE.mode(cfg, {}), mode)
26        self.assertNotIn("split_engine", derive_config(self.BASE, S.LaunchSettings(), bool_flags=frozenset()), "nobody chose: auto writes nothing")
27        self.assertEqual(SE.mode(derive_config(self.BASE, S.LaunchSettings(), bool_flags=frozenset()), {}), "auto")
28        self.assertIn("--split-engine off", S.flags_text(S.LaunchSettings(split_engine="off")))
29        self.assertNotIn("--split-engine", S.flags_text(S.LaunchSettings()))
30        code, out, err = run_cli(["launch", "--plan", "--split-engine", "sometimes"])
31        self.assertNotEqual(code, 0)
32
33    def test_a_saved_off_survives_a_new_launch_config_and_a_preset_round_trip(self):
34        s = S.LaunchSettings.from_dict(S.LaunchSettings(split_engine="off").to_dict())
35        self.assertEqual(s.split_engine, "off")
36        self.assertIsNone(S.LaunchSettings.from_dict({}).split_engine)
37        # a config written earlier with "off" is kept when this launch names nothing
38        cfg = derive_config({**self.BASE, "split_engine": "off"}, S.LaunchSettings(), bool_flags=frozenset())
39        self.assertEqual(cfg["split_engine"], "off")
40        # and the person's flag of this launch wins over the old file
41        cfg = derive_config({**self.BASE, "split_engine": "off"}, S.LaunchSettings(split_engine="on"), bool_flags=frozenset())
42        self.assertEqual(cfg["split_engine"], "on")
43
44
45if __name__ == "__main__":
46    unittest.main()