This guide covers the development workflow, automated cleanup system, and best practices for contributing to the Machine Learning Systems book.
./binder clean # Clean build artifacts
./binder build # Build HTML book
./binder doctor # Health check & diagnostics
./binder preview # Live preview with hot reload
./binder build pdf # Build PDF# First time setup
./binder setup # Configure environment and tools
# Daily workflow (most common commands)
./binder clean # Clean build artifacts
./binder build # Build HTML (complete book)
./binder doctor # Health check
# Preview & development
./binder preview intro # Preview a chapter with live reload
./binder build intro # Build specific chapterThis project includes an automated cleanup system that runs before every commit to ensure a clean repository.
The cleanup system removes:
- Build artifacts:
*.html,*.pdf,*.tex,*.aux,*.log,*.toc - Cache directories:
.quarto/,site_libs/,index_files/(legacy) - Python artifacts:
__pycache__/,*.pyc,*.pyo - System files:
.DS_Store,Thumbs.db,*.swp - Editor files:
*~,.#* - Debug files:
debug.log,error.log
# Regular cleanup (recommended before commits)
./binder clean
# See what files will be cleaned (safe preview)
git status
git clean -xdn
# Deep clean (removes all build artifacts)
./binder clean
git clean -xdfThe git pre-commit hook automatically:
- π Scans for build artifacts in staged files
- π§Ή Runs cleanup if artifacts are detected
β οΈ Warns about large files (>1MB)- π¨ Blocks commits with potential secrets
- β Allows clean commits to proceed
# Only if absolutely necessary
git commit --no-verify -m "Emergency commit"# Using binder (recommended)
./binder build html # Build HTML version
./binder build pdf # Build PDF version
./binder publish # Build and publish
# Using binder (recommended)
./binder build # HTML version
./binder build pdf # PDF version
./binder build epub # EPUB version# Preview a chapter (fastest)
./binder preview intro
# Build complete book
./binder build html
# Publish to the world
./binder publishThe ./binder setup command provides a complete environment configuration:
What it does:
- Checks environment - Verifies all required tools and versions
- Installs dependencies - Auto-installs missing tools (Quarto, GitHub CLI, release-note helpers)
- Configures Git - Sets up user name, email, and GitHub username
- Sets preferences - Configures build format and browser behavior
- Tests setup - Builds a test chapter to verify everything works
Features:
- π οΈ Automatic tool installation (Homebrew, apt, pip)
- π€ Interactive Git configuration
- βοΈ User preference setup
- π§ͺ Built-in testing to verify setup
# Run setup
./binder setup
# Get welcome and overview
./binder hello# Start live preview server
./binder preview
# The server will automatically reload when you save changes- HTML:
build/html/index.html(main output directory) - PDF:
build/pdf/(PDF output directory) - PDF:
book/index.pdf(in book directory) - Artifacts: Automatically cleaned by git hooks
The ./binder publish command provides a complete publishing workflow:
Step-by-step process:
- Environment validation - Checks Git status, tools, and dependencies
- Branch management - Merges
devtomainwith confirmation - Release planning - Suggests version bump based on changes
- Build process - PDF first, then HTML (ensures PDF availability)
- Release creation - Git tag, curated release notes, GitHub release
- Deployment - Copies PDF to assets, commits, pushes to production
Features:
- π Curated release notes
- π Smart version suggestions (patch/minor/major)
- π‘οΈ Safety checks and confirmations
- π― Step-by-step wizard with clear progress
# One-command publishing
./binder publishIf you prefer to do it step by step:
# 1. Ensure you're on main branch
git checkout main
git merge dev
# 2. Build both formats
./binder build html
./binder build pdf
# 3. Copy PDF to assets
cp build/pdf/Machine-Learning-Systems.pdf assets/
# 4. Commit and push
git add assets/downloads/Machine-Learning-Systems.pdf
git commit -m "Add PDF to assets"
git push origin main- β
Must be on
mainbranch - β No uncommitted changes
- β All builds successful
- β Git repository properly configured
The GitHub Actions workflow will:
- π Run quality checks
- ποΈ Build all formats (Linux + Windows)
- π Deploy to GitHub Pages
- π¦ Create release assets
Monitor progress: https://github.com/harvard-edge/cs249r_book/actions
./binder doctor # Overall project health
./binder status # Detailed project status
git status # Git repository status./binder doctor # Run comprehensive health check
quarto check # Validate Quarto configurationπ Checking project health...
π Project Structure:
QMD files: 45
Bibliography files: 20
Quiz files: 18
ποΈ Git Status:
Repository is clean
π¦ Dependencies:
β
Quarto: 1.4.x
β
Python: 3.x
book/contents/
βββ core/ # Main content chapters
β βββ introduction/
β β βββ introduction.qmd
β β βββ introduction.bib
β β βββ introduction_quizzes.json
β βββ ...
βββ frontmatter/ # Preface, about, etc.
βββ backmatter/ # References, appendices
βββ labs/ # Hands-on exercises
For faster development, you can work with a minimal set of chapters:
- Edit
book/_quarto-html.yml: Comment out chapters you're not working on - Edit bibliography section: Comment out unused
.bibfiles - Build faster: Only active chapters will be processed
chapters:
- index.qmd
- contents/core/introduction/introduction.qmd
# - contents/core/ml_systems/ml_systems.qmd # Commented out
# - contents/core/nn_computation/nn_computation.qmd # Commented outSimply uncomment the chapters and bibliography entries you want to restore.
-
Build fails with missing files
make clean # Clean artifacts make check # Verify structure
-
Git hook blocks commit
make clean # Remove artifacts git status # Check what's staged
-
Slow builds
make clean-deep # Full cleanup # Use minimal configuration
-
Permission denied on scripts
make setup-hooks # Fix permissions
./binder help # Show all commands
./binder --help # Detailed helpgit pull # Get latest changes
./binder clean # Clean workspace
./binder doctor # Verify health# 1. Clean and build
./binder clean
./binder build
# 2. Start development server
./binder preview
# 3. Make changes to .qmd files
# 4. Preview updates automatically
# 5. When ready to commit
git add . # Pre-commit hook runs automatically
git commit -m "Your message"./binder clean # Full cleanup
./binder build # Clean build
./binder doctor # Run all checks./binder doctor # Comprehensive validation
./binder build # Build HTML
./binder build pdf # Build PDF
./binder build epub # Build EPUBquarto/config/_quarto-html.yml: HTML website configurationquarto/config/_quarto-pdf.yml: PDF book configurationbinder: Book Binder CLI (build and development tool).git/hooks/pre-commit: Automated cleanup hook.gitignore: Ignored file patterns
The tools/scripts/ directory is organized into logical categories:
tools/scripts/
βββ build/ # Build and development scripts (clean.sh, etc.)
βββ content/ # Content management tools
βββ maintenance/ # System maintenance scripts
βββ testing/ # Test and validation scripts
βββ utilities/ # General utility scripts
βββ docs/ # Script documentation
βββ quizzes/ # Quiz generation pipeline
βββ cross_refs/ # Cross-reference management
βββ quarto_publish/ # Publishing workflows
βββ ai_menu/ # AI menu tools
Each directory has its own README.md with specific usage instructions.
- Fork and clone the repository
- Run setup:
make setup-hooks && make install - Make changes with the development workflow above
- Test thoroughly:
make test && make build-all - Submit pull request with clean commits
The automated cleanup system ensures that your commits will be clean and won't include build artifacts, making code reviews easier and keeping the repository tidy.
If you encounter issues with the development workflow:
- Check this guide first
- Run
make checkfor diagnostics - Review the cleanup script output with
make clean-dry - Ask for help in project discussions