Decoder2704/python-chatbot-jay
0
1#!/usr/bin/env python32"""3Verify retrieval artifact files exist under backend/artifacts/, print sizes, and test read.4 5Run from repo root or backend/:6 python3 backend/debug/verify_artifacts_for_deploy.py7"""8 9from __future__ import annotations10 11import sys12from pathlib import Path13 14# backend/debug/ -> backend/15BACKEND = Path(__file__).resolve().parent.parent16ARTIFACTS = BACKEND / "artifacts"17REQUIRED = (18 "vectorizer.pkl",19 "question_vectors.pkl",20 "chatbot_df.pkl",21)22 23 24def main() -> int:25 print(f"backend root: {BACKEND}")26 print(f"artifacts dir: {ARTIFACTS}")27 if not ARTIFACTS.is_dir():28 print("ERROR: artifacts directory does not exist")29 return 130 31 ok = True32 for name in REQUIRED:33 p = ARTIFACTS / name34 if not p.is_file():35 print(f"MISSING: {p}")36 ok = False37 continue38 size = p.stat().st_size39 print(f"OK {p} ({size:,} bytes)")40 try:41 with open(p, "rb") as f:42 f.read(1)43 print(" readable: yes")44 except OSError as e:45 print(f" readable: NO — {e}")46 ok = False47 48 return 0 if ok else 149 50 51if __name__ == "__main__":52 sys.exit(main())53 