Skip to content

Commit 7d61941

Browse files
authored
Update examples to support latest Psydac and Python 3.12 (#9)
Summary of changes: * Update [`deploy-book.yml`](https://github.com/kvrigor/IGA-Python/blob/build-ci-update/.github/workflows/deploy-book.yml): - Use the latest version of Psydac (`devel` branch) - Simplify Psydac installation - Add macOS test; * Remove duplicate `keywords` field in `references.bib` since `jupyter-book` complains about them; * Remove author info in `.ipynb` and `.md` files; * Use [`nb-clean`](https://github.com/srstevenson/nb-clean) to scrub all Jupyter notebooks free of data (e.g. cell execution count, cell result, path to Python environment, etc.) which shouldn't be tracked in `git`. The [Build Jupyter Book step](https://github.com/pyccel/IGA-Python/pull/9/checks#step:6:1) already handles the execution and rendering of these notebooks online; * Update the [Installation guide](https://github.com/kvrigor/IGA-Python/blob/build-ci-update/chapter1/install.md).
1 parent c4b0a9f commit 7d61941

File tree

133 files changed

+701
-3127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+701
-3127
lines changed

.github/workflows/deploy-book.yml

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,85 @@
1-
name: Build and Deploy Jupyter Book
1+
name: Build IGA-Python Jupyter Book
22

33
on:
44
push:
5-
branches:
6-
- master
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
78

89
jobs:
910
deploy-book:
10-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
include:
16+
- os: ubuntu-24.04
17+
python-version: '3.12'
18+
19+
- os: macos-15
20+
python-version: '3.12'
21+
22+
env:
23+
FC: gfortran-14
24+
25+
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
26+
1127
steps:
12-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
1329

14-
- name: Set up Python
15-
uses: actions/setup-python@v2
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
1632
with:
17-
python-version: '3.9'
33+
python-version: ${{ matrix.python-version }}
34+
cache: 'pip'
35+
cache-dependency-path: requirements.txt
1836

19-
- name: Install dependencies
37+
- name: Install non-Python dependencies on Ubuntu
38+
if: startsWith(matrix.os, 'ubuntu')
39+
uses: awalsh128/cache-apt-pkgs-action@latest
40+
with:
41+
packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev
42+
version: 1.0
43+
execute_install_scripts: true
44+
45+
# When loading cached apt packages, the default MPI compiler isn't set.
46+
# Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform
47+
# installation (since openmpi-bin already exists), but instead reruns
48+
# `update-alternatives` which fixes the symlinks to mpicc/mpif90.
49+
- name: Reconfigure non-Python dependencies on Ubuntu
50+
if: startsWith(matrix.os, 'ubuntu')
2051
run: |
21-
python -m pip install --upgrade pip
2252
sudo apt-get update
23-
sudo apt-get install gfortran
24-
sudo apt-get install openmpi-bin libopenmpi-dev
25-
sudo apt-get install libhdf5-openmpi-dev
26-
git clone https://github.com/pyccel/psydac.git
27-
cd psydac
28-
python -m pip install -r requirements.txt
29-
python -m pip install -r requirements_extra.txt --no-build-isolation
30-
pip install .
31-
pip install jupyter-book ghp-import sphinx_proof
32-
python -m ipykernel install --user --name .iga-python --display-name "IGA-Python"
33-
python -m ipykernel install --user --name v_psydac --display-name "Python (v_psydac)"
53+
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev
54+
55+
- name: Install non-Python dependencies on macOS
56+
if: startsWith(matrix.os, 'macos')
57+
run: |
58+
brew install open-mpi hdf5-mpi libomp
59+
60+
- name: Check gfortran version
61+
run: |
62+
if [[ "${{ matrix.os }}" == *"macos"* ]]; then
63+
# pyccel searches for a Fortran compiler exactly named 'gfortran'
64+
# which the macos runner doesn't have. A simple workaround is to
65+
# create a symlink named 'gfortran'.
66+
FC_path=$(which $FC)
67+
FC_dir=$(dirname ${FC_path})
68+
ln -sv ${FC_path} ${FC_dir}/gfortran
69+
fi
70+
gfortran --version
71+
72+
- name: Install Jupyter Book and Psydac
73+
run: |
74+
pip install --upgrade pip
75+
pip install -r requirements.txt
3476
3577
- name: Build Jupyter Book
36-
run: jupyter-book build .
78+
run: make docs
3779

3880
- name: Deploy to GitHub Pages
81+
if: ${{ (github.ref == 'refs/heads/master') && startsWith(matrix.os, 'ubuntu') }}
3982
run: ghp-import -n -p -f _build/html
4083
env:
4184
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+

AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Ahmed Ratnani
2+
Mohamed Jalal Maaouni
3+
Paul Rigor
4+

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BUILD_DIR = ./_build
2+
SRC_DIR = .
3+
4+
.PHONY: docs docs-strict clean clean-notebooks
5+
6+
docs:
7+
@echo "Building IGA-Python docs..."
8+
@jupyter-book build .
9+
@echo "Done."
10+
11+
docs-strict:
12+
@echo "Building IGA-Python docs with strict rules on..."
13+
@jupyter-book build --warningiserror --nitpick --keep-going .
14+
@echo "Done."
15+
16+
clean:
17+
@echo "Removing previous IGA-Python build artifacts..."
18+
@jupyter-book clean .
19+
@echo "Done."
20+
21+
clean-notebooks:
22+
@echo "Running 'nb-clean --remove-empty-cells --remove-all-notebook-metadata' on all '*.ipynb' files..."
23+
@find . -type f -iname '*.ipynb' -exec nb-clean clean --remove-empty-cells --remove-all-notebook-metadata {} \+
24+
@echo "Done."
25+

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,72 @@
11
# Welcome to IGA-Python
2+
3+
This project provides a tutorial for isogeometric analysis (IGA) using Python and the Psydac library (pyccel/psydac). The numerical examples can be consulted online at pyccel.github.io/IGA-Python, or run with JupyterNotebook on a personal computer.
4+
5+
## Editing and building IGA-Python locally
6+
7+
1. Clone this repository and then install the required dependencies.
8+
9+
```bash
10+
git clone https://github.com/pyccel/IGA-Python.git
11+
cd IGA-Python
12+
IGA_PYTHON_DIR=$(pwd)
13+
14+
# Install dependencies on a virtual environment
15+
python3 -m venv iga-python-env
16+
source iga-python-env/bin/activate
17+
pip3 install -r requirements_ntbk.txt
18+
```
19+
20+
2. Install Psydac. Skip this step if Psydac is already installed.
21+
22+
```bash
23+
# Modify these variables if you're using your own psydac fork/branch
24+
PSYDAC_REMOTE="https://github.com/pyccel/psydac.git"
25+
BRANCH="devel"
26+
27+
# Install psydac
28+
pip install git+${PSYDAC_REMOTE}@${BRANCH}
29+
```
30+
31+
3. Run or modify the desired Python notebooks (`*.ipynb`) and Markdown files (`*.md`). Check the [MyST syntax cheat sheet](https://jupyterbook.org/en/stable/reference/cheatsheet.html) for reference.
32+
33+
> [!NOTE]
34+
> Before committing changes to git, the notebooks have to be cleaned first. See ["Committing your changes to git"](#committing-your-changes-to-git) for more information.
35+
36+
4. Build the docs by running `make` under the IGA-Python folder. This involves running all `*.ipynb` files in the background to make sure they are functional.
37+
38+
```bash
39+
cd ${IGA_PYTHON_DIR}
40+
make
41+
```
42+
43+
5. View your changes on the browser.
44+
45+
```bash
46+
open ${IGA_PYTHON_DIR}/_build/html/index.html
47+
```
48+
49+
## Committing your changes to git
50+
51+
Running the Python notebooks embeds extra information like the name of virtual environment, Python version used, cell outputs, etc. The notebooks should be free of system- and runtime-specific information before committing them to source control. We suggest the following commit workflow:
52+
53+
1. Run [`nb-clean`](https://github.com/srstevenson/nb-clean) on the modified notebook/s. There are different ways to run this command:
54+
55+
```bash
56+
# Clean a single notebook
57+
nb-clean clean --remove-empty-cells --remove-all-notebook-metadata chapter1/poisson.ipynb
58+
59+
# Clean all '.ipynb' files under IGA-Python
60+
make clean-notebooks
61+
62+
# Automatically run nb-clean on `git add`-ed *.ipynb files
63+
nb-clean add-filter --remove-empty-cells --remove-all-notebook-metadata
64+
65+
# Undo previous command
66+
nb-clean remove-filter
67+
```
68+
69+
2. Create a branch for your local changes, e.g. `git checkout -b my-local-fixes`.
70+
3. Stage the modified files with `git add`. Then run `git diff` to check if the changed `*.ipynb` notebooks doesn't include unnecessary diffs (e.g. notebook metadata).
71+
4. `git commit` your changes.
72+
5. *OPTIONAL*. Share your changes to this repo via a [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).

_toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ parts:
3232
- file: chapter1/topology
3333
- file: chapter1/space
3434
- file: chapter1/rules
35-
- file: chapter1/poisson
35+
- file: chapter1/poisson
3636
- file: chapter1/boundary-conditions
3737
- file: chapter1/geometry
3838
sections:

chapter0/bezier-curves.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Bézier curves
2-
*Author: Ahmed Ratnani*
2+
33

44
We recall the definition of a Bézier curve:
55

chapter0/bezier.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Bernstein polynomials
2-
*Author: Ahmed Ratnani*
2+
33

44
Without loss of generality, we restrict to the case of the unit interval, namely $a=0$ and $b=1$.
55
In figure (Fig. \ref{fig:bernstein-polynomials}), we plot the first sixth Bernstein polynomials.

chapter0/bsplines-curves.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# B-Splines curves
2-
*Author: Ahmed Ratnani*
2+
33

44
Let $(\mathbf{P}_i)_{ 0 \leqslant i \leqslant n}\in \mathbb{R}^d$ be a sequence of control points. Following the same approach as for Bézier curves, we define B-Splines curves as
55

chapter0/bsplines-operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Fundamental geometric operations for B-Splines
2-
*Author: Ahmed Ratnani*
2+
33

44
Having more control on a curve, adding new control points, can be done in two different ways:
55

chapter0/bsplines-surfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# B-Splines surfaces
2-
*Author: Ahmed Ratnani*
2+
33

44
The B-spline surface in $\mathbb{R}^d$ associated to knots $(T_u, T_v)$ where $T_u=(u_i)_{0\leqslant i \leqslant n_u + p_u + 1}$ and $T_v=(v_i)_{0\leqslant i \leqslant n_v + p_v + 1}$, and control points $(\mathbf{P}_{ij})_{ 0 \leqslant i \leqslant n_u, 0 \leqslant j \leqslant n_v}$ is defined by :
55

0 commit comments

Comments
 (0)