okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
d8db7ced3
main
1"""The four strings the owner approved word for word (11-07), and the rule for the third.""" 2from __future__import annotations 3 4import argparse 5import os 6import time 7import unittest 8from pathlib import Path 9from tempfile import TemporaryDirectory 10 11from strata_control import drafting 12from strata_cli .launch import cmd as launch_cmd 13 14ROOT = Path (__file__ ).resolve ().parents [2 ] 15 16 17class Wording (unittest .TestCase ): 18def test_launch_help_and_the_docs_row_say_the_size_depends_on_the_model (self ): 19top = argparse .ArgumentParser () 20parsers = launch_cmd .add_parsers (top .add_subparsers (dest = "command" )) 21helptext = " " .join (" " .join (p .format_help ()for p in parsers ).split ()) 22self .assertIn ("dflash2 (downloads its drafter once, 0.3 to 1.2 GB depending on the model; the size is shown before the download)" ,helptext ) 23self .assertNotIn ("1.2 GB drafter once" ,helptext ) 24docs = (ROOT / "docs" / "TERMINAL_LAUNCH.md" ).read_text (encoding = "utf-8" ) 25self .assertIn ("and downloads its drafter once (0.34 GB for the models that have a tuned drafter, 0.52 GB on Intel Arc, else 1.2 GB)." ,docs ) 26 27def test_the_arc_launch_line_names_what_was_not_downloaded (self ): 28src = (ROOT / "strata_cli" / "launch" / "runner.py" ).read_text (encoding = "utf-8" ) 29self .assertIn ("({path.name}). No model files were downloaded.\")" ,src ) 30self .assertNotIn ("({path.name}). Nothing was downloaded." ,src ) 31 32 33class FetchHint (unittest .TestCase ): 34NONE = drafting .Decision ("auto" ,"off" ,drafting .NONE_HERE ) 35 36def hint (self ,data ,decision = None ,** kw ): 37kw = {"model_name" :"qwen3.8-flash-next-iq3_s" ,"backend" :"cuda" ,"archs" : ["sm_120" ],"args" : [],"vram_mib" :73728.0 ,** kw } 38return drafting .fetch_hint (decision or self .NONE ,data_dir = data ,** kw ) 39 40def miss (self ,data ,age = 0 ): 41mark = Path (data )/ drafting .FOLDER / drafting .MISS_MARK 42mark .parent .mkdir (parents = True ,exist_ok = True ) 43mark .write_text ("x" ) 44if age : 45old = time .time ()- age 46os .utime (mark , (old ,old )) 47 48def test_only_with_a_recent_miss_and_a_tuned_set (self ): 49with TemporaryDirectory ()as d : 50self .assertEqual (self .hint (d ),"" ,"no miss mark" ) 51self .miss (d ) 52self .assertEqual (self .hint (d ),"Run strata drafting fetch to get the DFlash2 drafter now." ) 53self .assertEqual (self .hint (d ,drafting .Decision ("dflash2" ,"off" ,drafting .NONE_HERE )),"Run strata drafting fetch to get the DFlash2 drafter now." ) 54self .assertEqual (self .hint (d ,drafting .Decision ("mtp" ,"off" ,drafting .NONE_HERE )),"" ,"MTP chosen: nothing to fetch" ) 55self .assertEqual (self .hint (d ,drafting .Decision ("auto" ,"mtp" ,"" )),"" ,"a drafter runs" ) 56self .assertEqual (self .hint (d ,drafting .Decision ("auto" ,"off" ,drafting .DIDNT_FIT )),"" ,"off for another reason" ) 57self .assertEqual (self .hint (d ,model_name = "qwen3.8-flash-next-coder-iq1_m" ),"" ,"a set with no tuned drafter" ) 58 59def test_an_old_miss_says_nothing (self ): 60with TemporaryDirectory ()as d : 61self .miss (d ,age = drafting .RETRY_AFTER_S + 60 ) 62self .assertEqual (self .hint (d ),"" ) 63 64 65if __name__ == "__main__" : 66unittest .main ()