Health score updates in backend
This commit is contained in:
@@ -8,6 +8,16 @@ Usage:
|
||||
python scripts/enrich_nutrition.py --max-products 200 --no-narrative
|
||||
python scripts/enrich_nutrition.py --force # re-fetch even already-verified products
|
||||
|
||||
# Catalogue-wide, past ACTIVE_BRANDS. Without this the run cannot reach
|
||||
# Britannia, Parle or ITC at all, because enrich_all_products reads through
|
||||
# vector_store.list_available_brands(), which honours that filter.
|
||||
python scripts/enrich_nutrition.py --include-inactive
|
||||
python scripts/enrich_nutrition.py --brands "Britannia,Parle"
|
||||
python scripts/enrich_nutrition.py --categories "Fruits & Vegetables,Eggs"
|
||||
|
||||
Non-consumables (soap, shampoo, mosquito repellent, flowers) are skipped and
|
||||
reported separately - see app/services/consumability.py.
|
||||
|
||||
Equivalent to POST /api/admin/nutrition-intelligence/enrich.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -36,6 +46,13 @@ def main() -> None:
|
||||
parser.add_argument("--force", action="store_true", help="Re-fetch even products already marked 'verified'")
|
||||
parser.add_argument("--no-narrative", action="store_true", help="Skip the LLM narrative step (facts/scores/tags only)")
|
||||
parser.add_argument("--max-products", type=int, default=None, help="Cap the number of products processed (for a quick test run)")
|
||||
parser.add_argument("--brands", default=None,
|
||||
help="Comma-separated brand display names to enrich (default: whatever ACTIVE_BRANDS allows)")
|
||||
parser.add_argument("--include-inactive", action="store_true",
|
||||
help="Enrich every brand table, ignoring ACTIVE_BRANDS. Needed to reach "
|
||||
"brands the app does not currently display.")
|
||||
parser.add_argument("--categories", default=None,
|
||||
help="Comma-separated categories to restrict the run to, e.g. 'Fruits & Vegetables,Eggs'")
|
||||
args = parser.parse_args()
|
||||
|
||||
ensure_nutrition_schema()
|
||||
@@ -44,12 +61,16 @@ def main() -> None:
|
||||
generate_narrative=not args.no_narrative,
|
||||
progress_cb=_progress,
|
||||
max_products=args.max_products,
|
||||
brands=[b for b in (args.brands or "").split(",") if b.strip()] or None,
|
||||
include_inactive=args.include_inactive,
|
||||
categories=[c for c in (args.categories or "").split(",") if c.strip()] or None,
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"Done in {result.duration_seconds}s - "
|
||||
f"{result.verified} verified, {result.partial} partial, {result.unavailable} unavailable "
|
||||
f"of {result.total_products} total products"
|
||||
f"of {result.total_products} total products "
|
||||
f"({result.skipped_non_consumable} non-consumable skipped)"
|
||||
)
|
||||
if result.errors:
|
||||
logger.warning(f"{len(result.errors)} errors (showing up to 10): {result.errors[:10]}")
|
||||
|
||||
Reference in New Issue
Block a user