mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-03-09 15:02:25 -05:00
- Add jupytext dependency to binder/requirements.txt - Update postBuild to convert src/*.py files to modules/*.ipynb - Document the notebook generation workflow in README.md This ensures Binder users get ready-to-use notebooks that are always in sync with the source Python files.
42 lines
1.3 KiB
Bash
Executable File
42 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Binder postBuild script
|
|
# This runs after the environment is set up to install TinyTorch
|
|
|
|
set -e
|
|
|
|
echo "🔧 Installing TinyTorch package..."
|
|
pip install -e .
|
|
|
|
echo ""
|
|
echo "📓 Generating student notebooks from source..."
|
|
# Convert all src/*.py files to notebooks in modules/
|
|
# This ensures students always get fresh notebooks matching the code
|
|
|
|
for module_dir in src/*/; do
|
|
module_name=$(basename "$module_dir")
|
|
py_file="$module_dir/${module_name}.py"
|
|
|
|
if [ -f "$py_file" ]; then
|
|
# Create output directory
|
|
mkdir -p "modules/$module_name"
|
|
|
|
# Convert .py to .ipynb using jupytext
|
|
echo " 📝 Converting $module_name..."
|
|
jupytext --to notebook "$py_file" --output "modules/$module_name/${module_name}.ipynb" 2>/dev/null || {
|
|
echo " ⚠️ Warning: Could not convert $module_name"
|
|
}
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "✅ TinyTorch setup complete!"
|
|
echo ""
|
|
echo "📚 Available resources:"
|
|
echo " - TinyTorch modules: modules/ (Jupyter notebooks)"
|
|
echo " - Source files: src/ (Python files)"
|
|
echo " - Milestone examples: milestones/"
|
|
echo ""
|
|
echo "🚀 Start exploring with:"
|
|
echo " - Open any notebook from modules/ in the file browser"
|
|
echo " - Or import tinytorch in a new notebook"
|