import subprocess import os import sys import time # Fix Windows ZMQ + CUDA crash issue os.environ['CUDA_MODULE_LOADING'] = 'EAGER' python_exe = sys.executable api_dir = os.path.dirname(os.path.abspath(__file__)) restart_script = r"C:\Users\csuti\.gemini\antigravity\brain\74b0caef-2a34-41a7-b5be-0128459f3d88\scratch\restart_qdrant.py" reindex_script = os.path.join(api_dir, "reindex_jina_v5_local.py") test_script = os.path.join(api_dir, "test_rag_query.py") sys.stdout.reconfigure(encoding='utf-8') sys.stderr.reconfigure(encoding='utf-8') def run_step(args, name): print(f"\n============================================================") print(f"STARTING STEP: {name}") print(f"Command: {' '.join(args)}") print(f"============================================================") start_time = time.time() res = subprocess.run(args, cwd=api_dir) elapsed = time.time() - start_time if res.returncode != 0: print(f"\n[FAIL] STEP FAILED: {name} (exit code: {res.returncode})") sys.exit(res.returncode) print(f"[OK] STEP COMPLETED: {name} in {elapsed:.1f} seconds") def main(): print("Starting Tipitaka re-indexing and validation job...") # 1. Restart Qdrant Server run_step([python_exe, restart_script], "Restart Qdrant DB Server") # 2. Run local GPU Re-indexing run_step([python_exe, reindex_script], "Local GPU Re-indexing (to tipitaka_chunks_ft_vol1)") # 3. Verify retrieval run_step([python_exe, test_script], "Verify Retrieval & RAG Query") print("\n[SUCCESS] ALL STEPS COMPLETED SUCCESSFULY!") if __name__ == "__main__": main()