replay_grid_calls.py¶
scripts/replay_grid_calls.py
Replay the clew calls that failed or overflowed in the 1.4.0 grid, against that grid's own indexes.
_paths
tuple[Path, Path] replay_grid_calls._paths(Path run, str target)
The run's index database and checkout for one target.
scripts/replay_grid_calls.py:72
Source · 6 lines
def _paths(run: Path, target: str) -> tuple[Path, Path]:
"""@brief Locate a target's index and checkout. @return Paths."""
db = next((run / target / "state" / "targets").glob("*/clew.db"))
return db, run / target / "repo"
Activity · 2 steps
Flows
main
int replay_grid_calls.main(Path run)
Replay every call and print its size and outcome.
scripts/replay_grid_calls.py:82
Source · 23 lines
def main(run: Path) -> int:
"""@brief Replay. @return 0."""
for target, label, kwargs in CALLS:
db, repo = _paths(run, target)
tools = QueryTools(lambda db=db: db, lambda repo=repo: repo)
try:
reply = tools.dossier(**kwargs)
except Exception as exc: # the refusal IS the measurement
print(f"{label:52} REFUSED {exc}")
continue
size = len(json.dumps(reply, separators=(",", ":")))
facts = {
"found": reply.get("found", True),
"sites": len(reply.get("sites") or []) or None,
"selector_note": bool(reply.get("selector_note")),
"not_answered": reply.get("not_answered"),
"limited": bool(reply.get("_limited")),
"says_call_status": "call status" in str(reply.get("note", "")),
}
print(f"{label:52} {size:>7,} B {json.dumps({k: v for k, v in facts.items() if v})}")
return 0