Skip to content

Commit c1a4a64

Browse files
committed
Update Tutorials 0.2
1 parent 795e4a4 commit c1a4a64

File tree

32 files changed

+1605
-5232
lines changed

32 files changed

+1605
-5232
lines changed

.github/workflows/tutorial.yml

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

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,9 @@ cython_debug/
139139

140140
# Lightning logs dir
141141
**lightning_logs
142+
143+
# Tutorial logs dir
144+
**tutorial_logs
145+
146+
# tmp dir
147+
**tmp*

pina/problem/zoo/supervised_problem.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from ..abstract_problem import AbstractProblem
44
from ... import Condition
5-
from ... import Graph
5+
from ... import LabelTensor
66

77

88
class SupervisedProblem(AbstractProblem):
@@ -22,16 +22,22 @@ class SupervisedProblem(AbstractProblem):
2222

2323
conditions = {}
2424
output_variables = None
25+
input_variables = None
2526

26-
def __init__(self, input_, output_):
27+
def __init__(
28+
self, input_, output_, input_variables=None, output_variables=None
29+
):
2730
"""
2831
Initialize the SupervisedProblem class.
2932
3033
:param input_: Input data of the problem.
34+
:type input_: torch.Tensor | LabelTensor | Graph | Data
3135
:param output_: Output data of the problem.
32-
:type output_: torch.Tensor | Graph
36+
:type output_: torch.Tensor | LabelTensor | Graph | Data
3337
"""
34-
if isinstance(input_, Graph):
35-
input_ = input_.data
38+
# Set input and output variables
39+
self.input_variables = input_variables
40+
self.output_variables = output_variables
41+
# Set the condition
3642
self.conditions["data"] = Condition(input=input_, target=output_)
3743
super().__init__()

pina/trainer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ def __init__(
127127

128128
# logging
129129
self.logging_kwargs = {
130-
"logger": bool(
131-
kwargs["logger"] is not None or kwargs["logger"] is True
132-
),
133130
"sync_dist": bool(
134131
len(self._accelerator_connector._parallel_devices) > 1
135132
),

pyproject.toml

Lines changed: 7 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,8 +37,13 @@ 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",
43+
"torchvision",
44+
"tensorboard",
45+
"scipy",
46+
"numpy",
4247
]
4348

4449
[project.urls]

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)]|

tutorials/tutorial1/tutorial.ipynb

Lines changed: 151 additions & 115 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)