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

Show on the map →

Called by main

Calls none

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
lines 74–74db = next((run / target / "state" / "targets").glob("*/clew.db"))lines 75–75return db, run / target / "repo"

Flows

main

int replay_grid_calls.main(Path run)

Replay every call and print its size and outcome.

scripts/replay_grid_calls.py:82

Show on the map →

Called by none

Calls _paths

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

Activity · 12 steps
lines 84–84◇ for target, label, kwargs in CALLSlines 85–85db, repo = _paths(run, target)lines 86–86tools = QueryTools(lambda db=db: db, lambda repo=repo: repo)lines 87–87trylines 88–88reply = tools.dossier(**kwargs)lines 89–89except Exception as exc: # the refusal IS the measurementlines 90–90print(f"{label:52} REFUSED {exc}")lines 91–91continuelines 92–92size = len(json.dumps(reply, separators=(",", ":")))lines 93–100facts = { "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", "")), }lines 101–101print(f"{label:52} {size:>7,} B {json.dumps({k: v for k, v in facts.items() if v})}")lines 102–102return 0

Flows