fix(cli): _codes_for's slow-SQL warning is elements-only, not lineage --all-payable (refs #691 #692)
Minor from the final fix wave: _codes_for's "~20 min of SQL before any model call" warning describes elements' per-code LLM classification pass. lineage --all-payable also calls _codes_for but its own --all-payable path (lineage_all) is one inverted pass over fr_anchors — seconds, not minutes — so the warning there was misleading. New warn_slow keyword (default True, elements' two call sites unchanged; lineage --all-payable passes warn_slow=False).
This commit is contained in:
@@ -117,8 +117,17 @@ def _run_elements(
|
||||
|
||||
|
||||
def _codes_for(
|
||||
con: Any, codes: list[str], families: list[str], all_payable: bool
|
||||
con: Any,
|
||||
codes: list[str],
|
||||
families: list[str],
|
||||
all_payable: bool,
|
||||
*,
|
||||
warn_slow: bool = True,
|
||||
) -> list[str]:
|
||||
"""*warn_slow*: the "~20 min of SQL before any model call" warning
|
||||
describes ``elements``' per-code LLM classification pass — it does
|
||||
NOT apply to ``lineage --all-payable`` (one inverted pass over
|
||||
``fr_anchors``, seconds not minutes), which passes ``warn_slow=False``."""
|
||||
out: list[str] = [c.upper() for c in codes]
|
||||
if families:
|
||||
refresh_from(con)
|
||||
@@ -137,11 +146,12 @@ def _codes_for(
|
||||
"SELECT DISTINCT hcpcs FROM pfs.rvu WHERE status_code IN ('A','R','T') "
|
||||
"AND year = (SELECT max(year) FROM pfs.rvu) ORDER BY hcpcs"
|
||||
).fetchall()
|
||||
log.warning(
|
||||
"--all-payable is experimental: targeting %d codes (~20 min of SQL "
|
||||
"before any model call)",
|
||||
len(rows),
|
||||
)
|
||||
if warn_slow:
|
||||
log.warning(
|
||||
"--all-payable is experimental: targeting %d codes (~20 min of SQL "
|
||||
"before any model call)",
|
||||
len(rows),
|
||||
)
|
||||
out.extend(r[0] for r in rows)
|
||||
if not out:
|
||||
raise typer.BadParameter("pass --code, --family or --all-payable")
|
||||
@@ -256,7 +266,7 @@ def lineage_cmd(
|
||||
# calls write_events and publishes.
|
||||
con = _read()
|
||||
try:
|
||||
targets = _codes_for(con, [], [], True)
|
||||
targets = _codes_for(con, [], [], True, warn_slow=False)
|
||||
if limit:
|
||||
targets = targets[:limit]
|
||||
by_code = lineage_all(con, store, targets)
|
||||
|
||||
@@ -202,6 +202,20 @@ class TestElements:
|
||||
assert set(seen) == expected
|
||||
|
||||
|
||||
class TestCodesForWarnSlow:
|
||||
"""``_codes_for``'s "~20 min of SQL" warning describes the
|
||||
per-code LLM classification pass ``elements`` runs — it does not
|
||||
apply to ``lineage --all-payable`` (one inverted pass, seconds)."""
|
||||
|
||||
def test_warns_by_default(self, con, caplog):
|
||||
pfs_cli._codes_for(con, [], [], True)
|
||||
assert "20 min" in caplog.text
|
||||
|
||||
def test_silent_when_warn_slow_is_false(self, con, caplog):
|
||||
pfs_cli._codes_for(con, [], [], True, warn_slow=False)
|
||||
assert "20 min" not in caplog.text
|
||||
|
||||
|
||||
class TestLineage:
|
||||
def test_prints_and_writes(self, con, monkeypatch):
|
||||
ev = EventRow(
|
||||
|
||||
Reference in New Issue
Block a user