Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| BACKEND_ROOT = Path(__file__).resolve().parents[1] | |
| if str(BACKEND_ROOT) not in sys.path: | |
| sys.path.insert(0, str(BACKEND_ROOT)) | |
| from core.db import init_db | |
| from services.reference_data_service import ingest_reference_resumes | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Bulk ingest sample resumes into local database") | |
| parser.add_argument("--limit", type=int, default=20, help="Maximum number of PDF files to ingest") | |
| parser.add_argument( | |
| "--source-dir", | |
| type=str, | |
| default=None, | |
| help="Optional source directory containing resume PDFs", | |
| ) | |
| parser.add_argument( | |
| "--force-reingest", | |
| action="store_true", | |
| help="Reprocess files even if matching candidate IDs already exist", | |
| ) | |
| args = parser.parse_args() | |
| init_db() | |
| summary = ingest_reference_resumes( | |
| limit=max(1, min(args.limit, 500)), | |
| source_dir=args.source_dir, | |
| force_reingest=args.force_reingest, | |
| ) | |
| print("Reference resume ingestion summary") | |
| print(f"source_dir: {summary.source_dir}") | |
| print(f"requested_limit: {summary.requested_limit}") | |
| print(f"files_seen: {summary.files_seen}") | |
| print(f"ingested: {summary.ingested}") | |
| print(f"skipped: {summary.skipped}") | |
| print(f"failed: {summary.failed}") | |
| if summary.failures: | |
| print("failures:") | |
| for item in summary.failures: | |
| print(f" - {item['file']}: {item['error']}") | |
| if __name__ == "__main__": | |
| main() | |