#!/bin/bash set -e # Find all staged .ipynb files NOTEBOOKS=$(git diff --cached --name-only --diff-filter=ACM | grep '\.ipynb$' || true) if [ -z "$NOTEBOOKS" ]; then echo "No Jupyter notebooks staged. Skipping Jupytext conversion." exit 0 fi echo "Converting staged Jupyter notebooks to .py (percent format)..." # Loop through each notebook and convert for nb in $NOTEBOOKS; do if [ -f "$nb" ]; then echo " - Converting $nb" jupytext --to py:percent "$nb" pyfile="${nb%.ipynb}.py" # Stage the generated .py file git add "$pyfile" fi done echo "✅ Jupytext conversion complete."