-
Notifications
You must be signed in to change notification settings - Fork 20
97 lines (84 loc) · 3.07 KB
/
Copy pathexecute_notebooks.yml
File metadata and controls
97 lines (84 loc) · 3.07 KB
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
97
# .github/workflows/execute-notebooks.yml
name: Execute Notebooks
on:
push:
branches: [ main ]
paths:
- 'docs/Data Formatting/*ipynb'
- 'docs/*ipynb'
- '.github/workflows/execute_notebooks.yml'
pull_request:
branches: [ main ]
paths:
- 'docs/Data Formatting/*ipynb'
- 'docs/*ipynb'
- '.github/workflows/execute_notebooks.yml'
workflow_dispatch: # Allow manual trigger
# Cancel in-progress runs when a new push is made to the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
execute-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
# Install system dependencies
sudo apt update
sudo apt install pandoc
# Install Python dependencies
python -m pip install --upgrade pip
pip install jupyter nbconvert nbformat
pip install -r requirements.txt
pip install ipykernel rdkit cairosvg pymzml
pip install .
- name: Configure git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Find and execute notebooks
run: |
# Find all notebooks that need to execute (adjust paths as needed)
find "docs/Data Formatting/" -name "*.ipynb" > notebooks_to_execute.txt
echo "docs/Getting Started.ipynb" >> notebooks_to_execute.txt
echo "Found notebooks:"
cat notebooks_to_execute.txt
# Execute each notebook
while IFS= read -r notebook; do
echo "Executing: $notebook"
# Clear outputs first (optional)
jupyter nbconvert --clear-output --inplace "$notebook"
# Execute notebook
jupyter nbconvert --execute --to notebook --inplace "$notebook" \
--ExecutePreprocessor.timeout=300 \
--ExecutePreprocessor.kernel_name=python3
# Check if execution was successful
if [ $? -eq 0 ]; then
echo "✓ Successfully executed: $notebook"
else
echo "✗ Failed to execute: $notebook"
exit 1
fi
done < notebooks_to_execute.txt
- name: Push changes
if: steps.verify-changed-files.outputs.changed == 'true' && github.event_name != 'pull_request'
run: |
git push origin ${{ github.ref_name }}
- name: Summary
run: |
if [ "${{ steps.verify-changed-files.outputs.changed }}" == "true" ]; then
echo "✅ Notebooks executed successfully and changes committed"
else
echo "✅ Notebooks executed successfully, no changes to commit"
fi