mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2025-12-05 19:17:28 -06:00
fix: centralize path configuration for book/ restructure
- Add BOOK_ROOT, QUARTO_DIR, TOOLS_DIR, DEPS_DIR, DOCKER_DIR env vars to all workflows - Update path references to use centralized env vars - Fix requirements.txt to reference book/tools/dependencies - Fix pyproject.toml entry points: cli.main -> book.cli.main - Add __init__.py to book/ and book/tools/ for Python package support - Fix Dockerfile path casing (dockerfile -> Dockerfile) - Fix publish-live.yml relative path after cd This enables TinyTorch to coexist at repo root alongside book/ directory.
This commit is contained in:
10
.github/workflows/build-linux-container.yml
vendored
10
.github/workflows/build-linux-container.yml
vendored
@@ -85,6 +85,15 @@ on:
|
||||
- '.github/workflows/build-linux-container.yml'
|
||||
|
||||
env:
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
|
||||
# Container Registry Configuration (configurable via inputs)
|
||||
REGISTRY: ${{ (github.event_name == 'workflow_dispatch' && inputs.container_registry) || 'ghcr.io' }}
|
||||
IMAGE_NAME: ${{ github.repository }}/${{ (github.event_name == 'workflow_dispatch' && inputs.container_name) || 'quarto-linux' }}
|
||||
@@ -92,6 +101,7 @@ env:
|
||||
|
||||
# Container Build Configuration
|
||||
PLATFORM: linux/amd64
|
||||
# Note: DOCKERFILE_PATH uses literal path because it's evaluated before DOCKER_DIR
|
||||
DOCKERFILE_PATH: ./book/docker/linux/Dockerfile
|
||||
CONTEXT_PATH: .
|
||||
|
||||
|
||||
10
.github/workflows/build-windows-container.yml
vendored
10
.github/workflows/build-windows-container.yml
vendored
@@ -84,12 +84,22 @@ on:
|
||||
- '.github/workflows/build-windows-container.yml'
|
||||
|
||||
env:
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
|
||||
# Container Registry Configuration (configurable via inputs)
|
||||
REGISTRY: ${{ (github.event_name == 'workflow_dispatch' && inputs.container_registry) || 'ghcr.io' }}
|
||||
IMAGE_NAME: ${{ github.repository }}/${{ (github.event_name == 'workflow_dispatch' && inputs.container_name) || 'quarto-windows' }}
|
||||
CONTAINER_TAG: ${{ (github.event_name == 'workflow_dispatch' && inputs.container_tag) || 'latest' }}
|
||||
|
||||
# Container Build Configuration
|
||||
# Note: DOCKERFILE_PATH uses literal path because it's evaluated before DOCKER_DIR
|
||||
DOCKERFILE_PATH: ./book/docker/windows/Dockerfile
|
||||
CONTEXT_PATH: .
|
||||
|
||||
|
||||
13
.github/workflows/container-health-check.yml
vendored
13
.github/workflows/container-health-check.yml
vendored
@@ -55,6 +55,17 @@ on:
|
||||
|
||||
# Centralized Container Configuration - Single Source of Truth
|
||||
env:
|
||||
# ==========================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# ==========================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
DEPS_DIR: book/tools/dependencies
|
||||
|
||||
# Registry Configuration
|
||||
REGISTRY: ${{ inputs.container_registry || 'ghcr.io' }}
|
||||
CONTAINER_TAG: ${{ inputs.container_tag || 'latest' }}
|
||||
LINUX_CONTAINER_NAME: 'quarto-linux'
|
||||
@@ -84,7 +95,7 @@ jobs:
|
||||
env:
|
||||
CONTAINER_IMAGE: ${{ inputs.container_registry || 'ghcr.io' }}/${{ github.repository }}/${{ matrix.container_name }}:${{ inputs.container_tag || 'latest' }}
|
||||
PLATFORM: ${{ matrix.platform }}
|
||||
DOCKERFILE_PATH: ./book/docker/${{ matrix.platform }}/dockerfile
|
||||
DOCKERFILE_PATH: ./${{ env.DOCKER_DIR }}/${{ matrix.platform }}/Dockerfile
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout repository
|
||||
|
||||
10
.github/workflows/deploy-preview.yml
vendored
10
.github/workflows/deploy-preview.yml
vendored
@@ -2,6 +2,12 @@ name: '🛰️ Deploy (Dev) Preview'
|
||||
|
||||
env:
|
||||
ARTIFACT_NAME: dev-html-linux # The name of the artifact produced by the 'validate-dev' workflow
|
||||
# ==========================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# ==========================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
BOOK_ROOT: book
|
||||
TOOLS_DIR: book/tools
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -143,7 +149,7 @@ jobs:
|
||||
with:
|
||||
path: ./repo-scripts
|
||||
sparse-checkout: |
|
||||
book/tools/scripts/publish/modify_dev_announcement.py
|
||||
${{ env.TOOLS_DIR }}/scripts/publish/modify_dev_announcement.py
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: 🔧 Modify announcement for dev preview
|
||||
@@ -156,7 +162,7 @@ jobs:
|
||||
|
||||
echo "📝 Adding dev preview banner with commit info: $COMMIT_SHORT"
|
||||
|
||||
python3 ./repo-scripts/book/tools/scripts/publish/modify_dev_announcement.py \
|
||||
python3 ./repo-scripts/${{ env.TOOLS_DIR }}/scripts/publish/modify_dev_announcement.py \
|
||||
./preview-site \
|
||||
--verbose \
|
||||
--commit-hash "$COMMIT_HASH" \
|
||||
|
||||
6
.github/workflows/link-check.yml
vendored
6
.github/workflows/link-check.yml
vendored
@@ -1,5 +1,11 @@
|
||||
name: '🔗 Link Check'
|
||||
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION NOTE
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
# Input defaults use book/quarto/contents - update these if structure changes
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
|
||||
23
.github/workflows/publish-live.yml
vendored
23
.github/workflows/publish-live.yml
vendored
@@ -12,6 +12,16 @@ env:
|
||||
OLLAMA_RETRIES: "3" # Number of retries for Ollama calls
|
||||
BUILD_TIMEOUT: "3600" # Timeout for build operations (1 hour)
|
||||
|
||||
# ==========================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# ==========================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
DEPS_DIR: book/tools/dependencies
|
||||
|
||||
# Quarto Configuration Files
|
||||
QUARTO_HTML_CONFIG: "_quarto-html.yml" # HTML build configuration file
|
||||
QUARTO_PDF_CONFIG: "_quarto-pdf.yml" # PDF build configuration file
|
||||
@@ -438,10 +448,11 @@ jobs:
|
||||
run: |
|
||||
echo "📚 Validating Quarto project structure..."
|
||||
|
||||
cd book/quarto
|
||||
cd ${{ env.QUARTO_DIR }}
|
||||
|
||||
# Check critical files exist using environment variables
|
||||
REQUIRED_FILES=("${{ env.QUARTO_MAIN_CONFIG }}" "book/config/${{ env.QUARTO_HTML_CONFIG }}" "book/config/${{ env.QUARTO_PDF_CONFIG }}")
|
||||
# Note: paths are relative to ${{ env.QUARTO_DIR }}/ after the cd above
|
||||
REQUIRED_FILES=("${{ env.QUARTO_MAIN_CONFIG }}" "config/${{ env.QUARTO_HTML_CONFIG }}" "config/${{ env.QUARTO_PDF_CONFIG }}")
|
||||
for file in "${REQUIRED_FILES[@]}"; do
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "❌ Required file missing: $file"
|
||||
@@ -544,7 +555,7 @@ jobs:
|
||||
|
||||
- name: 📝 Update Version in index.qmd
|
||||
run: |
|
||||
echo "📝 Updating version number in book/quarto/index.qmd..."
|
||||
echo "📝 Updating version number in ${{ env.QUARTO_DIR }}/index.qmd..."
|
||||
echo "🎯 This automatically updates the version displayed on the website"
|
||||
echo "🔗 The version links to GitHub releases via assets/scripts/version-link.js"
|
||||
echo ""
|
||||
@@ -556,17 +567,17 @@ jobs:
|
||||
# Find and update the doi line with the new version
|
||||
# The doi field is repurposed to show version (with custom label "Version")
|
||||
# JavaScript makes it link to releases page instead of DOI registry
|
||||
sed -i "s|doi: \".*\"|doi: \"${{ needs.validate-inputs.outputs.new_version }}\"|g" book/quarto/index.qmd
|
||||
sed -i "s|doi: \".*\"|doi: \"${{ needs.validate-inputs.outputs.new_version }}\"|g" ${{ env.QUARTO_DIR }}/index.qmd
|
||||
|
||||
echo "✅ Version updated to ${{ needs.validate-inputs.outputs.new_version }}"
|
||||
echo "📄 Updated line:"
|
||||
cat book/quarto/index.qmd | grep "doi:" || echo "Could not verify doi field"
|
||||
cat ${{ env.QUARTO_DIR }}/index.qmd | grep "doi:" || echo "Could not verify doi field"
|
||||
|
||||
# Commit the version update
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add book/quarto/index.qmd
|
||||
git add ${{ env.QUARTO_DIR }}/index.qmd
|
||||
git commit -m "chore: update version to ${{ needs.validate-inputs.outputs.new_version }}" || echo "No changes to commit"
|
||||
git push origin dev
|
||||
|
||||
|
||||
54
.github/workflows/quarto-build-baremetal.yml
vendored
54
.github/workflows/quarto-build-baremetal.yml
vendored
@@ -147,6 +147,18 @@ permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
# These env vars can be used in workflow steps: ${{ env.BOOK_ROOT }}, etc.
|
||||
env:
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
DEPS_DIR: book/tools/dependencies
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: '${{ matrix.os_emoji }} Build ${{ matrix.os_name }} (${{ matrix.format_emoji }} ${{ matrix.format }})'
|
||||
@@ -504,7 +516,7 @@ jobs:
|
||||
path: |
|
||||
~/.cache/pip
|
||||
~\AppData\Local\pip\Cache
|
||||
key: python-pkgs-${{ runner.os }}-${{ hashFiles('book/tools/dependencies/requirements.txt') }}
|
||||
key: python-pkgs-${{ runner.os }}-${{ hashFiles(format('{0}/requirements.txt', env.DEPS_DIR)) }}
|
||||
restore-keys: |
|
||||
python-pkgs-${{ runner.os }}-
|
||||
|
||||
@@ -568,14 +580,14 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
|
||||
Write-Output "📦 Installing Python packages from requirements.txt..."
|
||||
python -m pip install -r book/tools/dependencies/requirements.txt
|
||||
python -m pip install -r ${{ env.DEPS_DIR }}/requirements.txt
|
||||
Write-Output "✅ Python dependencies installed"
|
||||
|
||||
- name: 📦 Install Python dependencies (Linux)
|
||||
if: matrix.enabled && runner.os == 'Linux'
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r book/tools/dependencies/requirements.txt
|
||||
python -m pip install -r ${{ env.DEPS_DIR }}/requirements.txt
|
||||
|
||||
# Cache Linux system packages without hardcoded paths
|
||||
- name: 💾 Cache APT packages
|
||||
@@ -708,8 +720,8 @@ jobs:
|
||||
Write-Output "✅ PATH updated with: $texLiveBin"
|
||||
|
||||
Write-Output "📋 Reading collections from tl_packages..."
|
||||
if (Test-Path 'book/tools/dependencies/tl_packages') {
|
||||
$collections = Get-Content 'book/tools/dependencies/tl_packages' |
|
||||
if (Test-Path '${{ env.DEPS_DIR }}/tl_packages') {
|
||||
$collections = Get-Content '${{ env.DEPS_DIR }}/tl_packages' |
|
||||
Where-Object { $_.Trim() -ne '' -and -not $_.Trim().StartsWith('#') }
|
||||
Write-Output "📦 Found $($collections.Count) collections to install"
|
||||
Write-Output "📋 Collections:"
|
||||
@@ -745,7 +757,7 @@ jobs:
|
||||
if: matrix.enabled && runner.os == 'Linux'
|
||||
uses: zauguin/install-texlive@v4
|
||||
with:
|
||||
package_file: book/tools/dependencies/tl_packages
|
||||
package_file: ${{ env.DEPS_DIR }}/tl_packages
|
||||
texlive_version: 2025
|
||||
cache_version: 1
|
||||
|
||||
@@ -845,7 +857,7 @@ jobs:
|
||||
with:
|
||||
path: |
|
||||
${{ env.R_LIBS_USER }}
|
||||
key: r-pkgs-${{ runner.os }}-${{ inputs.r-version }}-${{ hashFiles('book/tools/dependencies/install_packages.R', '**/*.qmd') }}
|
||||
key: r-pkgs-${{ runner.os }}-${{ inputs.r-version }}-${{ hashFiles(format('{0}/install_packages.R', env.DEPS_DIR), '**/*.qmd') }}
|
||||
restore-keys: |
|
||||
r-pkgs-${{ runner.os }}-${{ inputs.r-version }}-
|
||||
|
||||
@@ -873,11 +885,11 @@ jobs:
|
||||
install.packages("remotes")
|
||||
|
||||
# Install packages from install_packages.R
|
||||
if (file.exists("book/tools/dependencies/install_packages.R")) {
|
||||
cat("📦 Installing packages from book/tools/dependencies/install_packages.R...\n")
|
||||
source("book/tools/dependencies/install_packages.R")
|
||||
if (file.exists("${{ env.DEPS_DIR }}/install_packages.R")) {
|
||||
cat("📦 Installing packages from ${{ env.DEPS_DIR }}/install_packages.R...\n")
|
||||
source("${{ env.DEPS_DIR }}/install_packages.R")
|
||||
} else {
|
||||
cat("⚠️ No book/tools/dependencies/install_packages.R found, installing common packages\n")
|
||||
cat("⚠️ No ${{ env.DEPS_DIR }}/install_packages.R found, installing common packages\n")
|
||||
pkgs <- c("rmarkdown", "knitr", "tidyverse", "ggplot2", "bookdown")
|
||||
cat(paste("📦 Installing packages:", paste(pkgs, collapse=", "), "\n"))
|
||||
install.packages(pkgs)
|
||||
@@ -984,9 +996,9 @@ jobs:
|
||||
echo "🔍 DEBUG: Current directory: $(pwd)"
|
||||
echo "🔍 DEBUG: Listing repository root:"
|
||||
ls -la
|
||||
echo "🔍 DEBUG: Checking book/quarto exists:"
|
||||
ls -la book/quarto/ || echo "book/quarto not found!"
|
||||
cd book/quarto
|
||||
echo "🔍 DEBUG: Checking ${{ env.QUARTO_DIR }} exists:"
|
||||
ls -la ${{ env.QUARTO_DIR }}/ || echo "${{ env.QUARTO_DIR }} not found!"
|
||||
cd ${{ env.QUARTO_DIR }}
|
||||
echo "🔍 DEBUG: Now in $(pwd)"
|
||||
echo "🔍 DEBUG: Listing current directory:"
|
||||
ls -la
|
||||
@@ -1033,7 +1045,7 @@ jobs:
|
||||
run: |
|
||||
if [ -f "Machine-Learning-Systems.pdf" ]; then
|
||||
echo "📉 Compressing PDF with professional compression tool..."
|
||||
python3 ${{ github.workspace }}/book/quarto/publish/compress_pdf.py \
|
||||
python3 ${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_pdf.py \
|
||||
--input "Machine-Learning-Systems.pdf" \
|
||||
--output "compressed.pdf" \
|
||||
--quality minimal \
|
||||
@@ -1064,7 +1076,7 @@ jobs:
|
||||
|
||||
Write-Output "📉 Compressing PDF with professional compression tool..."
|
||||
|
||||
python ${{ github.workspace }}/book/quarto/publish/compress_pdf.py --input $input --output $output --quality minimal --verbose
|
||||
python ${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_pdf.py --input $input --output $output --quality minimal --verbose
|
||||
|
||||
if (Test-Path $output) {
|
||||
Write-Output "✅ PDF compression completed"
|
||||
@@ -1081,7 +1093,7 @@ jobs:
|
||||
echo "📚 Compressing EPUB with optimized compression tool..."
|
||||
echo "🔍 DEBUG: GITHUB_WORKSPACE=${{ github.workspace }}"
|
||||
echo "🔍 DEBUG: PWD=$(pwd)"
|
||||
echo "🔍 DEBUG: Script path: ${{ github.workspace }}/book/quarto/publish/compress_epub.py"
|
||||
echo "🔍 DEBUG: Script path: ${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_epub.py"
|
||||
echo "🔍 DEBUG: Verifying Python and Pillow installation:"
|
||||
python3 --version
|
||||
python3 -c "import sys; print('Python path:', sys.executable)"
|
||||
@@ -1091,12 +1103,12 @@ jobs:
|
||||
python3 -c "import PIL; print('✅ Pillow version (installed): ' + PIL.__version__)"
|
||||
fi
|
||||
echo "🔍 DEBUG: Checking quarto directory structure:"
|
||||
ls -la "${{ github.workspace }}/book/quarto/" || echo "❌ book/quarto/ not found"
|
||||
ls -la "${{ github.workspace }}/${{ env.QUARTO_DIR }}/" || echo "❌ ${{ env.QUARTO_DIR }}/ not found"
|
||||
echo "🔍 DEBUG: Checking for publish directory:"
|
||||
ls -la "${{ github.workspace }}/book/quarto/publish/" || echo "❌ book/quarto/publish/ not found"
|
||||
ls -la "${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/" || echo "❌ ${{ env.QUARTO_DIR }}/publish/ not found"
|
||||
echo "🔍 DEBUG: Repository root contents:"
|
||||
ls -la "${{ github.workspace }}/" | head -10
|
||||
python3 ${{ github.workspace }}/book/quarto/publish/compress_epub.py \
|
||||
python3 ${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_epub.py \
|
||||
--input "Machine-Learning-Systems.epub" \
|
||||
--output "compressed.epub" \
|
||||
--verbose
|
||||
@@ -1136,7 +1148,7 @@ jobs:
|
||||
python -c "import PIL; print('✅ Pillow version (installed): ' + PIL.__version__)"
|
||||
}
|
||||
|
||||
python ${{ github.workspace }}/book/quarto/publish/compress_epub.py --input $input --output $output --verbose
|
||||
python ${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_epub.py --input $input --output $output --verbose
|
||||
|
||||
if (Test-Path $output) {
|
||||
Write-Output "✅ EPUB compression completed (using optimized defaults: quality=50, max-size=1000px)"
|
||||
|
||||
28
.github/workflows/quarto-build-container.yml
vendored
28
.github/workflows/quarto-build-container.yml
vendored
@@ -111,6 +111,18 @@ permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
# These env vars can be used in workflow steps: ${{ env.BOOK_ROOT }}, etc.
|
||||
env:
|
||||
BOOK_ROOT: book
|
||||
DOCKER_DIR: book/docker
|
||||
TOOLS_DIR: book/tools
|
||||
QUARTO_DIR: book/quarto
|
||||
DEPS_DIR: book/tools/dependencies
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: '${{ matrix.platform_emoji }} Build ${{ matrix.platform_name }} (${{ matrix.format_emoji }} ${{ matrix.format_name }})'
|
||||
@@ -202,7 +214,7 @@ jobs:
|
||||
|
||||
env:
|
||||
CONTAINER_IMAGE: ${{ format('{0}/{1}/quarto-{2}:{3}', inputs.container_registry || 'ghcr.io', github.repository, matrix.platform, inputs.container_tag || 'latest') }}
|
||||
DOCKERFILE_PATH: ./book/docker/${{ matrix.platform }}/dockerfile
|
||||
DOCKERFILE_PATH: ./${{ env.DOCKER_DIR }}/${{ matrix.platform }}/Dockerfile
|
||||
|
||||
steps:
|
||||
- name: 🛑 Skip build
|
||||
@@ -243,7 +255,7 @@ jobs:
|
||||
|
||||
- name: 🔨 Build ${{ matrix.format_name }} (Linux)
|
||||
if: matrix.platform == 'linux' && matrix.enabled
|
||||
working-directory: book/quarto
|
||||
working-directory: ${{ env.QUARTO_DIR }}
|
||||
run: |
|
||||
echo "🔨 Building ${{ matrix.format_name }} on Linux container..."
|
||||
rm -f _quarto.yml
|
||||
@@ -265,7 +277,7 @@ jobs:
|
||||
|
||||
- name: 📉 Compress PDF (Linux)
|
||||
if: matrix.platform == 'linux' && matrix.format_name == 'PDF' && matrix.enabled
|
||||
working-directory: book/quarto/${{ matrix.output_dir }}
|
||||
working-directory: ${{ env.QUARTO_DIR }}/${{ matrix.output_dir }}
|
||||
run: |
|
||||
if [ -f "Machine-Learning-Systems.pdf" ]; then
|
||||
echo "📉 Compressing PDF with professional compression tool..."
|
||||
@@ -284,7 +296,7 @@ jobs:
|
||||
--verbose
|
||||
else
|
||||
# Fallback to absolute path via github.workspace
|
||||
SCRIPT_PATH="${{ github.workspace }}/book/quarto/publish/compress_pdf.py"
|
||||
SCRIPT_PATH="${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_pdf.py"
|
||||
echo "🔄 Trying fallback path: $SCRIPT_PATH"
|
||||
python3 "$SCRIPT_PATH" \
|
||||
--input "Machine-Learning-Systems.pdf" \
|
||||
@@ -338,7 +350,7 @@ jobs:
|
||||
|
||||
- name: 📚 Compress EPUB (Linux)
|
||||
if: matrix.platform == 'linux' && matrix.format_name == 'EPUB' && matrix.enabled
|
||||
working-directory: book/quarto/${{ matrix.output_dir }}
|
||||
working-directory: ${{ env.QUARTO_DIR }}/${{ matrix.output_dir }}
|
||||
run: |
|
||||
if [ -f "Machine-Learning-Systems.epub" ]; then
|
||||
echo "📚 Compressing EPUB with optimized compression tool..."
|
||||
@@ -348,7 +360,7 @@ jobs:
|
||||
echo "🔍 DEBUG: Checking for compress script:"
|
||||
ls -la ../../publish/compress_epub.py || echo "❌ Script not found at ../../publish/"
|
||||
echo "🔍 DEBUG: Checking fallback path:"
|
||||
ls -la "${{ github.workspace }}/book/quarto/publish/compress_epub.py" || echo "❌ Script not found at github.workspace path"
|
||||
ls -la "${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_epub.py" || echo "❌ Script not found at github.workspace path"
|
||||
|
||||
# Use relative path from current working directory (book/quarto/_build/epub)
|
||||
SCRIPT_PATH="../../publish/compress_epub.py"
|
||||
@@ -360,7 +372,7 @@ jobs:
|
||||
--verbose
|
||||
else
|
||||
# Fallback to absolute path via github.workspace
|
||||
SCRIPT_PATH="${{ github.workspace }}/book/quarto/publish/compress_epub.py"
|
||||
SCRIPT_PATH="${{ github.workspace }}/${{ env.QUARTO_DIR }}/publish/compress_epub.py"
|
||||
echo "🔄 Trying fallback path: $SCRIPT_PATH"
|
||||
python3 "$SCRIPT_PATH" \
|
||||
--input "Machine-Learning-Systems.epub" \
|
||||
@@ -416,7 +428,7 @@ jobs:
|
||||
if: matrix.enabled
|
||||
with:
|
||||
name: ${{ matrix.artifact_name }}
|
||||
path: book/quarto/${{ matrix.output_dir }}
|
||||
path: ${{ env.QUARTO_DIR }}/${{ matrix.output_dir }}
|
||||
|
||||
collect-outputs:
|
||||
name: '📊 Collect Outputs'
|
||||
|
||||
15
.github/workflows/update-contributors.yml
vendored
15
.github/workflows/update-contributors.yml
vendored
@@ -4,6 +4,15 @@ on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
# =============================================================================
|
||||
# PATH CONFIGURATION - Central location for all path references
|
||||
# =============================================================================
|
||||
# MLSysBook content lives under book/ to accommodate TinyTorch at root
|
||||
env:
|
||||
BOOK_ROOT: book
|
||||
QUARTO_DIR: book/quarto
|
||||
DEPS_DIR: book/tools/dependencies
|
||||
|
||||
jobs:
|
||||
update-contributors:
|
||||
name: Update Contributors List
|
||||
@@ -24,7 +33,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r book/tools/dependencies/requirements.txt
|
||||
pip install -r ${{ env.DEPS_DIR }}/requirements.txt
|
||||
pip install PyGithub>=1.55
|
||||
|
||||
- name: Configure Git
|
||||
@@ -43,7 +52,7 @@ jobs:
|
||||
- name: Check for changes
|
||||
id: update
|
||||
run: |
|
||||
if git status .all-contributorsrc README.md book/quarto/contents/frontmatter/acknowledgements/acknowledgements.qmd --porcelain | grep .; then
|
||||
if git status .all-contributorsrc README.md ${{ env.QUARTO_DIR }}/contents/frontmatter/acknowledgements/acknowledgements.qmd --porcelain | grep .; then
|
||||
echo "changes_made=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changes_made=false" >> $GITHUB_OUTPUT
|
||||
@@ -54,7 +63,7 @@ jobs:
|
||||
run: |
|
||||
BRANCH_NAME=${GITHUB_HEAD_REF:-$(git rev-parse --abbrev-ref HEAD)}
|
||||
|
||||
git add .all-contributorsrc README.md book/quarto/contents/frontmatter/acknowledgements/acknowledgements.qmd
|
||||
git add .all-contributorsrc README.md ${{ env.QUARTO_DIR }}/contents/frontmatter/acknowledgements/acknowledgements.qmd
|
||||
git commit -m "Update contributors list [skip ci]"
|
||||
git pull --rebase origin "$BRANCH_NAME"
|
||||
git push origin "$BRANCH_NAME"
|
||||
|
||||
3
book/__init__.py
Normal file
3
book/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# MLSysBook package
|
||||
# This directory contains the Machine Learning Systems textbook content
|
||||
|
||||
3
book/tools/__init__.py
Normal file
3
book/tools/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# MLSysBook Tools package
|
||||
# Scripts and utilities for building and maintaining the textbook
|
||||
|
||||
@@ -119,16 +119,16 @@ Issues = "https://github.com/mlsysbook/mlsysbook/issues"
|
||||
Changelog = "https://github.com/mlsysbook/mlsysbook/blob/main/CHANGELOG.md"
|
||||
|
||||
[project.scripts]
|
||||
binder = "cli.main:main"
|
||||
mlsysbook = "cli.main:main"
|
||||
binder = "book.cli.main:main"
|
||||
mlsysbook = "book.cli.main:main"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["tools*", "cli*"]
|
||||
include = ["book*", "book.tools*", "book.cli*"]
|
||||
exclude = ["tests*", "docs*"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"tools.scripts" = ["**/*.yaml", "**/*.yml", "**/*.json", "**/*.txt", "**/*.md"]
|
||||
"book.tools.scripts" = ["**/*.yaml", "**/*.yml", "**/*.json", "**/*.txt", "**/*.md"]
|
||||
|
||||
# Black formatting configuration
|
||||
[tool.black]
|
||||
@@ -163,8 +163,8 @@ include_trailing_comma = true
|
||||
force_grid_wrap = 0
|
||||
use_parentheses = true
|
||||
ensure_newline_before_comments = true
|
||||
src_paths = ["tools"]
|
||||
skip_glob = ["contents/*", "quarto/*"]
|
||||
src_paths = ["book/tools"]
|
||||
skip_glob = ["book/quarto/contents/*", "book/quarto/*"]
|
||||
|
||||
# MyPy type checking configuration
|
||||
[tool.mypy]
|
||||
@@ -199,12 +199,12 @@ minversion = "7.0"
|
||||
addopts = [
|
||||
"--strict-markers",
|
||||
"--strict-config",
|
||||
"--cov=tools",
|
||||
"--cov=book/tools",
|
||||
"--cov-report=term-missing",
|
||||
"--cov-report=html",
|
||||
"--cov-fail-under=80"
|
||||
]
|
||||
testpaths = ["tests"]
|
||||
testpaths = ["tests", "book/tests"]
|
||||
python_files = ["test_*.py", "*_test.py"]
|
||||
python_classes = ["Test*"]
|
||||
python_functions = ["test_*"]
|
||||
@@ -217,7 +217,7 @@ markers = [
|
||||
|
||||
# Coverage configuration
|
||||
[tool.coverage.run]
|
||||
source = ["tools"]
|
||||
source = ["book/tools"]
|
||||
branch = true
|
||||
omit = [
|
||||
"*/tests/*",
|
||||
@@ -260,7 +260,7 @@ max-statements = 60
|
||||
|
||||
# Bandit security linting
|
||||
[tool.bandit]
|
||||
exclude_dirs = ["tests", "contents", "quarto"]
|
||||
exclude_dirs = ["tests", "book/quarto/contents", "book/quarto"]
|
||||
skips = ["B101", "B601"] # Skip assert_used and shell=True (sometimes needed)
|
||||
|
||||
# Flake8 configuration (in setup.cfg or .flake8 file)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# For development work including Book Binder CLI:
|
||||
# pip install -r requirements.txt
|
||||
#
|
||||
# Main dependencies are maintained in tools/dependencies/requirements.txt
|
||||
# Main dependencies are maintained in book/tools/dependencies/requirements.txt
|
||||
# (MLSysBook content is now under book/ to accommodate TinyTorch at root)
|
||||
|
||||
-r tools/dependencies/requirements.txt
|
||||
-r book/tools/dependencies/requirements.txt
|
||||
Reference in New Issue
Block a user