book/docs/BINDER.md
The Book Binder is a self-contained, lightning-fast development CLI for the MLSysBook project. It provides streamlined commands for building, previewing, and managing the book in both HTML and PDF formats.
Binder is the public automation interface for this repository.
./binder ... commands in local workflows, CI, and editor integrations.book/tools/scripts/ are internal implementation details.# First time setup
./binder setup
# Welcome and overview
./binder hello
# Build a single chapter (HTML)
./binder build intro
# Build multiple chapters together (HTML)
./binder build intro,ml_systems
# Preview a chapter (builds and opens in browser)
./binder preview intro
# Build the complete book (HTML)
./binder build
# Build the complete book (PDF)
./binder build pdf
# Build a single chapter (PDF) - SELECTIVE BUILD
./binder build pdf intro
# ↳ Automatically comments out all chapters except index.qmd and introduction.qmd
# Publish the book
./binder publish
# Get help
./binder help
# Run native validation suite
./binder validate all
# Run maintenance namespace
./binder maintain repo-health
The binder is a Python script located in the project root. Make sure it's executable:
chmod +x binder
Dependencies: Python 3.6+ (uses only standard library modules)
Intuitive commands that work on both individual chapters and the entire book.
| Command | Description | Example |
|---|---|---|
build [chapter[,ch2,...]] | Build book or chapter(s) in HTML | ./binder build intro,ml_systems |
preview [chapter[,ch2,...]] | Preview book or chapter(s) | ./binder preview ops |
build pdf [chapter[,ch2,...]] | Build book or chapter(s) in PDF | ./binder build pdf intro |
Smart defaults: No target = entire book, with target = specific chapter(s)
| Command | Description | Example |
|---|---|---|
build | Build complete book (HTML) | ./binder build |
preview | Preview complete book | ./binder preview |
build pdf | Build complete book (PDF) | ./binder build pdf |
publish | Build and publish book | ./binder publish |
| Command | Description | Example |
|---|---|---|
validate <subcommand> | Run Binder-native validation checks | ./binder validate inline-refs |
maintain <topic> ... | Run Binder-native maintenance utilities | ./binder maintain glossary build |
setup | Configure environment | ./binder setup |
clean | Clean configs & artifacts | ./binder clean |
switch <format> | Switch active config | ./binder switch pdf |
status | Show current status | ./binder status |
list | List available chapters | ./binder list |
doctor | Run comprehensive health check | ./binder doctor |
about | Show project information | ./binder about |
help | Show help information | ./binder help |
Use Binder-native checks instead of direct script calls:
./binder validate inline-python./binder validate refs./binder validate citations./binder validate references — validate .bib entries vs academic DBs (hallucinator; install: pip install -e ".[reference-check]" or pip install -r book/tools/dependencies/requirements.txt)
-f BIB / --file BIB — .bib file(s) to check (can repeat)-o FILE / --output FILE — write report to FILE--limit N — check only first N refs (quick test)./binder validate duplicate-labels./binder validate unreferenced-labels./binder validate inline-refs./binder validate allMachine-readable output is available for editor/CI integration:
./binder validate all --json
Exit semantics:
0 success (no issues)1 validation failures or command failure./binder maintain glossary build [--vol1|--vol2]./binder maintain images compress [-f <file> ... | --all] [--smart-compression] [--apply]./binder maintain repo-health [--json] [--min-size-mb N]All commands have convenient shortcuts:
| Shortcut | Command |
|---|---|
b | build |
p | preview |
pdf | build pdf |
epub | build epub |
l | list |
s | status |
d | doctor |
h | help |
Chapters can be referenced by their short names. Common examples:
intro → Introduction chapterml_systems → Machine Learning Systems chapternn_computation → Neural Computation chaptertraining → Training chapterops → MLOps chapterUse ./binder list to see all available chapters.
| Format | Output Location | Description |
|---|---|---|
| HTML | build/html/ | Website format with navigation |
build/pdf/ | Academic book format |
The publish command provides two modes based on how you call it:
When called without arguments, publish runs the interactive wizard:
# Interactive publishing wizard
./binder publish
What interactive mode does:
When called with arguments, publish triggers the GitHub Actions workflow directly:
# Trigger GitHub Actions workflow
./binder publish "Description" [COMMIT_HASH]
# With options
./binder publish "Add new chapter" abc123def --type patch --no-ai
What command-line mode does:
Options:
--type patch|minor|major - Release type (default: minor)--no-ai - Disable AI release notes--yes - Skip confirmation promptsRequirements:
gh auth login)# Development workflow
./binder preview intro # Preview a chapter
./binder build # Build complete HTML
./binder build pdf # Build complete PDF
./binder publish # Publish to the world
main branchThe binder supports building multiple chapters together in a single Quarto render command:
# Build multiple chapters together (HTML)
./binder build intro,ml_systems
# Build multiple chapters together (PDF)
./binder build pdf intro,ml_systems
# Preview multiple chapters together
./binder preview intro,ml_systems
Benefits:
Fast builds use selective rendering to only build essential files plus target chapters:
HTML Fast Build (project.render):
render:
- index.qmd
- 404.qmd
- contents/frontmatter/
- contents/core/target-chapter.qmd
PDF Fast Build (comments out unused chapters):
chapters:
- index.qmd
- contents/frontmatter/foreword.qmd
- contents/core/target-chapter.qmd
# - contents/core/other-chapter.qmd # Commented for fast build
When you run ./binder build pdf intro, the system automatically:
index.qmd (always included)contents/core/introduction/introduction.qmd (target chapter)contents/backmatter/glossary/glossary.qmd (commented out)contents/backmatter/references.qmd (commented out)Example output:
./binder build pdf intro
📄 Building chapter(s) as PDF: intro
🚀 Building 1 chapters (pdf)
⚡ Setting up fast build mode...
📋 Files to build: 2 files
✓ - index.qmd
✓ - contents/core/introduction/introduction.qmd
✓ Fast build mode configured (PDF/EPUB)
This ensures that in Binder environments, you get exactly what you need: a PDF containing only the index and your target chapter, with all other chapters automatically commented out during the build process.
The selective PDF build system works seamlessly in cloud environments like mybinder.org:
For cloud Binder users:
# In a Jupyter terminal or notebook cell
!./binder build pdf intro
# Or using the Python CLI directly
!python binder build pdf intro
Key benefits for cloud environments:
What gets built:
index.qmd for proper book structureintroduction.qmd)The binder automatically manages Quarto configurations:
_quarto-html.yml: Website build configuration_quarto-pdf.yml: Academic PDF build configuration_quarto.yml: Symlink to active configuration (currently → config/_quarto-html.yml)Important: The _quarto.yml file is a symlink that points to the active configuration. This allows the binder to quickly switch between HTML and PDF build modes without copying files.
Quarto Executable: The system quarto executable (/Applications/quarto/bin/quarto) is NOT a symlink - it's a regular executable file.
Use ./binder switch <format> to change the active configuration symlink.
# 1. Start development on a chapter
./binder preview intro
# 2. Make edits, save files (auto-rebuild in preview mode)
# 3. Build multiple related chapters together
./binder build intro,ml_systems html
# 4. Check full book before committing
./binder build * pdf
# Clean up any build artifacts
./binder clean
# Run health check
./binder doctor
# Build full book to ensure everything works
./binder build
./binder build pdf
"Chapter not found"
./binder list to see available chapters"Build artifacts detected"
./binder clean to remove temporary files./binder doctor to verify system health"Config not clean"
./binder clean to restore normal configuration"Symlink issues"
_quarto.yml is not a symlink: ln -sf config/_quarto-html.yml book/_quarto.ymlls -la book/_quarto.ymlconfig/_quarto-html.yml or config/_quarto-pdf.yml./binder build chapter html) for development./binder build ch1,ch2 html) for multiple chapters./binder build * format) for final verificationThe publish command provides a complete publishing workflow:
# One-command publishing
./binder publish
What it does:
dev to main with confirmationFeatures:
For more details, see: