sunheycho commited on
Commit
227b8f4
Β·
1 Parent(s): 0a08210

Debug: Add startup import debugging to identify exact failure point

Browse files

- Add comprehensive startup debugging for product_comparison import
- Test coordinator creation at startup to catch early failures
- Remove duplicate import blocks that were causing syntax errors
- This will show exactly which LangChain component fails during server startup

Files changed (1) hide show
  1. api.py +36 -2
api.py CHANGED
@@ -57,13 +57,45 @@ from chromadb.utils import embedding_functions
57
 
58
  app = Flask(__name__, static_folder='static')
59
 
60
- # Import product comparison coordinator
 
 
 
 
61
  try:
 
62
  from product_comparison import get_product_comparison_coordinator, decode_base64_image
63
- except ImportError:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  print("Warning: Product comparison module not available")
65
  get_product_comparison_coordinator = None
66
  decode_base64_image = None
 
 
 
 
 
 
 
 
 
 
 
 
67
  # ν™˜κ²½ λ³€μˆ˜μ—μ„œ λΉ„λ°€ ν‚€λ₯Ό κ°€μ Έμ˜€κ±°λ‚˜, μ—†μœΌλ©΄ μ•ˆμ „ν•œ 랜덀 ν‚€ 생성
68
  secret_key = os.environ.get('FLASK_SECRET_KEY')
69
  if not secret_key:
@@ -929,6 +961,8 @@ def add_detected_objects():
929
 
930
 
931
  # Product Comparison API Endpoints
 
 
932
  @app.route('/api/product/compare/start', methods=['POST'])
933
  @login_required
934
  def start_product_comparison():
 
57
 
58
  app = Flask(__name__, static_folder='static')
59
 
60
+ # Import product comparison coordinator with detailed debugging
61
+ print("=" * 80)
62
+ print("[STARTUP DEBUG] πŸš€ Testing product_comparison import at startup...")
63
+ print("=" * 80)
64
+
65
  try:
66
+ print("[DEBUG] Attempting to import product_comparison module...")
67
  from product_comparison import get_product_comparison_coordinator, decode_base64_image
68
+ print("[DEBUG] βœ“ Product comparison module imported successfully!")
69
+ print(f"[DEBUG] βœ“ get_product_comparison_coordinator: {get_product_comparison_coordinator}")
70
+ print(f"[DEBUG] βœ“ decode_base64_image: {decode_base64_image}")
71
+
72
+ # Test coordinator creation
73
+ print("[DEBUG] Testing coordinator creation...")
74
+ test_coordinator = get_product_comparison_coordinator()
75
+ print(f"[DEBUG] βœ“ Test coordinator created: {type(test_coordinator).__name__}")
76
+
77
+ except ImportError as e:
78
+ print(f"[DEBUG] ❌ Product comparison import failed: {e}")
79
+ print(f"[DEBUG] ❌ Import error type: {type(e).__name__}")
80
+ print(f"[DEBUG] ❌ Import error args: {e.args}")
81
+ import traceback
82
+ print("[DEBUG] ❌ Full import traceback:")
83
+ traceback.print_exc()
84
  print("Warning: Product comparison module not available")
85
  get_product_comparison_coordinator = None
86
  decode_base64_image = None
87
+ except Exception as e:
88
+ print(f"[DEBUG] ❌ Unexpected error during import: {e}")
89
+ print(f"[DEBUG] ❌ Error type: {type(e).__name__}")
90
+ import traceback
91
+ print("[DEBUG] ❌ Full traceback:")
92
+ traceback.print_exc()
93
+ get_product_comparison_coordinator = None
94
+ decode_base64_image = None
95
+
96
+ print("=" * 80)
97
+ print(f"[STARTUP DEBUG] 🏁 Import test completed. Coordinator available: {get_product_comparison_coordinator is not None}")
98
+ print("=" * 80)
99
  # ν™˜κ²½ λ³€μˆ˜μ—μ„œ λΉ„λ°€ ν‚€λ₯Ό κ°€μ Έμ˜€κ±°λ‚˜, μ—†μœΌλ©΄ μ•ˆμ „ν•œ 랜덀 ν‚€ 생성
100
  secret_key = os.environ.get('FLASK_SECRET_KEY')
101
  if not secret_key:
 
961
 
962
 
963
  # Product Comparison API Endpoints
964
+
965
+
966
  @app.route('/api/product/compare/start', methods=['POST'])
967
  @login_required
968
  def start_product_comparison():