okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0f1e5e4cb
main
1"""0.2.10: for an Intel Arc card Strata builds the pack itself (setup.py --prepare-pack).""" 2 3from __future__import annotations 4 5import tempfile 6import unittest 7from pathlib import Path 8from unittest import mock 9 10class IntelPack (unittest .TestCase ): 11def test_prepare_pack_runs_the_pack_tool_with_its_own_gguf_code (self ): 12import setup 13calls = {} 14with tempfile .TemporaryDirectory ()as d : 15gdir = Path (d )/ "models" 16gdir .mkdir () 17fam = setup .FAMILIES ["qwen" ] 18shards = [gdir / setup .model_file (fam ,"IQ3_XXS" ,i )for i in range (1 ,setup .model_shards (fam ,"IQ3_XXS" )+ 1 )] 19for s in shards : 20s .write_bytes (b"x" ) 21pack = Path (d )/ "packs" / "p" 22 23def fake_run (cmd ,cwd = None ,env = None ,check = True ,quiet = False ): 24calls ["cmd" ],calls ["env" ]= cmd ,env 25 (pack / "tokenizer" ).mkdir (parents = True ) 26 (pack / "tokenizer" / "vocab.json" ).write_text ("{}" ) 27 28args = mock .Mock (gguf_dir = str (gdir ),family = "qwen" ,model = "IQ3_XXS" ,prepare_pack = str (pack )) 29fetched = [] 30with mock .patch .object (setup ,"get_llama_cpp" ,lambda :fetched .append (1 )),mock .patch .object (setup ,"run" ,fake_run ), \ 31mock .patch .object (setup ,"gguf_dir_problem" ,lambda * a :None ), \ 32mock .patch .dict ("os.environ" , {k :v for k ,v in __import__ ("os" ).environ .items ()if k != "STRATA_GGUF_PY" },clear = True ): 33self .assertEqual (setup .prepare_pack_only (args ),0 ) 34self .assertIn ("iq_pack.py" ," " .join (map (str ,calls ["cmd" ]))) 35self .assertNotIn ("STRATA_GGUF_PY" ,calls ["env" ],"the tool uses tools/strata_gguf.py unless the user named a gguf-py" ) 36self .assertEqual (fetched , [],"nothing is downloaded" ) 37 38 39if __name__ == "__main__" : 40unittest .main ()