mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 20:34:17 +01:00
38 lines
1.9 KiB
Python
38 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""switch-model.sh to a lane that leaves the box too little memory for the Clipstral lane beside it says to stop that one first, when it
|
|
runs. The cockpit's Load of such a lane stops it (dashboard/tests/test_embed_cockpit.py); a terminal was told nothing (2026-12-02)."""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
TEXT = (REPO / "switch-model.sh").read_text()
|
|
NOTE = TEXT[TEXT.index("beside_note() {"):TEXT.index("\n}\n", TEXT.index("beside_note() {")) + 3]
|
|
|
|
|
|
class TheNote(unittest.TestCase):
|
|
def said(self, active):
|
|
with tempfile.TemporaryDirectory(prefix="switch-note-") as d:
|
|
f = pathlib.Path(d, "systemctl")
|
|
f.write_text(f'#!/bin/sh\n[ "$*" = "is-active --quiet qwen38-clipstral.service" ] && exit {0 if active else 3}\nexit 1\n')
|
|
f.chmod(0o755)
|
|
r = subprocess.run(["bash", "-euc", NOTE + "beside_note; echo end"], capture_output=True, text=True, env={"PATH": f"{d}:/usr/bin:/bin"})
|
|
self.assertTrue(r.stdout.endswith("end\n"), r.stderr)
|
|
return r.stdout[:-4]
|
|
|
|
def test_it_is_said_while_that_lane_runs_alone(self):
|
|
self.assertIn("sudo systemctl stop qwen38-clipstral.service", self.said(True))
|
|
self.assertEqual(self.said(False), "")
|
|
|
|
def test_the_two_lanes_the_cockpit_stops_it_for_say_it(self):
|
|
self.assertIn('[ "$KOL_MODEL" = "$KOLIBRI_NVFP4_REPO" ] || beside_note', TEXT)
|
|
self.assertIn('[ "$CHOICE" != nemotron-super ] || beside_note', TEXT)
|
|
self.assertEqual(TEXT.count("|| beside_note"), 2)
|
|
js = (REPO / "dashboard" / "static" / "js" / "base.js").read_text()
|
|
self.assertIn("({[UFLASH]: 6.9, [NEMOTRON_SUPER_UNIT]: 9.1})[unit] || (unit === KOLIBRI_UNIT && target === 'kolibri' ? 10.9 : 0)", js)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|