59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
"""
|
|
Force reload and test with fresh Python process
|
|
"""
|
|
import subprocess
|
|
import sys
|
|
|
|
print("=" * 80)
|
|
print("CLEARING ALL CACHE AND STARTING FRESH PYTHON PROCESS")
|
|
print("=" * 80)
|
|
|
|
# Delete all __pycache__ directories
|
|
print("\n1. Deleting Python cache...")
|
|
result = subprocess.run(
|
|
["python", "-c",
|
|
"import os, shutil; [shutil.rmtree(os.path.join(root, d)) for root, dirs, files in os.walk('.') for d in dirs if d == '__pycache__']"],
|
|
capture_output=True
|
|
)
|
|
print(f" Cache cleared (exit code: {result.returncode})")
|
|
|
|
# Now run the test in a fresh subprocess
|
|
print("\n2. Starting fresh Python process...")
|
|
test_cmd = [
|
|
sys.executable, "-c",
|
|
"""
|
|
import sys
|
|
import os
|
|
os.environ["DISABLE_MODEL_SOURCE_CHECK"] = "True"
|
|
|
|
# Force fresh imports
|
|
for mod in list(sys.modules.keys()):
|
|
if 'cma_extraction' in mod or 'test_accuracy' in mod:
|
|
del sys.modules[mod]
|
|
|
|
# Now run the test
|
|
from test_accuracy_batch_full import process_single_pdf_standalone
|
|
from pathlib import Path
|
|
|
|
pdf_path = Path("src/test/resources/data/pdfs/YDQ23_001838.pdf")
|
|
output_dir = Path("test_reports_fresh")
|
|
|
|
print(f"Processing: {pdf_path}")
|
|
print(f"Output: {output_dir}")
|
|
print()
|
|
|
|
result = process_single_pdf_standalone(pdf_path, output_dir, "ppocr_v5")
|
|
print()
|
|
print("=" * 80)
|
|
print("RESULT")
|
|
print("=" * 80)
|
|
print(f"Status: {result['status']}")
|
|
print(f"CMA: {result['cma']}")
|
|
"""
|
|
]
|
|
|
|
print(" Command:", " ".join(test_cmd))
|
|
print()
|
|
|
|
result = subprocess.run(test_cmd, capture_output=False, text=True)
|