Skip to content

Conversation

@jeremymanning
Copy link
Member

Summary

  • Simplified remote_train.sh by removing GitHub authentication logic
  • Added comprehensive Git credential setup instructions to README
  • Improved documentation clarity for remote training workflow

Changes

  • Removed GitHub authentication prompts from remote_train.sh
  • Script now assumes git credentials are pre-configured on server
  • Simplified repository management: just git pull if exists, else clone
  • Added -y flag support to run_llm_stylometry.sh for non-interactive mode
  • Updated README with:
    • Git credential setup instructions
    • Clear explanation that remote_train.sh runs FROM local machine
    • Complete workflow from setup to downloading results

Test plan

  • Tested remote training script on GPU server
  • Verified screen sessions persist after disconnect
  • Confirmed sync_models.sh downloads results correctly
  • No credentials in commit history

🤖 Generated with Claude Code

jeremymanning and others added 19 commits September 17, 2025 13:32
- Remove problematic eval statement that caused syntax errors
- Replace bash array with simple space-separated list in loop
- Use temporary file and line-by-line parsing instead of eval
- Fixes: './sync_models.sh: eval: line 100: syntax error near unexpected token'

The issue was that bash arrays in the heredoc were causing problems
when eval'd. Now uses a simpler approach that's more portable.
remote_train.sh:
- Fixed 'command not found' error by reorganizing SSH execution
- Moved SSH command with heredoc to proper location
- Removed duplicate SSH execution that caused issues
- Fixed variable escaping in screen command

sync_models.sh:
- Fixed syntax error with bash arrays in eval statement
- Replaced eval with safer line-by-line parsing
- Use simple loops instead of bash arrays for portability

Both scripts now properly execute on remote servers without syntax errors.
- Added menu to choose authentication method (SSH, token, or skip)
- Support GitHub Personal Access Tokens for private repo access
- Automatically detect and use SSH if keys are configured
- Option to skip repo update and use existing code
- Configure Git credential caching to avoid repeated prompts
- Pass credentials securely through SSH session

Users can now:
1. Use SSH keys (if already configured on server)
2. Enter GitHub PAT for HTTPS authentication
3. Skip repo operations if code already exists

Fixes authentication issues with private repositories.
- Added --no-confirm/-y flag to generate_figures.py to skip prompts
- Updated remote_train.sh to use --no-confirm flag in screen session
- Directly call generate_figures.py instead of wrapper script in remote mode

The training was getting stuck at 'Proceed with training? [y/N]' because
screen sessions run non-interactively and can't receive keyboard input.

Now training will automatically proceed when run via remote_train.sh.
- Added --kill (-k) flag to terminate existing training sessions
- Kills both screen sessions and python training processes
- Prompts user to optionally start new training after cleanup
- Updated README with documentation for the new flag
- Helps prevent accumulation of hanging training processes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Prompt for GitHub authentication method first
- Then prompt for SSH server details (address and username)
- This keeps SSH username and password prompts contiguous
- Avoids interrupting SSH auth flow with GitHub prompts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed incorrect SSH environment variable syntax
- Variables now passed correctly within heredoc
- Added SSH connection test with timeout before main execution
- Improved error handling for connection failures

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Use quoted heredoc ('ENDSSH') in remote_train.sh to prevent local expansion
- Pass environment variables explicitly to remote shell
- Fix $HOME expansion in sync_models.sh SSH/rsync commands
- Ensures scripts use remote user's home directory, not local

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create temporary script file to avoid variable expansion issues
- Use tilde notation for paths in quoted heredoc
- Fix LOG_FILE variable handling for remote execution
- Remove leftover code from screen command
- Screen session now properly starts with conda activation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Escape variables with \$ in quoted heredoc so they're evaluated remotely
- Replace $HOME with ~ throughout for proper remote expansion
- Fix AUTH_OPTION, KILL_MODE, GH_USER, GH_TOKEN variable references
- Resolves bash syntax error from improper variable expansion

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Option 3 now completely skips all Git operations (no fetch/pull)
- Option 1 requires SSH key and fails gracefully if not available
- Option 2 properly uses Personal Access Token if provided
- Clear separation of authentication methods for each option
- Better user guidance for GitHub credentials

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove backslashes from environment variable references
- Variables passed via SSH are now properly evaluated
- AUTH_OPTION, KILL_MODE, GH_USER, GH_TOKEN now expand correctly
- Fixes option 3 to actually skip repository operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove backslash from $(date) command substitution
- Fix LOG_FILE variable reference
- Resolves bash syntax error from escaped command substitution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove escaped variables in TRAINSCRIPT heredoc
- Variables like $LOG_FILE, $(date), $(conda info) now expand correctly
- Fixes screen session not starting due to script syntax errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Check if /tmp/llm_train.sh is created and executable
- Display first 10 lines of the script for verification
- Capture screen command exit code
- Check for running processes
- Test direct script execution to reveal errors
- Add timeout to prevent hanging during debug

This will help identify why screen sessions aren't persisting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Changed remote_train.sh to use ./run_llm_stylometry.sh instead of Python directly
- Simplified training script since run_llm_stylometry.sh handles environment setup
- Screen sessions now start successfully
- Added .test_credentials to .gitignore for future testing

The issue was that Python wasn't directly available, but run_llm_stylometry.sh
handles all the environment setup internally.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove interactive prompt in --kill mode (doesn't work over SSH)
- Always start new training after killing old sessions
- Add error checking for run_llm_stylometry.sh existence
- Ensure script is executable before running
- Add better logging to debug issues
- Use 'set -e' to exit on any error

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Accept -y, --yes, --no-confirm flags for non-interactive mode
- Pass --no-confirm to Python script when flag is provided
- Update help text to document the new flag
- Fixes screen session issues in remote_train.sh

The remote script now correctly uses the -y flag to run training
in non-interactive mode, preventing screen sessions from dying.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
@jeremymanning jeremymanning merged commit f945450 into ContextLab:main Sep 18, 2025
jeremymanning referenced this pull request in jeremymanning/llm-stylometry Oct 20, 2025
Simplify remote training and improve documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant