feat(docs): update README to reflect JSON-LD conversion implementation

- mark task 04 as implemented in the project overview
- add convert_json.py as the entry script for task 04
- clarify output paths for JSON-LD conversion artifacts
This commit is contained in:
administrator
2026-07-11 14:21:13 -04:00
parent e3359383c0
commit 9364808b3d
3 changed files with 395 additions and 1 deletions

31
common/storage_sizes.py Normal file
View File

@@ -0,0 +1,31 @@
"""Idempotent per-format updates to out/bench/storage_sizes.csv.
Contract (docs/rules/build-pipeline-tasks.md section 4): columns
format,variant,bytes; a task re-run REPLACES its own format's rows and never
touches other formats' rows.
"""
from __future__ import annotations
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
HEADER = "format,variant,bytes"
def update_storage_sizes(bench_dir: Path, fmt: str, variants: list[tuple[str, int]]) -> Path:
path = bench_dir / "storage_sizes.csv"
kept: list[str] = []
if path.exists():
lines = path.read_text(encoding="ascii").splitlines()
if lines and lines[0] != HEADER:
raise ValueError(f"{path}: unexpected header {lines[0]!r}")
kept = [ln for ln in lines[1:] if ln and ln.split(",", 1)[0] != fmt]
rows = kept + [f"{fmt},{variant},{nbytes}" for variant, nbytes in variants]
bench_dir.mkdir(parents=True, exist_ok=True)
with open(path, "w", encoding="ascii", newline="\n") as fh:
fh.write(HEADER + "\n" + "\n".join(rows) + "\n")
logger.info("storage_sizes.csv: %s -> %s", fmt, ", ".join(f"{v}={b}" for v, b in variants))
return path