Spaces:
Sleeping
Sleeping
yonnel
commited on
Commit
·
8331c23
1
Parent(s):
b1c879a
Fix import error in build_index.py for module execution
Browse files- Add flexible import pattern to handle both direct execution and module execution
- Fixes ModuleNotFoundError: No module named 'settings' when running python -m app.build_index
- Tries relative import, then app.settings, then settings as fallback
- app/build_index.py +9 -1
app/build_index.py
CHANGED
@@ -13,9 +13,17 @@ import time
|
|
13 |
import argparse
|
14 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
15 |
import logging
|
16 |
-
from settings import get_settings
|
17 |
import pickle
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
# Configure logging
|
20 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
21 |
logger = logging.getLogger(__name__)
|
|
|
13 |
import argparse
|
14 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
15 |
import logging
|
|
|
16 |
import pickle
|
17 |
|
18 |
+
# Try different import patterns to handle both direct execution and module execution
|
19 |
+
try:
|
20 |
+
from .settings import get_settings
|
21 |
+
except ImportError:
|
22 |
+
try:
|
23 |
+
from app.settings import get_settings
|
24 |
+
except ImportError:
|
25 |
+
from settings import get_settings
|
26 |
+
|
27 |
# Configure logging
|
28 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
29 |
logger = logging.getLogger(__name__)
|