File size: 1,330 Bytes
89e5b6e 79edacd 037bea6 4692cb2 037bea6 317967f 89e5b6e 79edacd 037bea6 |
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 |
#!/bin/bash
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
NOTEBOOK_DIR="/data"
# Download notebook from URL if provided
if [ -n "$NOTEBOOK_URL" ]; then
# Extract filename from URL
FILENAME=$(basename "$NOTEBOOK_URL")
# Handle GitHub raw URLs
if [[ "$NOTEBOOK_URL" == *"github.com"* && "$NOTEBOOK_URL" != *"raw.githubusercontent.com"* ]]; then
# Convert GitHub URL to raw URL
RAW_URL=$(echo "$NOTEBOOK_URL" | sed 's|github.com|raw.githubusercontent.com|' | sed 's|/blob/|/|')
wget -O "$NOTEBOOK_DIR/$FILENAME" "$RAW_URL"
else
wget -O "$NOTEBOOK_DIR/$FILENAME" "$NOTEBOOK_URL"
fi
echo "Downloaded notebook: $FILENAME"
else
echo "No NOTEBOOK_URL provided. Using existing notebooks in the repository."
fi
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
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 |