Files
Vijay Janapa Reddi 14ca66d2e9 Rename bindery/ to binder/ and run the CLI by its real path
The toolchain folder is now binder/, and the root ./binder symlink is gone.
The command is ./binder/binder: a plain path to the script, with no link and
no install step. Every invocation moved with it: pre-commit entries, workflow
steps, the VS Code extension's command palette, help text, and docs.

- bindery/ paths and bindery.* imports, including the chapter code cells
  that import binder.tools.figures, now name binder/.
- Binder (mybinder.org) reads its configuration from a root binder/ folder
  and refuses to build when binder/ and .binder/ both exist. .binder/postBuild
  and .binder/requirements.txt move into binder/, so the TinyTorch "Launch
  Binder" buttons keep working; binder/README.md records which file names the
  toolchain must not use there.
- contributors/projects.json still pointed the book's contributor record at
  publishing/; it now names binder/, where that .all-contributorsrc lives.
- The margin-figure reader-link audit report linked its 222 figures through
  the retired quarto/ tree; the links now resolve under books/.

The hooks reformatted hidden Python cells and trimmed whitespace in the
Volume II chapters whose figure imports this rename touches.

Checks: ./binder/binder check cli passes (contract and canonical hooks),
binder.tools.figures imports, and every workflow YAML file parses.

binder test suite, excluding the four modules that cannot import mlsysim
through the root symlink (fixed separately): 7 failed, 346 passed.

The GitHub repository variables BOOK_ROOT, BOOK_TOOLS, BOOK_DEPS, and
BOOK_DOCKER still name the retired book/ layout and must change when this
reaches origin.
2026-09-10 15:26:07 +02:00

79 lines
2.2 KiB
Python

import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
cli_path = str(ROOT / "binder")
if cli_path not in sys.path:
sys.path.insert(0, cli_path)
from cli.checks import footnote_caps
def _write_qmd(tmp_path: Path, body: str) -> Path:
path = tmp_path / "chapter.qmd"
path.write_text(body, encoding="utf-8")
return path
def test_sentence_case_bold_term_head_passes(tmp_path):
qmd = _write_qmd(
tmp_path,
"[^fn-arith-intensity]: **Arithmetic intensity**: Body.\n",
)
violations = footnote_caps.scan_file(qmd, set())
assert violations == []
def test_term_head_check_allows_protected_tokens(tmp_path):
qmd = _write_qmd(
tmp_path,
"\n".join(
[
"[^fn-grpc-inference]: **gRPC Inference**: Body.",
"[^fn-vllm-paging]: **vLLM Paging**: Body.",
"[^fn-nn-module-composition]: **nn.Module Composition**: Body.",
"[^fn-k-center-coverage]: **k-Center Algorithm**: Body.",
"[^fn-pj-mac-hierarchy]: **pJ/MAC Hierarchy**: Body.",
"[^fn-flop-rate]: **FLOP/s Throughput**: Body.",
"[^fn-math]: **$k$-Anonymity**: Body.",
"[^fn-code]: **`torch.compile` Guard**: Body.",
]
),
)
allowlist = {
"fn-grpc-inference",
"fn-vllm-paging",
"fn-nn-module-composition",
"fn-k-center-coverage",
"fn-pj-mac-hierarchy",
}
assert footnote_caps.scan_file(qmd, allowlist) == []
def test_allowlist_accepts_lowercase_brand_and_sentence_case_head(tmp_path):
qmd = _write_qmd(
tmp_path,
"[^fn-grpc-inference]: **gRPC service**: Body.\n",
)
violations = footnote_caps.scan_file(qmd, {"fn-grpc-inference"})
assert violations == []
def test_existing_lowercase_first_letter_check_still_fails(tmp_path):
qmd = _write_qmd(tmp_path, "[^fn-lower]: lowercase body.\n")
violations = footnote_caps.scan_file(qmd, set())
assert len(violations) == 1
assert violations[0].kind == "lowercase_first_letter"
assert (
footnote_caps.apply_fix(violations[0])
== "[^fn-lower]: Lowercase body."
)