Skip to content

Commit e0469fc

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

File tree

4 files changed

+85
-3
lines changed

4 files changed

+85
-3
lines changed

.github/workflows/tutorial.yml

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

pina/problem/zoo/supervised_problem.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ class SupervisedProblem(AbstractProblem):
2424
output_variables = None
2525
input_variables = None
2626

27-
def __init__(self, input_, output_, input_variables=None, output_variables=None):
27+
def __init__(
28+
self, input_, output_, input_variables=None, output_variables=None
29+
):
2830
"""
2931
Initialize the SupervisedProblem class.
3032

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)