-
-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (77 loc) · 2.79 KB
/
notebooks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# This file is managed by 'repo_helper'. Don't edit it directly.
---
name: notebooks rerender
on:
push:
branches: ["master"]
jobs:
Run:
name: "notebooks"
runs-on: "ubuntu-latest"
steps:
- name: Checkout 🛎️
uses: "actions/checkout@v2"
- name: Setup Python 🐍
uses: "actions/setup-python@v2"
with:
python-version: "3.8"
- name: Install dependencies 🔧
run: |
sudo apt-get update
sudo apt-get install pandoc
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install nbformat nbconvert jupyter-client ipykernel domdf_python_tools
python -m pip install -r requirements.txt
python -m pip install .
- name: "Change to Notebooks branch"
run: git checkout -b Notebooks
- name: "Setup work dir"
run: |
git config --global user.email "[email protected]"
git config --global user.name "Dominic Davis-Foster"
working-directory: demo/jupyter
- name: Display structure of work dir
run: ls -R
working-directory: demo/jupyter
- name: "Render notebooks"
run: |
for file in *.ipynb; do
jupyter nbconvert --clear-output --inplace "$file"
jupyter nbconvert --to notebook --inplace --execute "$file"
done
working-directory: demo/jupyter
- name: "Regenerate reStructuredText files"
run: python3 notebook2rst.py
# TODO: regenerate scripts using notebook2script
- name: "Remove execution times"
working-directory: demo/jupyter
run: |
cat > remove_execution_times.py <<EOF
#!/usr/bin/env/python3
import json
from domdf_python_tools.paths import PathPlus
for filename in PathPlus.cwd().glob("*.ipynb"):
notebook = filename.load_json()
for cell in notebook["cells"]:
if "execution" in cell["metadata"]:
cell["metadata"]["execution"] = {}
if "pycharm" in cell["metadata"]:
del cell["metadata"]["pycharm"]
filename.write_clean(json.dumps(notebook, indent=1).replace("/home/runner/work/PyMassSpec-Plot/", ''))
EOF
python3 remove_execution_times.py
- name: "Stage, commit and push"
run: |
for file in demo/jupyter/*.ipynb; do
git stage "$file"
done
for file in doc-source/demo_rst/*.rst; do
git stage "$file"
done
for file in doc-source/examples/graphics/*.png; do
git stage "$file"
done
git commit -m "Re-rendered Jupyter Notebooks"
git push --set-upstream origin Notebooks --force