Skip to content

Commit bae18df

Browse files
authored
update workflow + pyproject tut dependencies (#531)
1 parent f48da47 commit bae18df

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

.github/workflows/tutorial_exporter.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- 'tutorials/**/*.ipynb'
1111

1212
jobs:
13+
# run on push
14+
export_tutorials_on_push:
15+
if: ${{ github.event_name == 'push' }}
1316
export_tutorials:
1417
permissions: write-all
1518
runs-on: ubuntu-latest
@@ -41,6 +44,9 @@ jobs:
4144
git config user.name "github-actions[bot]"
4245
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
4346
47+
- name: Run formatter
48+
run: black tutorials/
49+
4450
- name: Export tutorials to .py and .html
4551
run: |
4652
set -x
@@ -56,9 +62,67 @@ jobs:
5662
done
5763
set +x
5864
65+
- uses: benjlevesque/[email protected]
66+
id: short-sha
67+
68+
- name: Remove unwanted files
69+
run: |
70+
rm -rf build/ tutorials/tutorial4/data/
71+
72+
- name: Create Pull Request
73+
uses: peter-evans/[email protected]
74+
with:
75+
labels: maintenance
76+
title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }}
77+
branch: export-tutorial-${{ steps.short-sha.outputs.sha }}
78+
base: ${{ github.head_ref }}
79+
commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }}
80+
delete-branch: true
81+
82+
# run on workflow_dispatch
83+
export_tutorials_workflow_dispatch:
84+
if: ${{ github.event_name == 'workflow_dispatch' }}
85+
permissions: write-all
86+
runs-on: ubuntu-latest
87+
env:
88+
TUTORIAL_TIMEOUT: 1200s
89+
steps:
90+
- uses: actions/checkout@v4
91+
92+
- name: Set up Python
93+
uses: actions/setup-python@v5
94+
with:
95+
python-version: 3.8
96+
97+
- name: Install dependencies
98+
run: |
99+
python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
100+
101+
- name: Setup FFmpeg
102+
uses: FedericoCarboni/setup-ffmpeg@v2
103+
104+
- name: Configure git
105+
run: |
106+
git config user.name "github-actions[bot]"
107+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
108+
59109
- name: Run formatter
60110
run: black tutorials/
61111

112+
- name: Export all tutorials to .py and .html
113+
run: |
114+
set -x
115+
# Find all .ipynb files in the tutorials directory
116+
for file in $(find tutorials -type f -name "*.ipynb"); do
117+
filename=$(basename $file)
118+
pyfilename="${filename%.ipynb}.py"
119+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
120+
htmlfilename="${filename%.ipynb}.html"
121+
htmldir="docs/source"/$(dirname $file)
122+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
123+
done
124+
set +x
125+
62126
- uses: benjlevesque/[email protected]
63127
id: short-sha
64128

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dev = [
3939
]
4040
tutorial = [
4141
"jupyter",
42-
"smithers",
42+
"smithers @ git+https://github.com/mathLab/smithers.git",
4343
"torchvision",
4444
"tensorboard",
4545
"scipy",

0 commit comments

Comments
 (0)