S-Vetrivel commited on
Commit
d72a730
·
1 Parent(s): 08f0d4c

Fix Import Error: Add __init__.py files and debug logs

Browse files
app/main.py CHANGED
@@ -18,7 +18,16 @@ try:
18
  from src.pipeline.detector import VoicePipeline
19
  except ImportError as e:
20
  # Fallback or detailed error logging
21
- print(f"Failed to import src.pipeline.detector. CWD: {os.getcwd()}, Path: {sys.path}")
 
 
 
 
 
 
 
 
 
22
  raise e
23
 
24
  load_dotenv()
 
18
  from src.pipeline.detector import VoicePipeline
19
  except ImportError as e:
20
  # Fallback or detailed error logging
21
+ root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
22
+ print(f"Failed to import src.pipeline.detector.")
23
+ print(f"CWD: {os.getcwd()}")
24
+ print(f"Path: {sys.path}")
25
+ print(f"Root dir: {root_path}")
26
+ if os.path.exists(root_path):
27
+ print(f"Contents of root: {os.listdir(root_path)}")
28
+ src_path = os.path.join(root_path, "src")
29
+ if os.path.exists(src_path):
30
+ print(f"Contents of src: {os.listdir(src_path)}")
31
  raise e
32
 
33
  load_dotenv()
app/repro_import.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ # Simulate the path fix in main.py
5
+ current_dir = os.path.dirname(os.path.abspath(__file__))
6
+ root_dir = os.path.abspath(os.path.join(current_dir, ".."))
7
+ sys.path.append(root_dir)
8
+
9
+ print(f"CWD: {os.getcwd()}")
10
+ print(f"Added to path: {root_dir}")
11
+ print(f"Sys Path: {sys.path}")
12
+
13
+ try:
14
+ import src
15
+ print("Import src SUCCESS")
16
+ from src.pipeline import detector
17
+ print("Import src.pipeline.detector SUCCESS")
18
+ except ImportError as e:
19
+ print(f"Import FAILED: {e}")
src/__init__.py ADDED
File without changes
src/components/__init__.py ADDED
File without changes
src/pipeline/__init__.py ADDED
File without changes
src/utils/__init__.py ADDED
File without changes