fix: backfill skips hand extraction by default (prose->replay too lossy)
The auto-extracted hands from narrative logs were garbage (mangled cards/positions, 'unknown' players). Seed sessions + recaps + villain dossiers only; hands come from clean shorthand going forward. --with-hands re-enables if ever wanted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+11
-3
@@ -79,8 +79,14 @@ def extract(block: str, backend: str = "cloud") -> dict | None:
|
||||
_real_handle = poker._real_handle # one canonical filter (lives in poker.py)
|
||||
|
||||
|
||||
def seed(ex: dict, block: str) -> dict:
|
||||
"""Write one extracted session + its hands + villains to the DB. Returns a summary."""
|
||||
def seed(ex: dict, block: str, with_hands: bool = False) -> dict:
|
||||
"""Write one extracted session + villains (+ hands only if asked) to the DB.
|
||||
|
||||
Hands are OFF by default: reconstructing a clean replayable hand from old
|
||||
narrative prose is too lossy (mangled cards/positions). Sessions, their
|
||||
original writeups (recap), and villain dossiers seed cleanly; hands are best
|
||||
captured fresh from Brian's own shorthand going forward.
|
||||
"""
|
||||
sid = poker.import_session(
|
||||
date=ex.get("date") or "2026-01-01", venue=ex.get("venue"), game=ex.get("game") or "NLH",
|
||||
stakes=ex.get("stakes"), fmt=ex.get("format") or "cash",
|
||||
@@ -88,6 +94,7 @@ def seed(ex: dict, block: str) -> dict:
|
||||
hours=ex.get("hours"), mood=ex.get("mood"), recap_md=block,
|
||||
)
|
||||
n_hands = 0
|
||||
if with_hands:
|
||||
for h in ex.get("hands") or []:
|
||||
hid = poker.store_hand_history(h, session_id=sid)
|
||||
poker.link_hand_players(hid, h, session_id=sid)
|
||||
@@ -107,6 +114,7 @@ def main() -> int:
|
||||
args = sys.argv[1:]
|
||||
commit = "--commit" in args
|
||||
reset = "--reset" in args
|
||||
with_hands = "--with-hands" in args # off by default — prose->hand replay is too lossy
|
||||
limit = None
|
||||
for i, a in enumerate(args):
|
||||
if a == "--dry" and i + 1 < len(args) and args[i + 1].isdigit():
|
||||
@@ -127,7 +135,7 @@ def main() -> int:
|
||||
print(f" ! could not parse a block: {b[:60]!r}")
|
||||
continue
|
||||
if commit:
|
||||
print(" seeded:", seed(ex, b))
|
||||
print(" seeded:", seed(ex, b, with_hands=with_hands))
|
||||
else:
|
||||
print(f"\n=== {ex.get('date')} — {ex.get('venue')} {ex.get('stakes')} "
|
||||
f"({ex.get('format')}) net {ex.get('net')} ===")
|
||||
|
||||
Reference in New Issue
Block a user