File size: 1,269 Bytes
c49b21b
4b5719e
c49b21b
 
 
4b5719e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c49b21b
4b5719e
 
c49b21b
4b5719e
 
c49b21b
4b5719e
c49b21b
4b5719e
 
 
 
 
 
 
c49b21b
4b5719e
 
c49b21b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -u

echo "Starting AdvisorAI Data Pipeline with Gradio..."

# Determine writable data dir via existing Python config logic
NLTK_DIR=$(python - <<'PY'
import os
try:
    from src.config import DATA_DIR
except Exception:
    # fallback order
    for p in ['/data', '/app/data', '/tmp']:
        try:
            os.makedirs(p, exist_ok=True)
            test = os.path.join(p, '.wtest')
            open(test,'w').close(); os.remove(test)
            DATA_DIR = p
            break
        except Exception:
            continue
    else:
        DATA_DIR = '/tmp'

nl = os.path.join(DATA_DIR, 'nltk_data')
os.makedirs(nl, exist_ok=True)
print(nl)
PY
)

export NLTK_DATA="$NLTK_DIR"
echo "NLTK_DATA set to: $NLTK_DATA"

# Best-effort NLTK downloads (do not fail on errors)
python - <<'PY'
import os
print('Preparing NLTK into', os.environ.get('NLTK_DATA'))
try:
    import nltk
    for pkg in ['punkt', 'stopwords', 'vader_lexicon']:
        try:
            nltk.download(pkg, download_dir=os.environ.get('NLTK_DATA'), quiet=True)
            print('Downloaded', pkg)
        except Exception as e:
            print('NLTK download failed for', pkg, e)
except Exception as e:
    print('NLTK import failed:', e)
PY

echo "Starting services..."
exec "$@"