tostido's picture
download
raw
6.12 kB
"""
šŸ” Causation Explorer Web UI - Setup Diagnostic Tool
Run this script on your other PC to check if everything is set up correctly.
It will verify all dependencies, files, and paths needed for the web UI.
"""
import sys
from pathlib import Path
import importlib
print("=" * 70)
print("šŸ” Causation Explorer Web UI - Setup Diagnostic")
print("=" * 70)
print()
errors = []
warnings = []
# 1. Check Python version
print("1ļøāƒ£ Python Version")
print(f" Python {sys.version}")
if sys.version_info < (3, 7):
errors.append("Python 3.7+ required")
else:
print(" āœ… Python version OK")
print()
# 2. Check Flask
print("2ļøāƒ£ Flask Dependency")
try:
import flask
print(f" āœ… Flask {flask.__version__} installed")
except ImportError:
errors.append("Flask not installed - run: pip install flask")
print(" āŒ Flask NOT INSTALLED")
print()
# 3. Check other dependencies
print("3ļøāƒ£ Other Dependencies")
deps = ['networkx', 'numpy']
for dep in deps:
try:
mod = importlib.import_module(dep)
version = getattr(mod, '__version__', 'unknown')
print(f" āœ… {dep} ({version})")
except ImportError:
warnings.append(f"{dep} not installed (may cause issues)")
print(f" āš ļø {dep} NOT INSTALLED")
print()
# 4. Check project structure
print("4ļøāƒ£ Project Structure")
base_dir = Path(__file__).parent
required_files = [
'causation_web_ui.py',
'causation_explorer.py',
'templates/causation_explorer.html',
]
for file_path in required_files:
full_path = base_dir / file_path
if full_path.exists():
print(f" āœ… {file_path}")
else:
errors.append(f"Missing file: {file_path}")
print(f" āŒ {file_path} NOT FOUND")
print()
# 5. Check data directories
print("5ļøāƒ£ Data Directories")
data_dirs = [
'data/logs',
'data',
'templates',
]
for dir_path in data_dirs:
full_path = base_dir / dir_path
if full_path.exists():
print(f" āœ… {dir_path}/")
else:
# Create if it doesn't exist (non-critical)
try:
full_path.mkdir(parents=True, exist_ok=True)
print(f" āœ… {dir_path}/ (created)")
except Exception as e:
warnings.append(f"Could not create {dir_path}: {e}")
print(f" āš ļø {dir_path}/ (cannot create)")
print()
# 6. Check template file specifically
print("6ļøāƒ£ Template File")
template_path = base_dir / 'templates' / 'causation_explorer.html'
if template_path.exists():
size = template_path.stat().st_size
print(f" āœ… causation_explorer.html ({size:,} bytes)")
# Check if it looks like valid HTML
try:
content = template_path.read_text(encoding='utf-8')
if '<html' in content.lower() and '<script' in content.lower():
print(" āœ… Contains HTML and JavaScript")
else:
warnings.append("Template file may be corrupted")
print(" āš ļø Template content looks incomplete")
except Exception as e:
errors.append(f"Cannot read template file: {e}")
print(f" āŒ Cannot read template: {e}")
else:
errors.append("Template file missing")
print(" āŒ Template file NOT FOUND")
print()
# 7. Test Causation Explorer import
print("7ļøāƒ£ Causation Explorer Module")
try:
from causation_explorer import CausationExplorer
print(" āœ… Module imports successfully")
# Try to initialize (may fail if data dirs missing, but that's OK)
try:
explorer = CausationExplorer()
print(" āœ… Initializes successfully")
except Exception as e:
warnings.append(f"CausationExplorer init warning: {e}")
print(f" āš ļø Initialization warning: {e}")
except ImportError as e:
errors.append(f"Cannot import CausationExplorer: {e}")
print(f" āŒ Import failed: {e}")
except Exception as e:
errors.append(f"Unexpected error: {e}")
print(f" āŒ Error: {e}")
print()
# 8. Test Flask app creation
print("8ļøāƒ£ Flask App Creation")
try:
from flask import Flask
template_dir = Path(__file__).parent / 'templates'
app = Flask(__name__, template_folder=str(template_dir))
print(" āœ… Flask app created successfully")
print(f" āœ… Template folder: {template_dir}")
except Exception as e:
errors.append(f"Cannot create Flask app: {e}")
print(f" āŒ Failed: {e}")
print()
# 9. Check port availability (informational)
print("9ļøāƒ£ Port 5000 Status")
try:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', 5000))
sock.close()
if result == 0:
warnings.append("Port 5000 is already in use")
print(" āš ļø Port 5000 is IN USE (you may need to use a different port)")
else:
print(" āœ… Port 5000 is available")
except Exception as e:
print(f" āš ļø Cannot check port: {e}")
print()
# 10. Summary
print("=" * 70)
print("šŸ“Š DIAGNOSTIC SUMMARY")
print("=" * 70)
if errors:
print("\nāŒ ERRORS (must fix):")
for i, error in enumerate(errors, 1):
print(f" {i}. {error}")
print("\n āš ļø The web UI will NOT work until these are fixed!")
else:
print("\nāœ… No critical errors found!")
if warnings:
print("\nāš ļø WARNINGS (may cause issues):")
for i, warning in enumerate(warnings, 1):
print(f" {i}. {warning}")
else:
print("\nāœ… No warnings!")
print("\n" + "=" * 70)
if errors:
print("\nšŸ”§ QUICK FIX COMMANDS:")
print()
if any("Flask" in e for e in errors):
print(" pip install flask")
if any("Missing file" in e for e in errors):
print(" # Make sure all files are copied from the main PC")
print()
sys.exit(1)
else:
print("\nāœ… Everything looks good! You can run:")
print(" python causation_web_ui.py")
print()
sys.exit(0)

Xet Storage Details

Size:
6.12 kB
Ā·
Xet hash:
49216b7b72d0ecde5f9c26a30d7137fe2bf87331b4c6a0675139cd6fa908bf0b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.