120 lines
5.6 KiB
Python
120 lines
5.6 KiB
Python
import requests
|
|
import os
|
|
import time
|
|
|
|
base_url = 'http://localhost:3015'
|
|
|
|
def test_current_system_status():
|
|
print("=== CURRENT SYSTEM STATUS ===")
|
|
|
|
# Check if server is running
|
|
try:
|
|
response = requests.get(f'{base_url}/', timeout=5)
|
|
print(f"✓ Server is running (status: {response.status_code})")
|
|
except Exception as e:
|
|
print(f"✗ Server is not accessible: {e}")
|
|
return
|
|
|
|
# Login
|
|
login_data = {'username': 'jleu3482', 'password': 'jleu1212'}
|
|
try:
|
|
login_response = requests.post(f'{base_url}/login', data=login_data, timeout=5)
|
|
if login_response.status_code == 200:
|
|
token = login_response.json().get('access_token')
|
|
headers = {'Authorization': f'Bearer {token}'}
|
|
print("✓ Authentication working")
|
|
|
|
# Check document status
|
|
docs_response = requests.get(f'{base_url}/documents', headers=headers, timeout=5)
|
|
if docs_response.status_code == 200:
|
|
docs = docs_response.json()
|
|
statuses = docs.get('statuses', {})
|
|
print(f"Document Status:")
|
|
print(f" Completed: {len(statuses.get('completed', []))}")
|
|
print(f" Processing: {len(statuses.get('processing', []))}")
|
|
print(f" Failed: {len(statuses.get('failed', []))}")
|
|
|
|
# Show any existing documents
|
|
for status_type in ['completed', 'processing', 'failed']:
|
|
docs_list = statuses.get(status_type, [])
|
|
for doc in docs_list:
|
|
print(f" {status_type.upper()}: {doc.get('file_path')}")
|
|
if status_type == 'failed':
|
|
print(f" Error: {doc.get('error_msg', 'Unknown error')}")
|
|
|
|
# Check pipeline status
|
|
pipeline_response = requests.get(f'{base_url}/documents/pipeline_status', headers=headers, timeout=5)
|
|
if pipeline_response.status_code == 200:
|
|
pipeline_data = pipeline_response.json()
|
|
print(f"Pipeline Status:")
|
|
print(f" Busy: {pipeline_data.get('busy', False)}")
|
|
print(f" Job: {pipeline_data.get('job_name', 'Unknown')}")
|
|
print(f" Latest message: {pipeline_data.get('latest_message', '')}")
|
|
|
|
else:
|
|
print(f"✗ Authentication failed: {login_response.text}")
|
|
except Exception as e:
|
|
print(f"✗ Error checking system status: {e}")
|
|
|
|
def test_simple_upload():
|
|
print("\n=== TESTING SIMPLE UPLOAD (without waiting for processing) ===")
|
|
|
|
# Login
|
|
login_data = {'username': 'jleu3482', 'password': 'jleu1212'}
|
|
try:
|
|
login_response = requests.post(f'{base_url}/login', data=login_data, timeout=5)
|
|
if login_response.status_code == 200:
|
|
token = login_response.json().get('access_token')
|
|
headers = {'Authorization': f'Bearer {token}'}
|
|
|
|
# Upload a simple text file first (no OCR required)
|
|
test_file_path = 'test_simple.txt'
|
|
if os.path.exists(test_file_path):
|
|
print(f"Uploading simple text file: {test_file_path}")
|
|
with open(test_file_path, 'rb') as f:
|
|
files = {'file': (os.path.basename(test_file_path), f, 'text/plain')}
|
|
upload_response = requests.post(f'{base_url}/documents/upload', files=files, headers=headers, timeout=10)
|
|
print(f"Upload status: {upload_response.status_code}")
|
|
if upload_response.status_code == 200:
|
|
upload_data = upload_response.json()
|
|
print(f"Upload response: {upload_data}")
|
|
|
|
# Wait a moment and check if it processes
|
|
print("Waiting 10 seconds for text processing...")
|
|
time.sleep(10)
|
|
|
|
# Check document status
|
|
docs_response = requests.get(f'{base_url}/documents', headers=headers, timeout=5)
|
|
if docs_response.status_code == 200:
|
|
docs = docs_response.json()
|
|
statuses = docs.get('statuses', {})
|
|
completed = len(statuses.get("completed", []))
|
|
processing = len(statuses.get("processing", []))
|
|
failed = len(statuses.get("failed", []))
|
|
print(f"After text upload - Completed: {completed}, Processing: {processing}, Failed: {failed}")
|
|
else:
|
|
print(f"Upload failed: {upload_response.text}")
|
|
else:
|
|
print(f"Test file not found: {test_file_path}")
|
|
except Exception as e:
|
|
print(f"✗ Error during simple upload test: {e}")
|
|
|
|
def check_available_pdfs():
|
|
print("\n=== AVAILABLE PDF FILES ===")
|
|
pdf_files = [f for f in os.listdir('.') if f.lower().endswith('.pdf')]
|
|
for pdf in pdf_files:
|
|
size = os.path.getsize(pdf)
|
|
print(f" {pdf} ({size} bytes)")
|
|
|
|
if __name__ == "__main__":
|
|
test_current_system_status()
|
|
test_simple_upload()
|
|
check_available_pdfs()
|
|
|
|
print("\n=== SUMMARY ===")
|
|
print("The server is experiencing cuDNN version detection errors during OCR processing.")
|
|
print("This prevents GPU-accelerated OCR from working properly.")
|
|
print("Possible solutions:")
|
|
print("1. Use CPU-only OCR mode (slower but reliable)")
|
|
print("2. Fix the cuDNN version detection issue")
|
|
print("3. Use alternative OCR processing methods") |