Skip to content

Commit d874ae4

Browse files
committed
adding tutorials workflow + update toml
1 parent bca661f commit d874ae4

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

.github/workflows/tutorial.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
with:
19+
fetch-depth: 1
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.8
25+
26+
- name: Install dependencies
27+
run: |
28+
# Dependencies for tutorials
29+
python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
30+
31+
- name: Setup FFmpeg
32+
uses: FedericoCarboni/setup-ffmpeg@v2
33+
34+
- id: files
35+
uses: jitterbit/get-changed-files@v1
36+
continue-on-error: true
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
format: space-delimited
40+
41+
- name: Configure git
42+
run: |
43+
git config user.name "github-actions[bot]"
44+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
45+
46+
- name: Export tutorials to .py and RST
47+
run: |
48+
set -x
49+
for file in ${{ steps.files.outputs.all }}; do
50+
if [[ $file == *.ipynb ]]; then
51+
filename=$(basename $file)
52+
53+
pyfilename=$(echo ${filename%?????})py
54+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to python --output $pyfilename
55+
56+
rstfilename=$(echo ${filename%?????} | sed -e 's/-//g')rst
57+
output_dir="docs/source/_rst/_tutorials"
58+
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/||')
59+
fi
60+
done
61+
set +x
62+
63+
- name: Run formatter
64+
run: black tutorials/
65+
66+
- uses: benjlevesque/[email protected]
67+
id: short-sha
68+
69+
- name: Remove unwanted files
70+
run: |
71+
rm -rf build/
72+
73+
- name: Create Pull Request
74+
uses: peter-evans/[email protected]
75+
with:
76+
labels: maintenance
77+
title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }}
78+
branch: export-tutorial-${{ steps.short-sha.outputs.sha }}
79+
commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }}
80+
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)