Preserve mixed evaluation evidence with reserved atomic report checkpoints
This commit is contained in:
1 parent
ac90ce748d
commit
0b6c958907
4 files changed
+55
-3
No files matched your search
@@ -16,6 +16,28 @@ ROOT = Path(__file__).resolve().parents[2]
|
||||
FIXTURE = ROOT / 'fixtures/mixed'
|
||||
|
||||
|
||||
def reserve_report(path):
|
||||
"""Refuse to overwrite prior evidence before starting expensive inference."""
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open('x', encoding='utf-8'):
|
||||
pass
|
||||
|
||||
|
||||
def write_report(path, report):
|
||||
"""Publish a complete JSON checkpoint without truncating the prior one."""
|
||||
data = json.dumps(report, indent=2, ensure_ascii=False)
|
||||
temporary = None
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', dir=path.parent,
|
||||
suffix='.partial', delete=False) as stream:
|
||||
temporary = Path(stream.name)
|
||||
stream.write(data)
|
||||
os.replace(temporary, path)
|
||||
finally:
|
||||
if temporary is not None:
|
||||
temporary.unlink(missing_ok=True)
|
||||
|
||||
|
||||
def digest(path):
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
@@ -92,14 +114,14 @@ def run(args):
|
||||
raise ValueError('Model bytes differ from the pinned Google manifest')
|
||||
spec = importlib.util.spec_from_file_location('searchi_benchmark', ROOT / 'tools/embeddinggemma2/benchmark.py')
|
||||
benchmark = importlib.util.module_from_spec(spec); spec.loader.exec_module(benchmark)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
reserve_report(args.output)
|
||||
rows, stages = [], []
|
||||
provenance = {'fixture_sha256': lock['fixture_sha256'], 'model_manifest_sha256': digest(manifest_path),
|
||||
'model': manifest, 'device': 'cpu', 'cpu_threads': 1,
|
||||
'cli_sha256': digest(args.cli), 'worker_sha256': digest(args.worker),
|
||||
'platform': platform.platform(), 'python': platform.python_version()}
|
||||
def checkpoint():
|
||||
args.output.write_text(json.dumps({**provenance, 'complete': False, 'stages': stages, 'rows': rows}, indent=2, ensure_ascii=False), encoding='utf-8')
|
||||
write_report(args.output, {**provenance, 'complete': False, 'stages': stages, 'rows': rows})
|
||||
def stage(name, command, timeout):
|
||||
started = time.perf_counter()
|
||||
try:
|
||||
@@ -167,7 +189,7 @@ def run(args):
|
||||
'device': 'cpu', 'cpu_threads': 1, 'cli_sha256': digest(args.cli), 'worker_sha256': digest(args.worker),
|
||||
'scope_note': 'Small mixed diagnostic, reused previously tested media labels; file-level relevance only. No temporal-localization or production-scale claims. MCP roundtrip excludes initialization and is not UI latency.',
|
||||
'rows': rows, 'summary': summarize(rows)}
|
||||
args.output.write_text(json.dumps(report, indent=2, ensure_ascii=False), encoding='utf-8')
|
||||
write_report(args.output, report)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user