first-llm-classifier / start_server.sh
fdaudens's picture
fdaudens HF Staff
Update start_server.sh
0913112 verified
raw
history blame
1.34 kB
#!/bin/bash
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
# Define directories
NOTEBOOK_DIR="/data"
ORIGINAL_NOTEBOOKS="/notebooks"
BACKUP_DIR="/home/user/original_notebooks"
# Create backup directory if it doesn't exist
if [ ! -d "$BACKUP_DIR" ]; then
echo "Creating backup directory for original notebooks..."
mkdir -p "$BACKUP_DIR"
# Copy all original notebooks to the backup directory
cp -r "$ORIGINAL_NOTEBOOKS"/*.ipynb "$BACKUP_DIR"
fi
# Clear the notebook directory and copy fresh notebooks for this session
echo "Preparing fresh notebooks for this session..."
mkdir -p "$NOTEBOOK_DIR"
rm -rf "$NOTEBOOK_DIR"/*.ipynb
cp "$BACKUP_DIR"/*.ipynb "$NOTEBOOK_DIR"
# Set proper permissions
chmod -R 755 "$NOTEBOOK_DIR"
# Start JupyterLab
echo "Starting JupyterLab..."
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