okami.mom/strata

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

Niko1221Merge f-028-app-p13b8dc8fa3

main
2.5 KiB54 linesraw
1"""The update's test start must not pick a DeepSeek model: it runs the engine under test (the Strata engine) with the model's options, and a
2DeepSeek model runs on strata-dsv41 (a separate package). Seen on a PC with a DeepSeek and a Qwen model: the test start failed with
3'unknown argument: --eos' and engine 0.1.50 was refused."""
4
5import json
6import tempfile
7import unittest
8from pathlib import Path
9from unittest import mock
10
11from strata_control import models, updater
12
13
14class DiscoverRunConfigCase(unittest.TestCase):
15    def setUp(self):
16        self.temp = tempfile.TemporaryDirectory(prefix="strata-discover-")
17        self.addCleanup(self.temp.cleanup)
18        self.root = Path(self.temp.name)
19
20    def config(self, name: str, **fields) -> str:
21        path = self.root / f"strata-{name}.json"
22        path.write_text(json.dumps(fields), encoding="utf-8")
23        return str(path)
24
25    def discover(self, *entries):
26        listed = {"models": [{"id": i, "component_status": "present", "source_config": c} for i, c in entries]}
27        with mock.patch.object(models, "list_installed", return_value=listed), \
28                mock.patch("strata_control.profiles.list_profiles", return_value=[]):
29            return updater.discover_run_config()
30
31    def test_deepseek_is_skipped_for_a_model_the_engine_under_test_can_run(self):
32        deep = self.config("deepseek", exe="C:/e/engine-dsv41/0.1.51/strata-dsv41.exe", arch="deepseek41", args=["--eos", "1"])
33        qwen = self.config("qwen", exe="C:/e/engine/strata.exe", args=["--pack", "x"])
34        # "deepseek..." sorts first by id, which is how the update picked it before
35        self.assertEqual(self.discover(("deepseek-v4.1-flash", deep), ("unsloth-ud-iq4_xs", qwen)), Path(qwen))
36
37    def test_deepseek_is_recognised_by_its_exe_alone(self):
38        deep = self.config("deepseek", exe=r"C:\e\engine-dsv41\0.1.51\strata-dsv41.exe", args=[])
39        self.assertIsNone(self.discover(("deepseek-v4.1-flash", deep)))
40
41    def test_only_deepseek_installed_means_no_model(self):
42        deep = self.config("deepseek", exe="x", arch="deepseek41")
43        self.assertIsNone(self.discover(("deepseek-v4.1-flash", deep)))
44
45    def test_other_and_unreadable_configs_are_still_used(self):
46        qwen = self.config("qwen", exe="C:/e/engine/strata.exe")
47        broken = self.root / "strata-broken.json"
48        broken.write_text("{not json", encoding="utf-8")
49        self.assertEqual(self.discover(("a-broken", str(broken))), broken)
50        self.assertEqual(self.discover(("b-qwen", qwen)), Path(qwen))
51
52
53if __name__ == "__main__":
54    unittest.main()