Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 4,469 Bytes
61d29fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | ---
sidebar_position: 9
---
# π Variable Name Migration Guide
## What Changed?
We've standardized environment variable names to match `.env.example`:
| Old Name | New Name | Status |
|----------|----------|--------|
| `HF_TOKEN` | `HUGGINGFACE_TOKEN` | β
Backwards compatible |
| `HF_USERNAME` | `HF_USERNAME` | β
No change |
## Why This Change?
- **Consistency:** All variables now match `.env.example`
- **Clarity:** `HUGGINGFACE_TOKEN` is more descriptive than generic `HF_TOKEN`
- **Developer Experience:** Single source of truth in `.env.example`
## Migration Steps
### 1. Local Development (.env file)
**No action needed!**
The `.env.example` already uses `HUGGINGFACE_TOKEN`, so if you copied it to create your `.env`, you're already using the correct variable name.
If you have an old `.env` file with `HF_TOKEN`:
```bash
# Old (still works due to backwards compatibility)
HF_TOKEN=hf_your_token_here
# New (recommended)
HUGGINGFACE_TOKEN=hf_your_token_here
```
### 2. GitHub Actions Secrets
If you're using the GitHub Actions workflow for deployment:
**Option A: Rename the secret (Recommended)**
1. Go to your repository
2. Click **Settings** β **Secrets and variables** β **Actions**
3. Delete the old `HF_TOKEN` secret
4. Create a new secret named `HUGGINGFACE_TOKEN` with the same token value
**Option B: Add new secret (Keep both)**
1. Go to **Settings** β **Secrets and variables** β **Actions**
2. Add new secret `HUGGINGFACE_TOKEN` with your token
3. Keep `HF_TOKEN` for now (you can delete it later)
**Option C: Do nothing**
The scripts still check for `HF_TOKEN` as a fallback, but the GitHub Actions workflow now requires `HUGGINGFACE_TOKEN`.
### 3. Hugging Face Space Secrets
If deploying to Hugging Face Spaces:
1. Go to your Space settings: `https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME/settings`
2. Click **Variables and secrets**
3. The space should use `HUGGINGFACE_TOKEN` (it may already be set correctly)
### 4. Production Environments
Update your production environment variables:
```bash
# Docker
docker run -e HUGGINGFACE_TOKEN=hf_xxx ...
# Docker Compose
environment:
- HUGGINGFACE_TOKEN=hf_xxx
# Kubernetes
env:
- name: HUGGINGFACE_TOKEN
valueFrom:
secretKeyRef:
name: hf-secrets
key: token
```
## Backwards Compatibility
β
**Python scripts are backwards compatible:**
```python
# scripts/upload_to_huggingface.py checks both:
self.token = token or os.getenv("HUGGINGFACE_TOKEN") or os.getenv("HF_TOKEN")
```
This means:
- β
`HUGGINGFACE_TOKEN` works (preferred)
- β
`HF_TOKEN` still works (fallback)
- β
Both can coexist (HUGGINGFACE_TOKEN takes precedence)
β οΈ **GitHub Actions workflow requires update:**
The `.github/workflows/deploy-huggingface.yml` now uses `HUGGINGFACE_TOKEN` only, so you must update your GitHub secrets.
## Verification
### Check Your Local Setup
```bash
# Should show your token
echo $HUGGINGFACE_TOKEN
# Old variable (may or may not be set)
echo $HF_TOKEN
```
### Test Your Scripts
```bash
# Should work with HUGGINGFACE_TOKEN
python scripts/upload_to_huggingface.py --discovery
# Should also work with HF_TOKEN (backwards compatibility)
export HF_TOKEN="hf_xxx"
python scripts/upload_to_huggingface.py --discovery
```
## Troubleshooting
### "Hugging Face token required" Error
**Cause:** Neither `HUGGINGFACE_TOKEN` nor `HF_TOKEN` is set
**Solution:**
```bash
# Set the correct variable
export HUGGINGFACE_TOKEN="hf_YOUR_TOKEN_HERE"
# Or add to .env file
echo "HUGGINGFACE_TOKEN=hf_YOUR_TOKEN_HERE" >> .env
```
### GitHub Actions Deployment Fails
**Cause:** GitHub secret still named `HF_TOKEN`
**Solution:**
1. Go to Settings β Secrets and variables β Actions
2. Add secret `HUGGINGFACE_TOKEN` with your token
3. Re-run the workflow
### Not Sure Which Variable You're Using
Check your current environment:
```bash
# See all HF-related variables
env | grep -E "(HF_|HUGGINGFACE)"
```
## Summary
| Action | Required? | Notes |
|--------|-----------|-------|
| Update .env file | Optional | Works with both names |
| Update GitHub secrets | **Required** | If using GitHub Actions |
| Update HF Space secrets | Recommended | Check your Space settings |
| Update production env | Recommended | For consistency |
| Update code | Not needed | Backwards compatible |
## Questions?
Check the `.env.example` file for the latest variable names and examples.
---
**Last Updated:** 2026-04-26
|