Skip to content

Commit a1432e6

Browse files
committed
Add script to update notebook output
1 parent b0ba302 commit a1432e6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.internal/update_notebooks.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
#
4+
# 1) Initialization - `git pull` + create-new-branch
5+
#
6+
echo "======= Init ======="
7+
cd "$(git rev-parse --show-toplevel)"
8+
9+
git checkout main
10+
git pull
11+
12+
echo
13+
git checkout -b "my_pr_$(date '+%Y.%m.%d_%H.%M')"
14+
echo
15+
16+
echo "Updating pip"
17+
python -m pip install -U -r requirements.txt -r requirements_tests.txt
18+
19+
#
20+
# 2) Update the notebooks
21+
#
22+
echo
23+
echo
24+
echo "======= Updating notebooks ======="
25+
# test all bernstein-vazirani notebooks
26+
find . -type f -name "*bernstein*.ipynb" | xargs -P2 -I{} jupyter nbconvert --to notebook --execute --inplace {}
27+
# # test all algorithms
28+
# find algorithms/ -type f -name "*.ipynb" | xargs -P8 -I{} jupyter nbconvert --to notebook --execute --inplace {}
29+
# # test 3 notebooks
30+
# find . -type f -name "*.ipynb" | head -n 3 | xargs -P8 -I{} jupyter nbconvert --to notebook --execute --inplace {}
31+
# # test all notebooks
32+
# find algorithms applications tutorials -type f -name "*.ipynb" | xargs -P8 -I{} jupyter nbconvert --to notebook --execute --inplace {}
33+
34+
#
35+
# 3) Commit the changes + open PR
36+
#
37+
echo
38+
echo
39+
echo "======= Creating PR ======="
40+
# running twice so that we'd include the pre-commit updates
41+
git commit -a -m "Updating notebooks output" || git commit -a -m "Updating notebooks output"
42+
# # running once, so that failure on pre-commit would fail this script
43+
# git commit -a -m "Updating notebooks output" || echo "pre-commit failed. please fix manually"
44+
45+
gh pr create --fill
46+
gh pr view --web

0 commit comments

Comments
 (0)