Luigi commited on
Commit
fc5ac33
Β·
1 Parent(s): b5d5f43

Test: Verify git workflow preserves commit messages

Browse files
Files changed (3) hide show
  1. DEPLOY.md +72 -0
  2. app.py +1 -1
  3. deploy.sh +97 -0
DEPLOY.md CHANGED
@@ -31,6 +31,8 @@ git commit -m "Initial HF Spaces deployment"
31
  git push
32
  ```
33
 
 
 
34
  ### 3. Wait for Build
35
 
36
  The Space will automatically:
@@ -109,6 +111,76 @@ User Upload β†’ Gradio Interface β†’ app.py β†’ llama-cpp-python β†’ Qwen Model
109
  Streaming Output β†’ User
110
  ```
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  ## Local Testing
113
 
114
  Before deploying to HF Spaces:
 
31
  git push
32
  ```
33
 
34
+ **IMPORTANT:** Always use `git push` - never edit files via the HuggingFace web UI. Web edits create generic commit messages like "Upload app.py with huggingface_hub".
35
+
36
  ### 3. Wait for Build
37
 
38
  The Space will automatically:
 
111
  Streaming Output β†’ User
112
  ```
113
 
114
+ ## Deployment Workflow
115
+
116
+ ### Recommended: Use the Deployment Script
117
+
118
+ The `deploy.sh` script ensures meaningful commit messages:
119
+
120
+ ```bash
121
+ # Make your changes
122
+ vim app.py
123
+
124
+ # Test locally
125
+ python app.py
126
+
127
+ # Deploy with meaningful message
128
+ ./deploy.sh "Fix: Improve thinking block extraction"
129
+ ```
130
+
131
+ The script will:
132
+ 1. Check for uncommitted changes
133
+ 2. Prompt for commit message if not provided
134
+ 3. Warn about generic/short messages
135
+ 4. Show commits to be pushed
136
+ 5. Confirm before pushing
137
+ 6. Verify commit message was preserved on remote
138
+
139
+ ### Manual Deployment
140
+
141
+ If deploying manually:
142
+
143
+ ```bash
144
+ # 1. Make changes
145
+ vim app.py
146
+
147
+ # 2. Test locally
148
+ python app.py
149
+
150
+ # 3. Commit with detailed message
151
+ git add app.py
152
+ git commit -m "Fix: Improve streaming output formatting
153
+
154
+ - Extract thinking blocks more reliably
155
+ - Show full response in thinking field
156
+ - Update regex pattern for better parsing"
157
+
158
+ # 4. Push to HuggingFace Spaces
159
+ git push origin main
160
+
161
+ # 5. Verify deployment
162
+ # Visit: https://huggingface.co/spaces/Luigi/tiny-scribe
163
+ ```
164
+
165
+ ### Avoiding Generic Commit Messages
166
+
167
+ **❌ DON'T:**
168
+ - Edit files directly on huggingface.co
169
+ - Use the "Upload files" button in HF web UI
170
+ - Use single-word commit messages ("fix", "update")
171
+
172
+ **βœ… DO:**
173
+ - Always use `git push` from command line
174
+ - Write descriptive commit messages
175
+ - Test locally before pushing
176
+
177
+ ### Git Hook
178
+
179
+ A pre-push hook is installed in `.git/hooks/pre-push` that:
180
+ - Validates commit messages before pushing
181
+ - Warns about very short messages
182
+ - Ensures you're not accidentally pushing generic commits
183
+
184
  ## Local Testing
185
 
186
  Before deploying to HF Spaces:
app.py CHANGED
@@ -4,7 +4,7 @@ Tiny Scribe - HuggingFace Spaces Demo
4
  A Gradio app for summarizing transcripts using GGUF models with live streaming output.
5
  Optimized for HuggingFace Spaces Free CPU Tier (2 vCPUs).
6
 
7
- Test push: Git workflow verified βœ“
8
  """
9
 
10
  import os
 
4
  A Gradio app for summarizing transcripts using GGUF models with live streaming output.
5
  Optimized for HuggingFace Spaces Free CPU Tier (2 vCPUs).
6
 
7
+ Deployment: Always use git push to preserve meaningful commit messages
8
  """
9
 
10
  import os
deploy.sh ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # deploy.sh - Deploy to HuggingFace Spaces with meaningful commit messages
3
+ #
4
+ # Usage:
5
+ # ./deploy.sh "Your commit message"
6
+ # ./deploy.sh (prompts for message if not provided)
7
+
8
+ set -e # Exit on error
9
+
10
+ # Color output
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m' # No Color
15
+
16
+ # Check if we're in a git repo
17
+ if ! git rev-parse --git-dir > /dev/null 2>&1; then
18
+ echo -e "${RED}Error: Not in a git repository${NC}"
19
+ exit 1
20
+ fi
21
+
22
+ # Check for uncommitted changes
23
+ if ! git diff-index --quiet HEAD --; then
24
+ echo -e "${YELLOW}You have uncommitted changes:${NC}"
25
+ git status --short
26
+ echo ""
27
+ read -p "Stage and commit all changes? (y/n) " -n 1 -r
28
+ echo
29
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
30
+ echo -e "${RED}Aborted${NC}"
31
+ exit 1
32
+ fi
33
+ git add -A
34
+ fi
35
+
36
+ # Get commit message
37
+ if [ -z "$1" ]; then
38
+ echo -e "${YELLOW}Enter commit message:${NC}"
39
+ read -r COMMIT_MSG
40
+ if [ -z "$COMMIT_MSG" ]; then
41
+ echo -e "${RED}Error: Commit message cannot be empty${NC}"
42
+ exit 1
43
+ fi
44
+ else
45
+ COMMIT_MSG="$1"
46
+ fi
47
+
48
+ # Validate commit message isn't generic
49
+ if [[ "$COMMIT_MSG" =~ ^(Upload|update|Update|fix|Fix)$ ]]; then
50
+ echo -e "${YELLOW}Warning: Commit message is too generic: '$COMMIT_MSG'${NC}"
51
+ read -p "Continue anyway? (y/n) " -n 1 -r
52
+ echo
53
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
54
+ echo -e "${RED}Aborted${NC}"
55
+ exit 1
56
+ fi
57
+ fi
58
+
59
+ # Create commit if there are staged changes
60
+ if ! git diff-index --quiet --cached HEAD --; then
61
+ echo -e "${GREEN}Creating commit...${NC}"
62
+ git commit -m "$COMMIT_MSG"
63
+ else
64
+ echo -e "${YELLOW}No staged changes to commit${NC}"
65
+ fi
66
+
67
+ # Show what will be pushed
68
+ echo -e "\n${YELLOW}Commits to be pushed:${NC}"
69
+ git log origin/main..HEAD --oneline --decorate
70
+
71
+ # Confirm push
72
+ echo ""
73
+ read -p "Push to HuggingFace Spaces? (y/n) " -n 1 -r
74
+ echo
75
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
76
+ echo -e "${RED}Aborted${NC}"
77
+ exit 1
78
+ fi
79
+
80
+ # Push to HuggingFace
81
+ echo -e "${GREEN}Pushing to HuggingFace Spaces...${NC}"
82
+ git push origin main
83
+
84
+ echo -e "${GREEN}βœ“ Deployment complete!${NC}"
85
+ echo -e "View at: ${GREEN}https://huggingface.co/spaces/Luigi/tiny-scribe${NC}"
86
+
87
+ # Verify commit message was preserved
88
+ echo -e "\n${YELLOW}Verifying commit on remote...${NC}"
89
+ git fetch origin -q
90
+ REMOTE_MSG=$(git log origin/main -1 --pretty=format:"%s")
91
+ echo -e "Latest remote commit: ${GREEN}$REMOTE_MSG${NC}"
92
+
93
+ if [[ "$REMOTE_MSG" == *"huggingface_hub"* ]]; then
94
+ echo -e "${RED}⚠ WARNING: Remote commit has generic message!${NC}"
95
+ echo -e "${YELLOW}This means you may have edited files via HF web UI.${NC}"
96
+ echo -e "${YELLOW}Always use 'git push' instead of the web interface!${NC}"
97
+ fi