Skip to content

Commit 1b10389

Browse files
committed
adding tutorials workflow + update toml
1 parent 9175251 commit 1b10389

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

.github/workflows/tutorial.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Export tutorials"
2+
3+
on:
4+
push:
5+
branches:
6+
- "**" # Run on push on all branches
7+
paths:
8+
- 'tutorials/**/*.ipynb'
9+
10+
jobs:
11+
export_tutorials:
12+
permissions: write-all
13+
runs-on: ubuntu-latest
14+
env:
15+
TUTORIAL_TIMEOUT: 1200s
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.8
23+
24+
- name: Install dependencies
25+
run: |
26+
# Dependencies for tutorials
27+
python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
28+
29+
- name: Setup FFmpeg
30+
uses: FedericoCarboni/setup-ffmpeg@v2
31+
32+
- id: files
33+
uses: jitterbit/get-changed-files@v1
34+
35+
- name: Configure git
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
39+
40+
- name: Export tutorials to .py and RST
41+
run: |
42+
set -x
43+
for file in ${{ steps.files.outputs.all }}; do
44+
if [[ $file == *.ipynb ]]; then
45+
filename=$(basename $file)
46+
47+
pyfilename=$(echo ${filename%?????})py
48+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to python --output $pyfilename
49+
50+
rstfilename=$(echo ${filename%?????} | sed -e 's/-//g')rst
51+
output_dir="docs/source/_rst/_tutorials"
52+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to rst --output $rstfilename --output-dir=$output_dir/$(dirname $file | sed 's|tutorials/||')
53+
fi
54+
done
55+
set +x
56+
57+
- name: Run formatter
58+
run: black tutorials/
59+
60+
- uses: benjlevesque/[email protected]
61+
id: short-sha
62+
63+
- name: Remove unwanted files
64+
run: |
65+
rm -rf build/
66+
67+
- name: Create Pull Request
68+
uses: peter-evans/[email protected]
69+
with:
70+
labels: maintenance
71+
title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }}
72+
branch: export-tutorial-${{ steps.short-sha.outputs.sha }}
73+
commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }}
74+
delete-branch: true

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
requires-python = ">=3.8"
2323

2424
[project.optional-dependencies]
25-
docs = [
25+
doc = [
2626
"sphinx>5.0",
2727
"sphinx_rtd_theme",
2828
"sphinx_copybutton",
@@ -37,7 +37,8 @@ test = [
3737
dev = [
3838
"black @ git+https://github.com/psf/black"
3939
]
40-
tutorials = [
40+
tutorial = [
41+
"jupyter",
4142
"smithers @ git+https://github.com/mathLab/smithers.git",
4243
"torchvision",
4344
"tensorboard",

tutorials/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Time dependent Kuramoto Sivashinsky equation using the Averaging Neural Operator
3333
|---------------|-----------|
3434
Unstructured convolutional autoencoder via continuous convolution |[[.ipynb](tutorial4/tutorial.ipynb), [.py](tutorial4/tutorial.py), [.html](http://mathlab.github.io/PINA/_rst/tutorials/tutorial4/tutorial.html)]|
3535
POD-RBF and POD-NN for reduced order modeling| [[.ipynb](tutorial8/tutorial.ipynb), [.py](tutorial8/tutorial.py), [.html](http://mathlab.github.io/PINA/_rst/tutorials/tutorial8/tutorial.html)]|
36+
POD-RBF for modelling Lid Cavity| [[.ipynb](tutorial14/tutorial.ipynb), [.py](tutorial14/tutorial.py), [.html](http://mathlab.github.io/PINA/_rst/tutorials/tutorial14/tutorial.html)]|

0 commit comments

Comments
 (0)