# HuggingFace Spaces Deployment Guide ## Prerequisites - โœ… HuggingFace account (`Tschoui`) - โœ… Private datasets created: - `Tschoui/tox21-requests` - `Tschoui/tox21-results` - โœ… HuggingFace token with access to both datasets ## Step 1: Create the Space 1. **Go to**: https://huggingface.co/new-space 2. **Fill in**: - **Space name**: `tox21-leaderboard` - **License**: Apache 2.0 - **SDK**: Gradio - **Hardware**: CPU basic (free) - **Visibility**: Public (users can see the leaderboard) 3. **Click "Create Space"** ## Step 2: Upload Your Code ### Option A: Git (Recommended) ```bash git clone https://huggingface.co/spaces/Tschoui/tox21-leaderboard cd tox21-leaderboard # Copy your files (excluding .env, .git, etc.) git add . git commit -m "Initial leaderboard setup" git push ``` ### Option B: Web Upload 1. **Go to your Space**: `https://huggingface.co/spaces/Tschoui/tox21-leaderboard` 2. **Files and versions** tab 3. **Upload files** - upload everything EXCEPT `.env` ## Step 3: Configure Space Secrets 1. **Go to your Space settings**: `https://huggingface.co/spaces/Tschoui/tox21-leaderboard/settings` 2. **Repository secrets** section 3. **New secret**: - **Name**: `HF_TOKEN` - **Value**: Your HuggingFace token (the same one from `.env`) 4. **Save** ## Step 4: Update README.md The Space needs proper metadata in `README.md`: ```yaml --- title: Tox21 Leaderboard emoji: ๐Ÿงช colorFrom: green colorTo: blue sdk: gradio app_file: app.py pinned: false license: apache-2.0 --- # Tox21 Leaderboard Molecular toxicity prediction leaderboard for the Tox21 dataset. ``` ## Step 5: Deploy & Test 1. **Push/Upload** your code 2. **Space will build automatically** 3. **Check logs** for any errors 4. **Test** that it can connect to your datasets ## Environment Handling ### Local Development: - Uses `.env` file with your token - `load_dotenv()` loads the token ### HuggingFace Spaces: - Uses Spaces Secrets (`HF_TOKEN`) - `.env` file not deployed (in `.gitignore`) - `os.environ.get("HF_TOKEN")` gets token from Spaces ## Security Notes โœ… **Safe**: Token stored in Spaces Secrets (encrypted) โœ… **Safe**: `.env` never pushed to git โœ… **Safe**: Users never see your token โŒ **Don't**: Hardcode tokens in source code โŒ **Don't**: Make datasets public if you don't want users seeing raw data