mirror of
https://github.com/marvinscham/masterthesis-playground.git
synced 2025-12-06 18:20:53 +01:00
26 lines
641 B
Bash
26 lines
641 B
Bash
#!/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."
|