File size: 1,970 Bytes
89e5b6e
c0dc80e
 
 
 
 
 
89e5b6e
c0dc80e
 
79edacd
 
c0dc80e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317967f
c0dc80e
 
 
89e5b6e
 
 
 
 
 
 
 
 
79edacd
 
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
53
54
55
56
57
58
59
60
#!/bin/bash
set -e  # Exit on error

echo "===== Starting FBMC Chronos-2 JupyterLab Space ====="
echo "Timestamp: $(date)"
echo "User: $(whoami)"
echo "Working directory: $(pwd)"

# Set environment
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
NOTEBOOK_DIR="/data"

echo "JUPYTER_TOKEN: ${JUPYTER_TOKEN:0:10}..."
echo "NOTEBOOK_DIR: $NOTEBOOK_DIR"

# Check if jupyter-lab is installed
echo "Checking jupyter-lab installation..."
which jupyter-lab || echo "WARNING: jupyter-lab not found in PATH"
jupyter-lab --version || echo "WARNING: Cannot get jupyter-lab version"

# Check Python environment
echo "Python version: $(python --version)"
echo "Python path: $(which python)"

# List /data directory
echo "Contents of /data directory:"
ls -lah /data || echo "WARNING: Cannot list /data"

# Copy notebooks from /home/user/app to /data if they don't exist
echo "Ensuring notebooks are in /data..."
if [ -f /home/user/app/inference_smoke_test.ipynb ]; then
    echo "Copying notebooks from /home/user/app to /data..."
    cp -v /home/user/app/*.ipynb /data/ 2>/dev/null || true
    if [ -d /home/user/app/src ]; then
        cp -rv /home/user/app/src /data/ 2>/dev/null || true
    fi
fi

echo "Final /data contents:"
ls -lah /data

# Disable announcements
echo "Disabling JupyterLab announcements..."
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" || echo "WARNING: Could not disable announcements"

# Start JupyterLab
echo "Starting JupyterLab on port 7860..."
exec jupyter-lab \
    --ip 0.0.0.0 \
    --port 7860 \
    --no-browser \
    --allow-root \
    --ServerApp.token="$JUPYTER_TOKEN" \
    --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
    --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
    --ServerApp.disable_check_xsrf=True \
    --LabApp.news_url=None \
    --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
    --notebook-dir=$NOTEBOOK_DIR