Ahilan Kumaresan
commited on
Commit
Β·
6c9b7fc
1
Parent(s):
6f0a426
Add automatic GitHub to Hugging Face sync workflow
Browse files- .github/workflows/sync-to-huggingface.yml +36 -0
- AUTO_SYNC_SETUP.md +197 -0
- DEPLOYMENT_GUIDE.md +84 -0
- QUICK_DEPLOY.md +69 -0
- upload_to_hf.py +75 -0
.github/workflows/sync-to-huggingface.yml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
workflow_dispatch: # Allows manual trigger from GitHub UI
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync-to-huggingface:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout repository
|
| 15 |
+
uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0 # Fetch all history for proper sync
|
| 18 |
+
lfs: true # Enable Git LFS if needed
|
| 19 |
+
|
| 20 |
+
- name: Push to Hugging Face Space
|
| 21 |
+
env:
|
| 22 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 23 |
+
run: |
|
| 24 |
+
git config --global user.email "ahilan.kumaresan@example.com"
|
| 25 |
+
git config --global user.name "Ahilan Kumaresan"
|
| 26 |
+
|
| 27 |
+
# Add Hugging Face remote
|
| 28 |
+
git remote add hf https://AhiBucket:$HF_TOKEN@huggingface.co/spaces/AhiBucket/Hand-wave || true
|
| 29 |
+
|
| 30 |
+
# Push to Hugging Face
|
| 31 |
+
git push hf main --force
|
| 32 |
+
|
| 33 |
+
- name: Notify completion
|
| 34 |
+
run: |
|
| 35 |
+
echo "β
Successfully synced to Hugging Face Space!"
|
| 36 |
+
echo "π View at: https://huggingface.co/spaces/AhiBucket/Hand-wave"
|
AUTO_SYNC_SETUP.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Automatic GitHub β Hugging Face Sync Setup
|
| 2 |
+
|
| 3 |
+
This guide will set up **automatic synchronization** so that every commit to GitHub automatically updates your Hugging Face Space.
|
| 4 |
+
|
| 5 |
+
## β¨ What This Does
|
| 6 |
+
|
| 7 |
+
- **Commit to GitHub** β Automatically pushes to Hugging Face
|
| 8 |
+
- **Zero manual work** after initial setup
|
| 9 |
+
- **Instant deployment** - changes go live automatically
|
| 10 |
+
- **Works with any branch** (configured for `main`)
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## π One-Time Setup (5 minutes)
|
| 15 |
+
|
| 16 |
+
### Step 1: Get Your Hugging Face Token
|
| 17 |
+
|
| 18 |
+
1. Go to: https://huggingface.co/settings/tokens
|
| 19 |
+
2. Click **"New token"**
|
| 20 |
+
3. Name it: `GitHub Actions Sync`
|
| 21 |
+
4. Permission: Select **"Write"**
|
| 22 |
+
5. Click **"Generate token"**
|
| 23 |
+
6. **COPY THE TOKEN** (you won't see it again!)
|
| 24 |
+
|
| 25 |
+
### Step 2: Add Token to GitHub Secrets
|
| 26 |
+
|
| 27 |
+
1. Go to your GitHub repository: https://github.com/Ahilan-Bucket/Hand-wave
|
| 28 |
+
2. Click **"Settings"** (top menu)
|
| 29 |
+
3. In the left sidebar, click **"Secrets and variables"** β **"Actions"**
|
| 30 |
+
4. Click **"New repository secret"**
|
| 31 |
+
5. Name: `HF_TOKEN`
|
| 32 |
+
6. Value: Paste your Hugging Face token
|
| 33 |
+
7. Click **"Add secret"**
|
| 34 |
+
|
| 35 |
+
### Step 3: Push the GitHub Actions Workflow
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
cd d:\Documents\SFU\PHYS385_Quantum2\CodeProjects\Hand-wave
|
| 39 |
+
|
| 40 |
+
# Add the workflow file
|
| 41 |
+
git add .github/workflows/sync-to-huggingface.yml
|
| 42 |
+
|
| 43 |
+
# Commit
|
| 44 |
+
git commit -m "Add automatic sync to Hugging Face Space"
|
| 45 |
+
|
| 46 |
+
# Push to GitHub
|
| 47 |
+
git push origin main
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Step 4: Verify It Works
|
| 51 |
+
|
| 52 |
+
1. Go to: https://github.com/Ahilan-Bucket/Hand-wave/actions
|
| 53 |
+
2. You should see the workflow running
|
| 54 |
+
3. Wait for it to complete (green checkmark β
)
|
| 55 |
+
4. Check your Hugging Face Space: https://huggingface.co/spaces/AhiBucket/Hand-wave
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## π― How It Works
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
βββββββββββββββββββ
|
| 63 |
+
β You commit to β
|
| 64 |
+
β GitHub β
|
| 65 |
+
ββββββββββ¬βββββββββ
|
| 66 |
+
β
|
| 67 |
+
βΌ
|
| 68 |
+
βββββββββββββββββββ
|
| 69 |
+
β GitHub Actions β
|
| 70 |
+
β automatically β
|
| 71 |
+
β triggers β
|
| 72 |
+
ββββββββββ¬βββββββββ
|
| 73 |
+
β
|
| 74 |
+
βΌ
|
| 75 |
+
βββββββββββββββββββ
|
| 76 |
+
β Pushes to β
|
| 77 |
+
β Hugging Face β
|
| 78 |
+
β Space β
|
| 79 |
+
ββββββββββ¬βββββββββ
|
| 80 |
+
β
|
| 81 |
+
βΌ
|
| 82 |
+
βββββββββββββββββββ
|
| 83 |
+
β Space rebuilds β
|
| 84 |
+
β automatically β
|
| 85 |
+
β (1-2 minutes) β
|
| 86 |
+
βββββββββββββββββββ
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## π Daily Workflow (After Setup)
|
| 92 |
+
|
| 93 |
+
From now on, your workflow is simple:
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
# 1. Make changes to your code
|
| 97 |
+
# (edit app.py, functions.py, etc.)
|
| 98 |
+
|
| 99 |
+
# 2. Commit to GitHub
|
| 100 |
+
git add .
|
| 101 |
+
git commit -m "Your change description"
|
| 102 |
+
git push origin main
|
| 103 |
+
|
| 104 |
+
# 3. That's it! π
|
| 105 |
+
# GitHub Actions automatically syncs to Hugging Face
|
| 106 |
+
# Check progress at: https://github.com/Ahilan-Bucket/Hand-wave/actions
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## π Monitoring
|
| 112 |
+
|
| 113 |
+
### Check GitHub Actions Status:
|
| 114 |
+
https://github.com/Ahilan-Bucket/Hand-wave/actions
|
| 115 |
+
|
| 116 |
+
### Check Hugging Face Space:
|
| 117 |
+
https://huggingface.co/spaces/AhiBucket/Hand-wave
|
| 118 |
+
|
| 119 |
+
### View Build Logs:
|
| 120 |
+
- Click on any workflow run in GitHub Actions
|
| 121 |
+
- Expand the steps to see detailed logs
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## π οΈ Troubleshooting
|
| 126 |
+
|
| 127 |
+
### If sync fails:
|
| 128 |
+
|
| 129 |
+
1. **Check the token**:
|
| 130 |
+
- Make sure `HF_TOKEN` secret is set correctly in GitHub
|
| 131 |
+
- Token must have **Write** permission
|
| 132 |
+
|
| 133 |
+
2. **Check the workflow logs**:
|
| 134 |
+
- Go to: https://github.com/Ahilan-Bucket/Hand-wave/actions
|
| 135 |
+
- Click on the failed run
|
| 136 |
+
- Read the error messages
|
| 137 |
+
|
| 138 |
+
3. **Manually trigger**:
|
| 139 |
+
- Go to: https://github.com/Ahilan-Bucket/Hand-wave/actions
|
| 140 |
+
- Click "Sync to Hugging Face Space"
|
| 141 |
+
- Click "Run workflow"
|
| 142 |
+
|
| 143 |
+
### Common Issues:
|
| 144 |
+
|
| 145 |
+
**"Authentication failed"**
|
| 146 |
+
β Token is incorrect or expired. Generate a new token and update the GitHub secret.
|
| 147 |
+
|
| 148 |
+
**"Remote already exists"**
|
| 149 |
+
β This is normal and handled by the workflow (using `|| true`)
|
| 150 |
+
|
| 151 |
+
**"Permission denied"**
|
| 152 |
+
β Make sure your token has **Write** permission, not just Read
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## π¨ Customization
|
| 157 |
+
|
| 158 |
+
### Change the branch that triggers sync:
|
| 159 |
+
|
| 160 |
+
Edit `.github/workflows/sync-to-huggingface.yml`:
|
| 161 |
+
|
| 162 |
+
```yaml
|
| 163 |
+
on:
|
| 164 |
+
push:
|
| 165 |
+
branches:
|
| 166 |
+
- main # Change this to your preferred branch
|
| 167 |
+
- develop # Or add multiple branches
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
### Add email notifications:
|
| 171 |
+
|
| 172 |
+
You can add email notifications in GitHub Actions settings:
|
| 173 |
+
1. Go to: https://github.com/Ahilan-Bucket/Hand-wave/settings
|
| 174 |
+
2. Click "Notifications"
|
| 175 |
+
3. Configure as desired
|
| 176 |
+
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
## β
Benefits
|
| 180 |
+
|
| 181 |
+
- β¨ **Zero manual deployment** - Just commit and push
|
| 182 |
+
- π **Fast updates** - Changes go live in minutes
|
| 183 |
+
- π **Secure** - Token stored as GitHub secret
|
| 184 |
+
- π **Trackable** - See deployment history in GitHub Actions
|
| 185 |
+
- π **Reliable** - Automatic retries if deployment fails
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## π Additional Resources
|
| 190 |
+
|
| 191 |
+
- GitHub Actions Docs: https://docs.github.com/en/actions
|
| 192 |
+
- Hugging Face Spaces Docs: https://huggingface.co/docs/hub/spaces
|
| 193 |
+
- Your Workflow File: `.github/workflows/sync-to-huggingface.yml`
|
| 194 |
+
|
| 195 |
+
---
|
| 196 |
+
|
| 197 |
+
**That's it!** After the one-time setup, you'll never need to manually deploy again. Just code, commit, and push! π
|
DEPLOYMENT_GUIDE.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deployment Guide: Syncing GitHub to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
## Quick Setup (Choose ONE method)
|
| 4 |
+
|
| 5 |
+
### Method 1: Direct Push to Hugging Face (Recommended)
|
| 6 |
+
|
| 7 |
+
1. **Get your Hugging Face Token:**
|
| 8 |
+
- Go to https://huggingface.co/settings/tokens
|
| 9 |
+
- Click "New token" β Create a **Write** token
|
| 10 |
+
- Copy the token
|
| 11 |
+
|
| 12 |
+
2. **Login to Hugging Face CLI:**
|
| 13 |
+
```bash
|
| 14 |
+
huggingface-cli login
|
| 15 |
+
```
|
| 16 |
+
- Paste your token when prompted
|
| 17 |
+
|
| 18 |
+
3. **Clone the Hugging Face Space repository:**
|
| 19 |
+
```bash
|
| 20 |
+
cd d:\Documents\SFU\PHYS385_Quantum2\CodeProjects
|
| 21 |
+
git clone https://huggingface.co/spaces/AhiBucket/Hand-wave huggingface-hand-wave
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
4. **Copy files from GitHub repo to HF Space:**
|
| 25 |
+
```bash
|
| 26 |
+
cd huggingface-hand-wave
|
| 27 |
+
Copy-Item -Path "..\Hand-wave\app.py" -Destination "." -Force
|
| 28 |
+
Copy-Item -Path "..\Hand-wave\functions.py" -Destination "." -Force
|
| 29 |
+
Copy-Item -Path "..\Hand-wave\requirements.txt" -Destination "." -Force
|
| 30 |
+
Copy-Item -Path "..\Hand-wave\README.md" -Destination "." -Force
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
5. **Commit and push to Hugging Face:**
|
| 34 |
+
```bash
|
| 35 |
+
git add .
|
| 36 |
+
git commit -m "Update: Fixed Plotly compatibility for wavefunction display"
|
| 37 |
+
git push
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
### Method 2: GitHub Integration (Via Web UI)
|
| 43 |
+
|
| 44 |
+
1. **Go to your Space Settings:**
|
| 45 |
+
- Navigate to https://huggingface.co/spaces/AhiBucket/Hand-wave
|
| 46 |
+
- Click **"Settings"** (top right, near your profile)
|
| 47 |
+
|
| 48 |
+
2. **Connect GitHub Repository:**
|
| 49 |
+
- Scroll to **"Repository"** section
|
| 50 |
+
- Click **"Connect to GitHub"**
|
| 51 |
+
- Select repository: `Ahilan-Bucket/Hand-wave`
|
| 52 |
+
- Choose branch: `main`
|
| 53 |
+
- Click **"Save"**
|
| 54 |
+
|
| 55 |
+
3. **Enable Auto-sync:**
|
| 56 |
+
- Toggle **"Automatically rebuild on push"**
|
| 57 |
+
- This will sync your GitHub repo to HF Space automatically
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## What's Been Done Already β
|
| 62 |
+
|
| 63 |
+
1. β
Created new GitHub repository: `Hand-wave`
|
| 64 |
+
2. β
Copied all necessary files from `psi_solve2`
|
| 65 |
+
3. β
Fixed Plotly compatibility issues for Hugging Face
|
| 66 |
+
4. β
Pushed code to GitHub: https://github.com/Ahilan-Bucket/Hand-wave
|
| 67 |
+
|
| 68 |
+
## What's Next π
|
| 69 |
+
|
| 70 |
+
- Choose Method 1 or Method 2 above to sync to Hugging Face
|
| 71 |
+
- Once synced, the wavefunctions should display correctly!
|
| 72 |
+
- Test the deployment at: https://huggingface.co/spaces/AhiBucket/Hand-wave
|
| 73 |
+
|
| 74 |
+
## Troubleshooting
|
| 75 |
+
|
| 76 |
+
**If the app doesn't start:**
|
| 77 |
+
- Check the build logs in the Hugging Face Space
|
| 78 |
+
- Verify `requirements.txt` has all dependencies
|
| 79 |
+
- Make sure `app.py` is in the root directory
|
| 80 |
+
|
| 81 |
+
**If wavefunctions still don't show:**
|
| 82 |
+
- The fixes we made should resolve this
|
| 83 |
+
- Check browser console for JavaScript errors
|
| 84 |
+
- Verify Plotly version compatibility
|
QUICK_DEPLOY.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Quick Deployment to Hugging Face Space
|
| 2 |
+
# This script helps you sync your code to Hugging Face
|
| 3 |
+
|
| 4 |
+
## OPTION 1: Upload via Python Script (Easiest)
|
| 5 |
+
|
| 6 |
+
1. Get your Hugging Face token:
|
| 7 |
+
- Go to: https://huggingface.co/settings/tokens
|
| 8 |
+
- Click "New token" β Create a WRITE token
|
| 9 |
+
- Copy the token
|
| 10 |
+
|
| 11 |
+
2. Run the upload script:
|
| 12 |
+
```bash
|
| 13 |
+
cd d:\Documents\SFU\PHYS385_Quantum2\CodeProjects\Hand-wave
|
| 14 |
+
python upload_to_hf.py
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
3. Paste your token when prompted
|
| 18 |
+
|
| 19 |
+
4. Done! Check your Space: https://huggingface.co/spaces/AhiBucket/Hand-wave
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## OPTION 2: Clone HF Space and Push (Alternative)
|
| 24 |
+
|
| 25 |
+
If Option 1 doesn't work, try this:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# 1. Clone the Hugging Face Space
|
| 29 |
+
cd d:\Documents\SFU\PHYS385_Quantum2\CodeProjects
|
| 30 |
+
git clone https://huggingface.co/spaces/AhiBucket/Hand-wave hf-hand-wave
|
| 31 |
+
|
| 32 |
+
# 2. Copy files
|
| 33 |
+
cd hf-hand-wave
|
| 34 |
+
Copy-Item -Path "..\Hand-wave\app.py" -Destination "." -Force
|
| 35 |
+
Copy-Item -Path "..\Hand-wave\functions.py" -Destination "." -Force
|
| 36 |
+
Copy-Item -Path "..\Hand-wave\requirements.txt" -Destination "." -Force
|
| 37 |
+
Copy-Item -Path "..\Hand-wave\README.md" -Destination "." -Force
|
| 38 |
+
|
| 39 |
+
# 3. Commit and push
|
| 40 |
+
git add .
|
| 41 |
+
git commit -m "Fix: Plotly compatibility for wavefunction display"
|
| 42 |
+
git push
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
When prompted for credentials:
|
| 46 |
+
- Username: Your Hugging Face username
|
| 47 |
+
- Password: Your Hugging Face WRITE token (NOT your password!)
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Files Ready for Deployment β
|
| 52 |
+
|
| 53 |
+
All files have been prepared in: `d:\Documents\SFU\PHYS385_Quantum2\CodeProjects\Hand-wave`
|
| 54 |
+
|
| 55 |
+
- β
app.py (with Plotly fixes)
|
| 56 |
+
- β
functions.py (physics engine)
|
| 57 |
+
- β
requirements.txt (dependencies)
|
| 58 |
+
- β
README.md (documentation)
|
| 59 |
+
- β
.gitignore
|
| 60 |
+
|
| 61 |
+
## What Was Fixed π§
|
| 62 |
+
|
| 63 |
+
The main issue causing wavefunctions not to display on Hugging Face:
|
| 64 |
+
|
| 65 |
+
1. **Array dimension validation** - Ensures x and y arrays match in length
|
| 66 |
+
2. **Data type conversion** - Converts numpy arrays to lists for Plotly compatibility
|
| 67 |
+
3. **Explicit array handling** - Uses x_internal explicitly instead of inline slicing
|
| 68 |
+
|
| 69 |
+
These fixes ensure the app works on both local Streamlit and Hugging Face Spaces!
|
upload_to_hf.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Script to upload files to Hugging Face Space
|
| 3 |
+
Run this after getting your HF token from: https://huggingface.co/settings/tokens
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from huggingface_hub import HfApi, login
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
def upload_to_hf_space():
|
| 10 |
+
print("=" * 60)
|
| 11 |
+
print("Hugging Face Space Uploader")
|
| 12 |
+
print("=" * 60)
|
| 13 |
+
|
| 14 |
+
# Get token from user
|
| 15 |
+
print("\n1. Get your token from: https://huggingface.co/settings/tokens")
|
| 16 |
+
print(" (Create a WRITE token if you don't have one)")
|
| 17 |
+
token = input("\n2. Paste your Hugging Face token here: ").strip()
|
| 18 |
+
|
| 19 |
+
if not token:
|
| 20 |
+
print("β No token provided. Exiting.")
|
| 21 |
+
return
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
# Login
|
| 25 |
+
print("\n3. Logging in to Hugging Face...")
|
| 26 |
+
login(token=token)
|
| 27 |
+
print("β
Login successful!")
|
| 28 |
+
|
| 29 |
+
# Initialize API
|
| 30 |
+
api = HfApi()
|
| 31 |
+
|
| 32 |
+
# Space details
|
| 33 |
+
repo_id = "AhiBucket/Hand-wave"
|
| 34 |
+
repo_type = "space"
|
| 35 |
+
|
| 36 |
+
print(f"\n4. Uploading files to {repo_id}...")
|
| 37 |
+
|
| 38 |
+
# Files to upload
|
| 39 |
+
files_to_upload = [
|
| 40 |
+
"app.py",
|
| 41 |
+
"functions.py",
|
| 42 |
+
"requirements.txt",
|
| 43 |
+
"README.md",
|
| 44 |
+
".gitignore"
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
# Upload each file
|
| 48 |
+
for file in files_to_upload:
|
| 49 |
+
if os.path.exists(file):
|
| 50 |
+
print(f" π€ Uploading {file}...")
|
| 51 |
+
api.upload_file(
|
| 52 |
+
path_or_fileobj=file,
|
| 53 |
+
path_in_repo=file,
|
| 54 |
+
repo_id=repo_id,
|
| 55 |
+
repo_type=repo_type,
|
| 56 |
+
)
|
| 57 |
+
print(f" β
{file} uploaded!")
|
| 58 |
+
else:
|
| 59 |
+
print(f" β οΈ {file} not found, skipping...")
|
| 60 |
+
|
| 61 |
+
print("\n" + "=" * 60)
|
| 62 |
+
print("π SUCCESS! All files uploaded to Hugging Face Space!")
|
| 63 |
+
print("=" * 60)
|
| 64 |
+
print(f"\nπ View your Space at: https://huggingface.co/spaces/{repo_id}")
|
| 65 |
+
print("\nβ³ The Space will rebuild automatically (may take 1-2 minutes)")
|
| 66 |
+
|
| 67 |
+
except Exception as e:
|
| 68 |
+
print(f"\nβ Error: {e}")
|
| 69 |
+
print("\nTroubleshooting:")
|
| 70 |
+
print("- Make sure your token has WRITE permissions")
|
| 71 |
+
print("- Verify the Space exists: https://huggingface.co/spaces/AhiBucket/Hand-wave")
|
| 72 |
+
print("- Check your internet connection")
|
| 73 |
+
|
| 74 |
+
if __name__ == "__main__":
|
| 75 |
+
upload_to_hf_space()
|