EduConnect / entrypoint.sh
dtyago's picture
Mod to support both gguf and hf model download
bcea21a
raw
history blame
948 Bytes
#!/bin/bash
# Authenticate with Hugging Face
export HF_HOME=/home/user/data/hf_cache
# Assuming HF_TOKEN is already exported to the environment
echo "Using Hugging Face API token for authentication"
# Use the environment variable for the model name
MODEL_DIR="/home/user/data/models/${HF_MODEL_NAME}"
MODEL_URL=${HF_MODEL_URL} # Ensure consistent variable naming
# Download the model if it does not exist
if [ ! -d "$MODEL_DIR" ]; then
echo "Model not found. Downloading ${HF_MODEL_NAME} from ${MODEL_URL}..."
# Navigate to the directory where download_model.py is located
cd /home/user/app/app/utils
# Execute the download_model script
echo "Downloading the model..."
python download_model.py || { echo "Model download failed"; exit 1; }
# Navigate back to the app directory
cd /home/user/app
else
echo "Model ${HF_MODEL_NAME} already present."
fi
# Execute the main command of the container
exec "$@"