Spaces:
Sleeping
Sleeping
File size: 5,707 Bytes
9dc895b |
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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# How to Upload app.py to HuggingFace Spaces
## β
Good News: app.py is Already Fixed!
Your local `app.py` file is correctly configured with:
- β
`USE_HF_API = "True"` (line 143)
- β
`USE_LMSTUDIO = "False"` (line 144)
- β
`LLM_BACKEND = "hf_api"` (line 145)
- β
`LLM_TIMEOUT = "180"` (line 147)
**Location**: `/home/john/TranscriptorEnhanced/app.py`
**File size**: 44KB
**Last modified**: Oct 30, 18:04
---
## π How to Upload to Your HuggingFace Space
### **Method 1: Via HuggingFace Web Interface (Easiest)**
1. **Open your Space in browser**
- Go to: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE
2. **Click "Files" tab**
3. **Click on "app.py"** to open it
4. **Click the "Edit" button** (pencil icon)
5. **Delete ALL content** in the editor (Ctrl+A, Delete)
6. **Open your local file**:
```bash
# On your local machine, open:
/home/john/TranscriptorEnhanced/app.py
```
7. **Copy ALL content** from your local file (Ctrl+A, Ctrl+C)
8. **Paste into HF editor** (Ctrl+V)
9. **Click "Commit changes to main"**
10. **Wait 2-3 minutes** for Space to rebuild
---
### **Method 2: Via Git (If You Have Git Access)**
If you cloned your Space repository:
```bash
# Navigate to your Space repo
cd /path/to/your-space-repo
# Copy the fixed file
cp /home/john/TranscriptorEnhanced/app.py .
# Commit and push
git add app.py
git commit -m "Fix: Force HF API mode to resolve timeout errors"
git push
```
---
### **Method 3: Direct File Upload**
1. **Go to your Space**: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE
2. **Click "Files" tab**
3. **Click "Upload files"** button
4. **Select your local file**:
```
/home/john/TranscriptorEnhanced/app.py
```
5. **Choose**: "Overwrite existing file"
6. **Click "Commit"**
---
## β
Verification After Upload
### **Step 1: Check the Logs**
After your Space restarts, click the **"Logs"** tab and look for:
```
π Forcing HF API mode for HuggingFace Spaces deployment...
β
HuggingFace token detected
β
Configuration loaded for HuggingFace Spaces
π TranscriptorAI Enterprise - LLM Backend: hf_api
π§ USE_HF_API: True
π§ USE_LMSTUDIO: False
π§ LLM_TIMEOUT: 180s
```
**Good signs**:
- β
"Forcing HF API mode"
- β
"HuggingFace token detected"
- β
"LLM Backend: hf_api"
- β
"USE_HF_API: True"
**Bad signs** (means old file still there):
- β "LLM Backend: local"
- β "USE_HF_API: False"
- β "Loading local model: microsoft/Phi-3"
### **Step 2: Test Processing**
Upload a test transcript and check logs for:
```
INFO: Calling HF API: microsoft/Phi-3-mini-4k-instruct
```
**Should NOT see**:
```
INFO: Generating with local model
ERROR: LLM generation timed out
```
### **Step 3: Check Quality Score**
After processing completes:
- β
Quality Score should be **0.70-1.00** (not 0.00)
- β
Processing time: **30-60 minutes** for 10 files (not hours)
- β
No timeout errors
---
## π Troubleshooting
### Issue: "Still seeing timeout errors"
**Check 1**: Verify file was uploaded
- Go to Files tab in your Space
- Click app.py
- Search for line 143
- Should say: `os.environ["USE_HF_API"] = "True"`
- If it says `setdefault` instead, the file wasn't uploaded correctly
**Check 2**: Verify token is set
- Go to Settings tab
- Look for HUGGINGFACE_TOKEN in secrets
- If not there, add it from https://huggingface.co/settings/tokens
**Check 3**: Force rebuild
- Settings tab β "Factory reboot"
- This clears all caches and rebuilds from scratch
### Issue: "Logs show 'USE_HF_API: False'"
**Cause**: Old file still being used
**Fix**:
1. Delete app.py from your Space
2. Upload the fixed version again
3. Factory reboot
### Issue: "HuggingFace token detected" not showing
**Cause**: Token not set in Space secrets
**Fix**:
1. Go to: https://huggingface.co/settings/tokens
2. Create new token (type: Read)
3. Go to Space β Settings β Repository secrets
4. Add: Name=HUGGINGFACE_TOKEN, Value=(your token)
5. Factory reboot
---
## π Quick Checklist
Before upload:
- [x] Local app.py has `USE_HF_API = "True"` on line 143 β (already confirmed)
- [ ] HUGGINGFACE_TOKEN is set in Space secrets
- [ ] Ready to upload file
After upload:
- [ ] File uploaded successfully
- [ ] Space rebuilt (takes 2-3 minutes)
- [ ] Logs show "Forcing HF API mode"
- [ ] Logs show "USE_HF_API: True"
- [ ] Logs show "LLM Backend: hf_api"
- [ ] Test transcript processes without timeout
- [ ] Quality Score > 0.00
---
## π― Expected Timeline
1. **Upload file**: 1 minute
2. **Space rebuild**: 2-3 minutes
3. **First transcript test**: 5-10 minutes (for a typical file)
4. **Total**: ~15 minutes to confirm it's working
---
## π If Still Not Working
After uploading and waiting for rebuild, if you still see timeout errors:
1. **Copy the startup logs** (first 50 lines)
2. **Copy the error logs** (when processing fails)
3. **Check these specific lines**:
- Line showing "LLM Backend: ???"
- Line showing "USE_HF_API: ???"
- Line showing "Calling HF API" or "Generating with local model"
This will help diagnose if the file uploaded correctly or if there's another issue.
---
## β
File is Ready - Just Upload It!
Your local file at `/home/john/TranscriptorEnhanced/app.py` is **100% correct**.
**All you need to do is**:
1. Copy it to your HuggingFace Space (Method 1, 2, or 3 above)
2. Wait for rebuild
3. Test!
The timeout issue will be **completely resolved** once this file is on your Space. π
|