Skip to content

Commit

Permalink
Merge branch 'topic/default/setup-plugins' into 'branch/default'
Browse files Browse the repository at this point in the history
Entry point fluidfft.plugins

See merge request fluiddyn/fluidfft!49
  • Loading branch information
paugier committed Jan 28, 2024
2 parents a9c7d29 + 48e76d7 commit 27f92ae
Show file tree
Hide file tree
Showing 39 changed files with 619 additions and 270 deletions.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ jobs:
python-version: [3.9, "3.10", "3.11"]

steps:

- name: apt install
run: |
sudo apt install -y libfftw3-dev libfftw3-mpi-dev \
sudo apt-get install -y make libfftw3-dev libfftw3-mpi-dev \
libhdf5-openmpi-dev openmpi-bin libopenmpi-dev \
libopenblas-dev
Expand All @@ -37,8 +38,10 @@ jobs:
- name: Run tests
run: |
cp .github/fluidfft-site.cfg $HOME/.fluidfft-site.cfg
cp .github/fluidfft-site-seq.cfg $HOME/.fluidfft-site.cfg
nox --session "tests(with_cov=True, with_mpi=False)"
make cleanall
cp .github/fluidfft-site-mpi.cfg $HOME/.fluidfft-site.cfg
nox --session "tests(with_cov=True, with_mpi=True)"
coverage xml
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ jobs:
use-mamba: true
- name: Install
run: |
cp .github/fluidfft-site-macos.cfg $HOME/.fluidfft-site.cfg
cp .github/fluidfft-site-seq.cfg $HOME/.fluidfft-site.cfg
pip install -e . -v --no-build-isolation --no-deps
pip install plugins/fluidfft-pyfftw
- name: Tests
run: |
pytest -v
pytest -v tests plugins/fluidfft-pyfftw
3 changes: 2 additions & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
run: |
cp .github/pythranrc-windows $HOME/.pythranrc
pip install -e . -v --no-build-isolation --no-deps
pip install plugins/fluidfft-pyfftw
- name: Tests
run: |
pytest -v
pytest -v tests plugins/fluidfft-pyfftw
1 change: 1 addition & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build:
post_install:
- pdm use -f $READTHEDOCS_VIRTUALENV_PATH
- pdm sync -G doc --no-self
- pdm run pip install plugins/fluidfft-pyfftw
- FLUIDFFT_TRANSONIC_BACKEND="python" pip install . -v --no-deps

sphinx:
Expand Down
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.PHONY: clean cleanall cleanmako cleancython develop build_ext_inplace list-sessions requirements
.PHONY: clean cleanall cleanmako cleancython develop build_ext_inplace list-sessions tests

develop: sync
pdm run pip install -e . --no-deps --no-build-isolation -v

sync:
pdm sync --clean --no-self
pdm run pip install -e plugins/fluidfft-pyfftw

clean:
rm -rf build
Expand All @@ -27,20 +28,20 @@ black:
pdm run black

tests:
pytest -s src
pytest -s tests

tests_mpi:
mpirun -np 2 pytest -s src
mpirun -np 2 pytest -s tests

tests_mpi4:
mpirun -np 4 pytest -s src
mpirun -np 4 pytest -s tests

_tests_coverage:
mkdir -p .coverage
coverage run -p -m pytest -s src
TRANSONIC_NO_REPLACE=1 coverage run -p -m pytest -s src
coverage run -p -m pytest -s tests
TRANSONIC_NO_REPLACE=1 coverage run -p -m pytest -s tests
# Using TRANSONIC_NO_REPLACE with mpirun in docker can block the tests
mpirun -np 2 --oversubscribe coverage run -p -m unittest discover src
mpirun -np 2 --oversubscribe coverage run -p -m unittest discover tests

_report_coverage:
coverage combine
Expand Down
5 changes: 2 additions & 3 deletions doc/ipynb/tuto_fft2d_seq.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ If you really want performance, first benchmark the different methods for an arr

```{code-cell} ipython3
import numpy as np
from fluidfft.fft2d import methods_seq
from fluidfft import import_fft_class
from fluidfft import get_methods, import_fft_class
```

```{code-cell} ipython3
print(methods_seq)
print(get_methods(ndim=2, sequential=True))
```

We import a class and instantiate it:
Expand Down
5 changes: 2 additions & 3 deletions doc/ipynb/tuto_fft3d_seq.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ In this tutorial, we present how to use fluidfft to perform 3D fft in sequential

```{code-cell} ipython3
import numpy as np
from fluidfft.fft3d import methods_seq
from fluidfft import import_fft_class
from fluidfft import get_methods, import_fft_class
```

```{code-cell} ipython3
print(methods_seq)
print(get_methods(ndim=3, sequential=True))
```

We import a class and instantiate it:
Expand Down
11 changes: 6 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ def tests(session, with_mpi, with_cov):
session.install("-e", ".", "--no-deps", "-v", silent=False)
session.run("ls", "src/fluidfft/fft3d", silent=False, external=True)

session.install("-e", "plugins/fluidfft-pyfftw")

def run_command(command, **kwargs):
session.run(*command.split(), **kwargs)

if with_cov:
cov_path = Path.cwd() / ".coverage"
cov_path.mkdir(exist_ok=True)

command = "pytest -v -s"
command = "pytest -v -s tests"
if with_cov:
command += (
" --cov --cov-config=setup.cfg --no-cov-on-fail --cov-report=term-missing"
Expand All @@ -70,12 +72,10 @@ def run_command(command, **kwargs):

if with_mpi:
if with_cov:
command = (
"mpirun -np 2 --oversubscribe coverage run -p -m pytest --exitfirst src"
)
command = "mpirun -np 2 --oversubscribe coverage run -p -m pytest -v -s --exitfirst tests"

else:
command = "mpirun -np 2 --oversubscribe pytest src"
command = "mpirun -np 2 --oversubscribe pytest -v -s tests"

# Using TRANSONIC_NO_REPLACE with mpirun in docker can block the tests
run_command(command, external=True)
Expand All @@ -92,6 +92,7 @@ def doc(session):
session.install(
"-e", ".", "--no-deps", env={"FLUIDFFT_TRANSONIC_BACKEND": "python"}
)
session.install("-e", "plugins/fluidfft-pyfftw")

session.chdir("doc")
session.run("make", "cleanall", external=True)
Expand Down
42 changes: 21 additions & 21 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Fluidfft plugins

Directory containing the plugins, i.e. Python packages declaring the
`fluidfft.plugins` entry point.

We should have

- [x] fluidfft-mpi4pyfft (cannot be tested because mpi4py-fft installation fails)
- [ ] fluidfft-fftw
- [ ] fluidfft-mpi_with_fftw
- [ ] fluidfft-fftwmpi
- [ ] fluidfft-p3dfft
- [ ] fluidfft-pfft
- [ ] fluidfft-pyvkfft (https://pyvkfft.readthedocs.io)

Currently, we have only one tested plugin (fluidfft-pyfftw), which was written to
design and test the plugin machinery. However, I (PA) think that this (pure Python)
code will have to go back in fluidfft. Pyfftw can just be an optional dependency
for fluidfft.

TODO: When we have other plugins, move back the code using pyfftw inside fluidfft.
21 changes: 21 additions & 0 deletions plugins/fluidfft-mpi4pyfft/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Pierre Augier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
20 changes: 20 additions & 0 deletions plugins/fluidfft-mpi4pyfft/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "fluidfft_mpi4pyfft"
version = "0.0.1"
description = "Fluidfft plugin using mpi4pyfft"
authors = [{name = "Pierre Augier", email = "pierre.augier@univ-grenoble-alpes.fr"}]
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
dependencies = ["fluidfft", "mpi4py-fft"]

[project.urls]
Home = "https://fluidfft.readthedocs.io"

[project.entry-points."fluidfft.plugins"]

"fft3d.mpi_with_mpi4pyfft" = "fluidfft_mpi4pyfft.mpi_with_mpi4pyfft"
"fft3d.mpi_with_mpi4pyfft_slab" = "fluidfft_mpi4pyfft.fft3d.mpi_with_mpi4pyfft_slab"
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mpi4py import MPI
from mpi4py_fft import PFFT, newDistArray

from .base import BaseFFTMPI
from fluidfft.fft3d.base import BaseFFTMPI


class FFT3DMPIWithMPI4PYFFT(BaseFFTMPI):
Expand Down
12 changes: 12 additions & 0 deletions plugins/fluidfft-mpi4pyfft/tests/test_with_mpi4pyfft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unittest import TestCase

from fluidfft.fft3d.testing import complete_test_class_3d


class Tests(TestCase):
pass


methods = ["fft3d.mpi_with_mpi4pyfft", "fft3d.mpi_with_mpi4pyfft_slab"]
for method in methods:
complete_test_class_3d(method, Tests)
21 changes: 21 additions & 0 deletions plugins/fluidfft-pyfftw/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Pierre Augier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
20 changes: 20 additions & 0 deletions plugins/fluidfft-pyfftw/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "fluidfft_pyfftw"
version = "0.0.1"
description = "Fluidfft plugin using pyfftw"
authors = [{name = "Pierre Augier", email = "pierre.augier@univ-grenoble-alpes.fr"}]
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
dependencies = ["fluidfft", "pyfftw"]

[project.urls]
Home = "https://foss.heptapod.net/fluiddyn/fluidfft"

[project.entry-points."fluidfft.plugins"]

"fft2d.with_pyfftw" = "fluidfft_pyfftw.fft2d"
"fft3d.with_pyfftw" = "fluidfft_pyfftw.fft3d"
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Class using pyfftw (:mod:`fluidfft.fft2d.with_pyfftw`)
=========================================================
"""Class using pyfftw
=====================
.. autoclass:: FFT2DWithPYFFTW
:members:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Class using pyfftw (:mod:`fluidfft.fft3d.with_pyfftw`)
=========================================================
"""Class using pyfftw
=====================
.. autoclass:: FFT3DWithPYFFTW
:members:
Expand Down
12 changes: 12 additions & 0 deletions plugins/fluidfft-pyfftw/tests/test_with_pyfftw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unittest import TestCase

from fluidfft.fft3d.testing import complete_test_class_3d
from fluidfft.fft2d.testing import complete_test_class_2d


class Tests(TestCase):
pass


complete_test_class_2d("fft2d.with_pyfftw", Tests)
complete_test_class_3d("fft3d.with_pyfftw", Tests)

0 comments on commit 27f92ae

Please sign in to comment.