Files
zeekay 42124b1f45 hanzo-research 0.2.0: every research and arena route, the crate's records, provenance
The Python client now reaches what the Rust crate does and the server
serves. Research covers every /v1/research route: record() files
benchmarks, studies, runs and papers in one batch a kind; runs(),
get_run() and compare() read them; grant(), revise() and retract() move
consent and versions; the experiment plane and artifacts as before.
Arena covers /v1/benchmark: catalog, leaderboard, claims (written with
protocol and source), history, compare, presets, and runs, which queue a
paid execution and are refused without confirm=True.

wire holds the crate's Run, Benchmark, Measure, Study, Paper and
Comparison field for field; canonical writes RFC 8785 bytes equal to the
crate's (tests/vectors/rust.json, written by the crate); lineage and wal
are the crate's records, and a WAL the crate wrote verifies here.
capture() reads the harness commit (the diff's SHA-256 when dirty), the
weights' SHA-256, host, CPU, GPU, device, dtype and packages, and
apply() folds them into a run.

runs(org=) sends no credential: the server answers ?org= only to a
caller with no org. An org the token does not belong to is refused
before the request, since the server would act in the home org. The
command is hanzo-research; the native CLI owns `hanzo`.
2026-10-15 12:11:45 -07:00

39 lines
1.4 KiB
Python

"""The README's worked example runs as written, against the fake, and the docs page shows the same code."""
from __future__ import annotations
import os
import re
from conftest import HANZO
HERE = os.path.dirname(__file__)
README = os.path.join(HERE, "..", "README.md")
DOCS = os.path.join(HERE, "..", "..", "..", "docs", "content", "docs", "research.mdx")
def example(path: str) -> str:
text = open(path, encoding="utf-8").read()
return re.search(r"## Worked example.*?```python\n(.*?)```", text, re.S).group(1)
def test_the_worked_example_files_reads_back(server, monkeypatch, capsys):
monkeypatch.setenv("HANZO_API_KEY", HANZO)
monkeypatch.setenv("RESEARCH_BASE", server.url)
exec(compile(example(README), "README.md", "exec"), {"__name__": "example"}) # noqa: S102
out = capsys.readouterr().out.split()
assert out[0] == "complete" and float(out[1]) > 0
paths = [(q["method"], q["path"]) for q in server.fake.requests]
assert paths == [
("POST", "/v1/research/benchmarks"),
("POST", "/v1/research/runs"),
("POST", "/v1/research/grants"),
("GET", "/v1/research/runs"),
]
run = server.fake.requests[1]["body"]["runs"][0]
assert run["commit"] == out[2] and "Provenance: harness " in run["notes"] and run["by"]
def test_the_docs_page_shows_the_same_example():
assert example(DOCS) == example(README)