okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
47d46ccce
main
1"""A Strix Halo start with --batch N that ended with the engine's own line "N requests at once do not fit in this PC's memory": the Terminal's sentence 2must name the way out in the words of the app and the Terminal (Concurrent requests / --parallel), not the generic "run it again" and not the shared-memory 3advice about the expert cache. Nothing here starts an engine.""" 4from __future__import annotations 5 6import json 7import unittest 8from pathlib import Path 9 10from strata_cli .launch import runner as R 11from tests .terminal .launch_support import Home 12 13ENGINE_LINE = "strata: 4 requests at once do not fit in this PC's memory: start with --batch 3" 14STEP = ("This PC's memory cannot hold that many requests at once. Lower Concurrent requests in the app (or `--parallel` in the Terminal) " 15"by one and start again." ) 16FAILED = {"state" :"failed" ,"error" :"server_exited" ,"engine_exit_code" :1 } 17 18 19class BatchMemoryWords (unittest .TestCase ): 20def config (self ,home :Home ,log_lines :list [str ],args :list [str ]| None = None )-> Path : 21log = home .base / "engine.log" 22log .write_text ("\n" .join (log_lines )+ "\n" ,encoding = "utf-8" ) 23path = home .base / "run.json" 24path .write_text (json .dumps ({"exe" :"e" ,"args" :args or [],"log" :str (log )}),encoding = "utf-8" ) 25return path 26 27def test_the_step_says_to_lower_the_concurrent_requests (self ): 28with Home ()as h : 29cfg = self .config (h , ["strata serve: prefill: copy stream" ,ENGINE_LINE ]) 30text ,nxt = R .explain_engine_exit (FAILED ,cfg ) 31self .assertIn (ENGINE_LINE ,text ) 32self .assertTrue (nxt .startswith (STEP ),nxt ) 33self .assertNotIn ("Run it again" ,nxt ) 34 35def test_the_step_beats_the_shared_memory_advice_on_a_strix_halo (self ): 36args = ["--expert-cache" ,"8000" ,"--resident-budget-gib" ,"38" ] 37with Home ()as h : 38other = self .config (h , ["strata serve: something odd" ],args ) 39_ ,control = R .explain_engine_exit (FAILED ,other ,shared_memory = True ) 40self .assertIn ("shares its memory with the RAM" ,control )# the control: this config does get the advice for another failure 41cfg = self .config (h , [ENGINE_LINE ],args ) 42_ ,nxt = R .explain_engine_exit (FAILED ,cfg ,shared_memory = True ) 43self .assertTrue (nxt .startswith (STEP ),nxt ) 44self .assertNotIn ("shares its memory with the RAM" ,nxt ) 45 46def test_another_failure_keeps_its_own_step (self ): 47with Home ()as h : 48cfg = self .config (h , ["strata serve: something odd" ]) 49_ ,nxt = R .explain_engine_exit (FAILED ,cfg ) 50self .assertTrue (nxt .startswith ("Run it again; if it repeats, report the log." ),nxt ) 51 52def test_the_new_cause_is_the_last_entry (self ): 53self .assertIn ("requests at once do not fit" ,KNOWN_PATTERN_LAST ()) 54 55 56def KNOWN_PATTERN_LAST ()-> str : 57return R .KNOWN_CAUSES [- 1 ][0 ].pattern 58 59 60if __name__ == "__main__" : 61unittest .main ()