okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
bc09a17e5
main
1"""OWN-1B: nothing downloads llama.cpp to build, package or install Strata. 2 3ggml (third_party/strata-ggml), strata-vision's sources (third_party/strata-llama) and gguf-py (third_party/strata-gguf-py) are vendored at the llama.cpp 4pin. This test reads the release scripts, Docker files, CI workflows and setup.py and fails when one of them fetches llama.cpp again or requires a checkout. 5The overrides (STRATA_GGML_DIR, LLAMA, GG, --llama, STRATA_GGUF_PY) stay for two releases and are allowed: they only POINT at a checkout. 6 7python -m unittest tools.test_no_llama_download -v 8""" 9import re 10import sys 11import unittest 12from pathlib import Path 13 14ROOT = Path (__file__ ).resolve ().parents [1 ] 15sys .path .insert (0 ,str (ROOT )) 16 17SCRIPTS = ["packaging/build_cuda_linux.sh" ,"packaging/build_cuda_linux_aarch64.sh" ,"packaging/build_cuda_windows.py" ,"packaging/build_hip_linux.sh" ,"packaging/build_hip_gfx1103.sh" , 18"packaging/build_sycl_linux.sh" ,"packaging/build_split_cuda.sh" ,"packaging/build_split_hip.sh" , 19"packaging/build_vision_windows.bat" ,"packaging/build_vision_mac.sh" , 20"packaging/mac/build_engine.sh" ,"spark/build_engine.sh" , 21"tools/hip/build_windows.bat" ,"Dockerfile" ,"docker/Dockerfile" ,"docker/entrypoint.sh" ,".github/workflows/backends.yml" , 22".github/workflows/metal-build.yml" ,"metal/setup_mac.py" ,"sycl/setup_intel.py" ] 23# a download of llama.cpp: its git remote or archive URL, setup's fetch function, the downloaded folder as a requirement 24FETCH = [r"ggml-org/llama\.cpp(\.git|/archive)" ,r"get_llama_cpp\s*\(" ,r"LLAMA_CPP_ZIP" ,r"FETCHCONTENT_SOURCE_DIR_STRATA_LLAMACPP" ] 25REQUIRED = [r"third_party[/\\]llama\.cpp" ,r":\?[^}]*llama\.cpp" ,r"set STRATA_GGML_DIR to" ] 26 27 28class NoLlamaDownload (unittest .TestCase ): 29def test_no_script_dockerfile_or_workflow_fetches_or_requires_a_llama_cpp_tree (self ): 30for rel in SCRIPTS : 31text = (ROOT / rel ).read_text (encoding = "utf-8" ,errors = "replace" ) 32for pat in FETCH + REQUIRED : 33self .assertIsNone (re .search (pat ,text ),f" { rel } still matches / { pat } /" ) 34 35def test_setup_has_no_llama_cpp_zip_and_the_vendored_trees_are_the_defaults (self ): 36import setup 37self .assertFalse (hasattr (setup ,"LLAMA_CPP_ZIP" )) 38self .assertIsNone (setup .get_llama_cpp ()if not setup .os .environ .get ("STRATA_GGML_DIR" )else None ) 39self .assertEqual (setup .VENDORED_LLAMA ,ROOT / "third_party" / "strata-llama" ) 40self .assertEqual (setup .vision_llama (None ),ROOT / "third_party" / "strata-llama" ) 41self .assertEqual (setup .ggml_defs (None ), []) 42for part in ("third_party/strata-ggml" ,): 43self .assertIn (part ,setup .ENGINE_SOURCES ) 44self .assertIn ("third_party/strata-llama" ,setup .VISION_SOURCES ) 45self .assertIn ("tools/vision" ,setup .VISION_SOURCES ) 46 47def test_tools_vision_takes_the_vendored_tree_by_default (self ): 48cm = (ROOT / "tools" / "vision" / "CMakeLists.txt" ).read_text (encoding = "utf-8" ) 49self .assertIn ('set(LLAMA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/strata-llama"' ,cm ) 50tree = ROOT / "third_party" / "strata-llama" 51for rel in ("CMakeLists.txt" ,"src/llama.cpp" ,"tools/mtmd/mtmd.cpp" ,"tools/mtmd/models/qwen3vl.cpp" ,"ggml/CMakeLists.txt" ,"ggml/src/ggml-backend-reg.cpp" , 52"ggml/src/ggml-cuda/ggml-cuda.cu" ,"ggml/src/ggml-sycl/ggml-sycl.cpp" ,"ggml/src/ggml-metal/ggml-metal.cpp" ,"ggml/src/ggml-hip/CMakeLists.txt" , 53"vendor/miniaudio/miniaudio.h" ,"vendor/stb/stb_image.h" ,"LICENSE" ): 54self .assertTrue ((tree / rel ).is_file (),rel ) 55 56def test_the_nvfp4_tools_take_the_vendored_converter (self ): 57"""The NVFP4-local tools import torch and transformers (not on the test boxes), so only the wiring is checked: they compile, name no downloaded tree and 58find the vendored converter, whose conversion/qwen4exp.py the policy hooks patch.""" 59sys .path .insert (0 ,str (ROOT / "tools" )) 60import _paths 61for name in ("nvfp4_convert.py" ,"nvfp4_verify.py" ,"nvfp4_verify_gguf.py" ): 62src = (ROOT / "tools" / name ).read_text (encoding = "utf-8" ) 63compile (src ,name ,"exec" ) 64self .assertNotIn ("llama.cpp\"" ,src .replace ("llama.cpp's" ,"" ),name ) 65self .assertNotIn ('"third_party" / "llama.cpp"' ,src ,name ) 66conv = Path (_paths .converter_dir ()) 67self .assertEqual (conv ,ROOT / "third_party" / "strata-gguf-py" / "converter" ) 68src = (conv / "conversion" / "qwen4exp.py" ).read_text (encoding = "utf-8" ) 69self .assertIn ("class Qwen4ExpTextModel" ,src ) 70self .assertIn ("_place_ple_shard" ,src ) 71 72def test_the_terminal_and_control_carry_gguf_py_so_a_model_is_prepared_without_a_download (self ): 73pt = (ROOT / "packaging" / "package_terminal.py" ).read_text (encoding = "utf-8" ) 74self .assertIn ('INSTALLER_THIRD_PARTY = ("third_party/strata-gguf-py",)' ,pt ) 75 76 77if __name__ == "__main__" : 78unittest .main ()