youssefreda9 commited on
Commit
4393710
·
1 Parent(s): 6963862

fix: better quran import error logging to diagnose HF failure

Browse files
Files changed (1) hide show
  1. src/app.py +7 -2
src/app.py CHANGED
@@ -15,12 +15,17 @@ import re
15
 
16
  # Quran search
17
  import sys
18
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
 
19
  try:
20
  from quran import search_bayan
21
  logger_quran_ok = True
22
- except ImportError:
23
  logger_quran_ok = False
 
 
 
 
24
 
25
  # Pipeline hardening modules
26
  from nlp.pipeline_context import PipelineContext
 
15
 
16
  # Quran search
17
  import sys
18
+ _quran_root = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19
+ sys.path.insert(0, _quran_root)
20
  try:
21
  from quran import search_bayan
22
  logger_quran_ok = True
23
+ except Exception as _quran_err:
24
  logger_quran_ok = False
25
+ import logging as _ql
26
+ _ql.getLogger('app').warning(f'[QURAN] Failed to import quran module: {_quran_err}')
27
+ _ql.getLogger('app').warning(f'[QURAN] Searched path: {_quran_root}')
28
+ _ql.getLogger('app').warning(f'[QURAN] Files in root: {os.listdir(_quran_root) if os.path.isdir(_quran_root) else "DIR NOT FOUND"}')
29
 
30
  # Pipeline hardening modules
31
  from nlp.pipeline_context import PipelineContext