feat: checkpoint distributed gguf runtime stories
This commit is contained in:
78
tests/test_llama_worker_build.py
Normal file
78
tests/test_llama_worker_build.py
Normal file
@@ -0,0 +1,78 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "packages" / "node" / "native" / "scripts" / "build_llama_worker.sh"
|
||||
PIN_FILE = ROOT / "packages" / "node" / "native" / "llama" / "UPSTREAM_COMMIT"
|
||||
|
||||
|
||||
@pytest.mark.skipif(not SCRIPT.exists(), reason="llama worker build script is missing")
|
||||
def test_llama_worker_build_smoke_rebuild(tmp_path: Path) -> None:
|
||||
if not shutil_which("git"):
|
||||
pytest.skip("git is unavailable")
|
||||
if not (shutil_which("g++") or shutil_which("c++") or shutil_which("clang++")):
|
||||
pytest.skip("no C++ compiler is unavailable")
|
||||
|
||||
source_dir = tmp_path / "llama.cpp"
|
||||
build_one = tmp_path / "build-1"
|
||||
build_two = tmp_path / "build-2"
|
||||
pin = PIN_FILE.read_text(encoding="utf-8").strip()
|
||||
|
||||
source_dir.mkdir()
|
||||
_write_fake_upstream_tree(source_dir, pin)
|
||||
_git_init(source_dir)
|
||||
|
||||
_run_build(source_dir, build_one)
|
||||
_run_build(source_dir, build_two)
|
||||
|
||||
binary = build_two / "meshnet_worker"
|
||||
assert binary.exists()
|
||||
output = subprocess.run(
|
||||
[str(binary), "--smoke"],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert "meshnet worker scaffold ok" in output.stdout
|
||||
assert pin in output.stdout
|
||||
|
||||
|
||||
def _run_build(source_dir: Path, build_dir: Path) -> None:
|
||||
env = os.environ.copy()
|
||||
env.setdefault("PATH", os.environ.get("PATH", ""))
|
||||
subprocess.run(
|
||||
[str(SCRIPT), "--source-dir", str(source_dir), "--build-dir", str(build_dir)],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
|
||||
def _write_fake_upstream_tree(source_dir: Path, pin: str) -> None:
|
||||
(source_dir / "LICENSE").write_text("MIT License placeholder\n", encoding="utf-8")
|
||||
(source_dir / "AUTHORS").write_text("Georgi Gerganov\nMeshnet maintainers\n", encoding="utf-8")
|
||||
(source_dir / "CMakeLists.txt").write_text("# upstream placeholder\n", encoding="utf-8")
|
||||
(source_dir / ".meshnet-upstream-commit").write_text(f"{pin}\n", encoding="utf-8")
|
||||
(source_dir / ".meshnet-upstream-repository").write_text(
|
||||
"https://github.com/ggml-org/llama.cpp.git\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def _git_init(source_dir: Path) -> None:
|
||||
subprocess.run(["git", "init", "-q"], cwd=source_dir, check=True)
|
||||
|
||||
|
||||
def shutil_which(name: str) -> str | None:
|
||||
from shutil import which
|
||||
|
||||
return which(name)
|
||||
Reference in New Issue
Block a user