Render price decision envelopes directly
This commit is contained in:
@@ -20,7 +20,9 @@ from services.competitor_match_attempt_rescore_audit import ( # noqa: E402
|
||||
DEFAULT_RESCAN_STATUSES,
|
||||
build_match_attempt_rescore_audit,
|
||||
fetch_match_attempt_rescore_rows,
|
||||
fetch_variant_rescore_accept_review_rows,
|
||||
materialize_rescore_accept_reviews,
|
||||
retract_variant_rescore_accept_reviews,
|
||||
summarize_match_attempt_rescore,
|
||||
)
|
||||
from services.competitor_price_feeder import MIN_MATCH_SCORE # noqa: E402
|
||||
@@ -74,12 +76,20 @@ def main(argv: list[str] | None = None) -> int:
|
||||
action="store_true",
|
||||
help="Append accepted-current rows to competitor_match_attempts for manual review; never writes competitor_prices.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--retract-variant-accepted",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Append low-confidence retraction rows for latest rescore_accepted_current "
|
||||
"attempts that contain variant_selection_review; never writes competitor_prices."
|
||||
),
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
statuses = tuple(args.statuses or DEFAULT_RESCAN_STATUSES)
|
||||
if args.input:
|
||||
if args.apply_accepted:
|
||||
parser.error("--apply-accepted requires DB mode; do not combine it with --input.")
|
||||
if args.apply_accepted or args.retract_variant_accepted:
|
||||
parser.error("--apply-accepted/--retract-variant-accepted require DB mode; do not combine them with --input.")
|
||||
rows = [row for row in _read_jsonl(args.input) if not row.get("_invalid_json")]
|
||||
summary = summarize_match_attempt_rescore(
|
||||
rows,
|
||||
@@ -90,7 +100,27 @@ def main(argv: list[str] | None = None) -> int:
|
||||
from config import DATABASE_PATH
|
||||
|
||||
engine = create_engine(DATABASE_PATH)
|
||||
if args.apply_accepted:
|
||||
if args.apply_accepted and args.retract_variant_accepted:
|
||||
parser.error("Choose only one write mode: --apply-accepted or --retract-variant-accepted.")
|
||||
if args.retract_variant_accepted:
|
||||
with engine.begin() as conn:
|
||||
rows = fetch_variant_rescore_accept_review_rows(
|
||||
conn,
|
||||
source=args.source,
|
||||
limit=args.limit,
|
||||
)
|
||||
summary = {
|
||||
"selection_mode": "latest_sku_only",
|
||||
"scanned": len(rows),
|
||||
"rows": rows[: max(0, args.sample_limit)],
|
||||
"retraction": retract_variant_rescore_accept_reviews(
|
||||
conn,
|
||||
rows,
|
||||
source=args.source,
|
||||
min_score=args.min_score,
|
||||
),
|
||||
}
|
||||
elif args.apply_accepted:
|
||||
with engine.begin() as conn:
|
||||
rows = fetch_match_attempt_rescore_rows(
|
||||
conn,
|
||||
|
||||
Reference in New Issue
Block a user