updates on the backend

This commit is contained in:
sriram
2026-08-11 19:16:01 +05:30
commit c2af4556c6
131 changed files with 546007 additions and 0 deletions

0
cli/__init__.py Normal file
View File

51
cli/ingest_brand.py Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""
CLI for running brand catalog ingestion (discovery -> images -> embeddings
-> pgvector) without going through the API - useful for bulk-loading
brands before the React app or FastAPI server are even running, exactly
like the original project's `pipeline_runner.py`.
Usage:
python cli/ingest_brand.py "Parle" --max-products 50
python cli/ingest_brand.py "Britannia" --max-products 100 -v
"""
from __future__ import annotations
import argparse
import asyncio
import logging
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from app.core.ingestion import ingest_brand # noqa: E402
def main() -> None:
parser = argparse.ArgumentParser(description="Ingest a brand's catalog into pgvector")
parser.add_argument("brand", help="Brand name to discover and ingest, e.g. 'Parle'")
parser.add_argument("--max-products", type=int, default=50, help="Max products to discover (default: 50)")
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose (DEBUG) logging")
args = parser.parse_args()
logging.basicConfig(
level=logging.DEBUG if args.verbose else logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
print(f"Starting ingestion for brand: {args.brand} (max_products={args.max_products})")
summary = asyncio.run(ingest_brand(args.brand, max_products=args.max_products))
print("\n" + "=" * 60)
print("INGESTION SUMMARY")
print("=" * 60)
print(f"Brand: {summary['brand']}")
print(f"Products: {summary['total_products']}")
print(f"Images: {summary['total_images']}")
print(f"Duration: {summary['duration_seconds']}s")
print("=" * 60)
if __name__ == "__main__":
main()