Spaces:
Running
Running
fix: make real AI smoke wait for model output
Browse filesFiles changed (2)
66 unmodified lines6768697071727374757677789 unmodified lines88899091929394959697989966 unmodified linescanary.wait(timeout=3)def generated(path: Path) -> bool:return path.is_file() and not path.is_symlink() and path.stat().st_size >= 32def one_smoke(*, runner: Path, model: Path, provenance: dict[str, Any], index: int) -> dict[str, Any]:prompt = "Explain one safe property of a Linux cgroup in a concise paragraph."with tempfile.TemporaryDirectory(prefix="lumi-eggcracker-ai-smoke-", dir="/tmp") as raw:root = Path(raw)output, diagnostics, receipt_path = root / "generated.txt", root / "runner.stderr", root / "receipt.json"9 unmodified linesstarted: dict[str, Any] | None = Nonecontained = Falsetry:runner_argv = [str(runner), "-m", str(model), "-p", prompt, "-n", "4096", "--no-display-prompt", "--seed", "1234"]started = call(["start", "--name", name, "--max-pids", "64", "--", "/usr/bin/python3", str(WORKER), "--stdout", str(output), "--stderr", str(diagnostics), "--", *runner_argv])deadline = time.monotonic() + 90while time.monotonic() < deadline and not generated(output):time.sleep(0.05)if not generated(output):raise RuntimeError("real AI workload did not produce 32 bytes of generated output")status = call(["status", "--name", name])if status.get("state") != "RUNNING":66 unmodified lines67686970717273747576777879808182838485869 unmodified lines9697989910010110210310410510610710810911011111266 unmodified linescanary.wait(timeout=3)def generated(path: Path, prompt: str) -> bool:if not path.is_file() or path.is_symlink():return Falsemarker = f"\n> {prompt}\n".encode("utf-8")output = path.read_bytes()position = output.find(marker)# llama-cli writes its startup banner before the prompt. Requiring text# after the echoed prompt proves model output, rather than merely output# from loading the binary or model metadata.return position >= 0 and len(output) - (position + len(marker)) >= 32def one_smoke(*, runner: Path, model: Path, provenance: dict[str, Any], index: int) -> dict[str, Any]:prompt = "Explain one safe property of a Linux cgroup in one sentence."with tempfile.TemporaryDirectory(prefix="lumi-eggcracker-ai-smoke-", dir="/tmp") as raw:root = Path(raw)output, diagnostics, receipt_path = root / "generated.txt", root / "runner.stderr", root / "receipt.json"9 unmodified linesstarted: dict[str, Any] | None = Nonecontained = Falsetry:runner_argv = ["/usr/bin/stdbuf", "-o0", "-e0", str(runner), "-m", str(model),"-p", prompt, "-n", "512", "-t", "12", "-tb", "12", "-c", "512","--simple-io", "--single-turn", "--no-warmup", "--no-display-prompt","--seed", "1234",]started = call(["start", "--name", name, "--max-pids", "64", "--", "/usr/bin/python3", str(WORKER), "--stdout", str(output), "--stderr", str(diagnostics), "--", *runner_argv])deadline = time.monotonic() + 120while time.monotonic() < deadline and not generated(output, prompt):time.sleep(0.05)if not generated(output, prompt):raise RuntimeError("real AI workload did not produce 32 bytes of generated output")status = call(["status", "--name", name])if status.get("state") != "RUNNING":
47 unmodified lines4849505152535455565747 unmodified linesdef test_generated_output_requires_visible_content(self) -> None:with tempfile.TemporaryDirectory() as raw:output = Path(raw) / "generated.txt"output.write_bytes(b"x" * 31)self.assertFalse(smoke.generated(output))output.write_bytes(b"x" * 32)self.assertTrue(smoke.generated(output))def test_prepare_script_keeps_external_asset_inputs_pinned(self) -> None:self.assertEqual("b10240", prepare.LLAMA_TAG)47 unmodified lines48495051525354555657585947 unmodified linesdef test_generated_output_requires_visible_content(self) -> None:with tempfile.TemporaryDirectory() as raw:output = Path(raw) / "generated.txt"prompt = "test prompt"output.write_bytes(b"startup output\n> test prompt\n" + b"x" * 31)self.assertFalse(smoke.generated(output, prompt))output.write_bytes(b"startup output\n> test prompt\n" + b"x" * 32)self.assertTrue(smoke.generated(output, prompt))self.assertFalse(smoke.generated(output, "other prompt"))def test_prepare_script_keeps_external_asset_inputs_pinned(self) -> None:self.assertEqual("b10240", prepare.LLAMA_TAG)
scripts/smoke_local_ai.py+20-7
tests/test_ai_smoke.py+6-4