#!/bin/bash # Automatic Hugging Face Dataset Sync Script # Configuration REPO_NAME="stamp-dataset" # Change this to your desired repository name ORGANIZATION="" # Optional: your organization name PRIVATE=false # Set to true for private repository # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' # No Color echo -e "${BLUE}🤗 STAMP Dataset Auto-Sync to Hugging Face${NC}" echo "==================================" # Check if huggingface_hub is installed if ! python -c "import huggingface_hub" 2>/dev/null; then echo -e "${RED}❌ huggingface_hub not installed${NC}" echo "Installing required packages..." pip install huggingface_hub datasets fi # Check if logged in to Hugging Face if ! huggingface-cli whoami >/dev/null 2>&1; then echo -e "${RED}❌ Not logged in to Hugging Face${NC}" echo "Please run: huggingface-cli login" exit 1 fi # Get current user HF_USER=$(huggingface-cli whoami | head -n 1) echo -e "${GREEN}✅ Logged in as: ${HF_USER}${NC}" # Generate commit message with timestamp COMMIT_MSG="Auto-update dataset $(date '+%Y-%m-%d %H:%M:%S')" # Prepare upload command UPLOAD_CMD="python upload_to_hf.py --repo-name $REPO_NAME --commit-message \"$COMMIT_MSG\"" if [ ! -z "$ORGANIZATION" ]; then UPLOAD_CMD="$UPLOAD_CMD --organization $ORGANIZATION" fi if [ "$PRIVATE" = true ]; then UPLOAD_CMD="$UPLOAD_CMD --private" fi echo "Repository: $REPO_NAME" echo "Commit message: $COMMIT_MSG" echo "" # Execute upload echo -e "${BLUE}🚀 Starting upload...${NC}" eval $UPLOAD_CMD if [ $? -eq 0 ]; then echo -e "${GREEN}🎉 Dataset successfully synced to Hugging Face!${NC}" # Display repository URL if [ ! -z "$ORGANIZATION" ]; then REPO_URL="https://huggingface.co/datasets/$ORGANIZATION/$REPO_NAME" else REPO_URL="https://huggingface.co/datasets/$HF_USER/$REPO_NAME" fi echo -e "${BLUE}📡 Repository URL: $REPO_URL${NC}" else echo -e "${RED}💥 Upload failed!${NC}" exit 1 fi