EduConnect / entrypoint.sh
dtyago's picture
Entrypoint to load model
faf4679
raw
history blame
827 Bytes
#!/bin/bash
# Authenticate with Hugging Face
export HF_HOME=/home/user/data/hf_cache
echo "Using Hugging Face API token for authentication"
export HF_TOKEN=${HF_TOKEN}
# 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}..."
mkdir -p "$MODEL_DIR" # Ensure the directory exists before downloading
wget "$MODEL_URL" -P "$MODEL_DIR" || {
echo "Failed to download model from ${MODEL_URL}"
exit 1 # Exit if download fails
}
else
echo "Model ${HF_MODEL_NAME} already present."
fi
# Execute the main command of the container
exec "$@"