Skip to content

Commit 7ed1584

Browse files
jeremymanningclaude
andcommitted
Simplify remote_train.sh and improve documentation
- Remove GitHub authentication prompts from remote_train.sh - Assume git credentials are pre-configured on server - Simplified repository update: just cd and git pull if exists, else clone - Added comprehensive git credential setup instructions to README - Clarified that remote_train.sh runs FROM local machine - Explained that it executes run_llm_stylometry.sh on server in screen session - Added clear instructions for monitoring progress and downloading results - Emphasized that sync_models.sh also runs from local machine Users now need to set up git credentials once on the server, then the remote scripts handle everything else automatically. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e068dd5 commit 7ed1584

File tree

2 files changed

+64
-120
lines changed

2 files changed

+64
-120
lines changed

README.md

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,42 @@ The training pipeline automatically handles data preparation, model training acr
188188

189189
### Remote Training on GPU Server
190190

191-
For training on a remote GPU server, use the provided `remote_train.sh` script:
191+
#### Prerequisites: Setting up Git credentials on the server
192192

193+
Before using the remote training script, you need to set up Git credentials on your server once:
194+
195+
1. SSH into your server:
196+
```bash
197+
ssh username@server
198+
```
199+
200+
2. Configure Git with your credentials:
201+
```bash
202+
# Set your Git user information (use your GitHub username)
203+
git config --global user.name "your-github-username"
204+
git config --global user.email "[email protected]"
205+
206+
# Enable credential storage
207+
git config --global credential.helper store
208+
```
209+
210+
3. Clone the repository with your Personal Access Token:
193211
```bash
194-
# Start remote training
212+
# Replace <username> and <token> with your GitHub username and Personal Access Token
213+
# Get a token from: https://github.com/settings/tokens (grant 'repo' scope)
214+
git clone https://<username>:<token>@github.com/ContextLab/llm-stylometry.git
215+
216+
# The credentials will be stored for future use
217+
cd llm-stylometry
218+
git pull # This should work without prompting for credentials
219+
```
220+
221+
#### Using the remote training script
222+
223+
Once Git credentials are configured on your server, run `remote_train.sh` **from your local machine** (not on the GPU server):
224+
225+
```bash
226+
# From your local machine, start training on the remote GPU server
195227
./remote_train.sh
196228

197229
# Kill existing training sessions and optionally start new one
@@ -200,25 +232,35 @@ For training on a remote GPU server, use the provided `remote_train.sh` script:
200232
# You'll be prompted for:
201233
# - Server address (hostname or IP)
202234
# - Username
203-
# - GitHub authentication method (SSH key, Personal Access Token, or skip)
204235
```
205236

206-
This script will:
207-
1. Connect to your GPU server via SSH
208-
2. Clone or update the repository in `~/llm-stylometry`
209-
3. Start training in a `screen` session that persists after disconnection
210-
4. Allow you to safely disconnect while training continues
237+
**What this script does:** The `remote_train.sh` script connects to your GPU server via SSH and executes `run_llm_stylometry.sh --train -y` in a `screen` session. This allows you to disconnect your local machine while the GPU server continues training.
238+
239+
The script will:
240+
1. SSH into your GPU server
241+
2. Update the repository in `~/llm-stylometry` (or clone if it doesn't exist)
242+
3. Start `run_llm_stylometry.sh --train -y` in a `screen` session
243+
4. Exit, allowing your local machine to disconnect while training continues on the server
244+
245+
#### Monitoring training progress
246+
247+
To check on the training status, SSH into the server and reattach to the screen session:
211248

212-
To monitor training progress:
213249
```bash
250+
# From your local machine
214251
ssh username@server
215-
screen -r llm_training # Reattach to training session
216-
# Press Ctrl+A, then D to detach again
252+
253+
# On the server, reattach to see live training output
254+
screen -r llm_training
255+
256+
# To detach and leave training running, press Ctrl+A, then D
257+
# To exit SSH while keeping training running
258+
exit
217259
```
218260

219-
### Downloading Trained Models
261+
#### Downloading results after training completes
220262

221-
After training completes on a remote server, use `sync_models.sh` to download the models:
263+
Once training is complete, use `sync_models.sh` **from your local machine** to download the trained models and results:
222264

223265
```bash
224266
# Download trained models from server

remote_train.sh

Lines changed: 9 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,7 @@ else
3434
KILL_MODE=false
3535
fi
3636

37-
# Ask about GitHub authentication method first
38-
print_info "GitHub authentication options:"
39-
echo "1. SSH key (recommended if already set up on server)"
40-
echo "2. Personal Access Token (will prompt when needed)"
41-
echo "3. Skip repository update (use existing code on server)"
42-
read -p "Choose option [1-3]: " AUTH_OPTION
43-
44-
if [ "$AUTH_OPTION" = "2" ]; then
45-
echo
46-
print_warning "GitHub now requires Personal Access Tokens instead of passwords."
47-
print_info "Create one at: https://github.com/settings/tokens"
48-
print_info "Grant 'repo' scope for private repository access."
49-
echo
50-
read -p "Enter your GitHub username: " GH_USER
51-
read -s -p "Enter your GitHub Personal Access Token: " GH_TOKEN
52-
echo
53-
export GH_USER GH_TOKEN
54-
fi
55-
56-
# Now get server details
57-
echo
37+
# Get server details
5838
read -p "Enter GPU server address (hostname or IP): " SERVER_ADDRESS
5939
if [ -z "$SERVER_ADDRESS" ]; then
6040
print_error "Server address cannot be empty"
@@ -77,8 +57,7 @@ fi
7757
echo
7858

7959
# Execute the remote script via SSH
80-
# Pass variables as arguments to the remote bash
81-
ssh -t "$USERNAME@$SERVER_ADDRESS" "AUTH_OPTION='$AUTH_OPTION' GH_USER='$GH_USER' GH_TOKEN='$GH_TOKEN' KILL_MODE='$KILL_MODE' bash -s" << 'ENDSSH'
60+
ssh -t "$USERNAME@$SERVER_ADDRESS" "KILL_MODE='$KILL_MODE' bash -s" << 'ENDSSH'
8261
#!/bin/bash
8362
set -e
8463
@@ -110,96 +89,19 @@ if [ "$KILL_MODE" = "true" ]; then
11089
echo ""
11190
fi
11291
113-
# Handle different authentication options
114-
if [ "$AUTH_OPTION" = "3" ]; then
115-
echo "Skipping all repository operations as requested..."
116-
if [ ! -d ~/llm-stylometry ]; then
117-
echo "Error: Repository not found at ~/llm-stylometry"
118-
echo "Please choose option 1 or 2 to clone the repository first."
119-
exit 1
120-
fi
92+
# Check if repository exists
93+
if [ -d ~/llm-stylometry ]; then
94+
echo "Repository exists. Updating..."
12195
cd ~/llm-stylometry
122-
echo "Using existing repository without updates"
123-
else
124-
# Configure Git to use credential caching to avoid repeated auth prompts
125-
git config --global credential.helper cache
126-
git config --global credential.helper 'cache --timeout=3600'
127-
128-
# Set up GitHub token authentication if provided (only for option 2)
129-
if [ "$AUTH_OPTION" = "2" ] && [ -n "$GH_TOKEN" ] && [ -n "$GH_USER" ]; then
130-
echo "Setting up GitHub token authentication..."
131-
git config --global url."https://${GH_USER}:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
132-
fi
133-
134-
# Check if repo exists
135-
if [ -d ~/llm-stylometry ]; then
136-
echo "Repository exists. Updating to latest version..."
137-
cd ~/llm-stylometry
138-
139-
# Stash any local changes
140-
if ! git diff --quiet || ! git diff --cached --quiet; then
141-
echo "Stashing local changes..."
142-
git stash
143-
fi
144-
145-
# Determine authentication method
146-
if [ "$AUTH_OPTION" = "1" ]; then
147-
# Try SSH first for option 1
148-
if ssh -o BatchMode=yes -o ConnectTimeout=5 [email protected] 2>&1 | grep -q "successfully authenticated"; then
149-
echo "Using SSH authentication..."
150-
git remote set-url origin [email protected]:ContextLab/llm-stylometry.git
151-
else
152-
echo "SSH key not found or not authorized."
153-
echo "Please ensure your SSH key is added to GitHub and try again."
154-
exit 1
155-
fi
156-
elif [ "$AUTH_OPTION" = "2" ]; then
157-
# Use HTTPS with token for option 2
158-
echo "Using HTTPS with Personal Access Token..."
159-
git remote set-url origin https://github.com/ContextLab/llm-stylometry.git
160-
161-
if [ -z "$GH_TOKEN" ] || [ -z "$GH_USER" ]; then
162-
echo "GitHub credentials not provided. You'll be prompted during git operations."
163-
echo "Note: Use your Personal Access Token as the password."
164-
fi
165-
fi
166-
167-
# Update repository
168-
git fetch origin
169-
git checkout main
170-
git pull origin main
96+
git pull
17197
echo "Repository updated successfully"
17298
else
17399
echo "Repository not found. Cloning..."
174-
175-
if [ "$AUTH_OPTION" = "1" ]; then
176-
# Check if SSH key is available
177-
if ssh -o BatchMode=yes -o ConnectTimeout=5 [email protected] 2>&1 | grep -q "successfully authenticated"; then
178-
echo "Using SSH to clone repository..."
179-
cd ~
180-
git clone [email protected]:ContextLab/llm-stylometry.git
181-
else
182-
echo "SSH key not found or not authorized."
183-
echo "Please ensure your SSH key is added to GitHub and try again."
184-
exit 1
185-
fi
186-
elif [ "$AUTH_OPTION" = "2" ]; then
187-
echo "Using HTTPS to clone repository..."
188-
if [ -z "$GH_TOKEN" ] || [ -z "$GH_USER" ]; then
189-
echo "GitHub credentials not configured. You'll be prompted."
190-
echo "Username: Your GitHub username"
191-
echo "Password: Your Personal Access Token (NOT your GitHub password)"
192-
echo "Create a token at: https://github.com/settings/tokens"
193-
echo ""
194-
fi
195-
cd ~
196-
git clone https://github.com/ContextLab/llm-stylometry.git
197-
fi
198-
100+
cd ~
101+
git clone https://github.com/ContextLab/llm-stylometry.git
199102
cd ~/llm-stylometry
200103
echo "Repository cloned successfully"
201-
fi
202-
fi # End of AUTH_OPTION check
104+
fi
203105
204106
# Check for screen
205107
if ! command -v screen &> /dev/null; then

0 commit comments

Comments
 (0)