Skip to content

Commit

Permalink
Merge branch 'topic/default/try-nox-pdm' into 'branch/default'
Browse files Browse the repository at this point in the history
Topic/default/try nox pdm

See merge request fluiddyn/fluidsim!350
  • Loading branch information
paugier committed Jan 4, 2024
2 parents b447330 + 361ed58 commit c21ff1e
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 233 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI Linux

on:
- push
Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: apt install
Expand All @@ -25,8 +25,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
pip install pdm nox
- name: Test with nox
run: |
# needed to avoid a pdm/unearth bug
$(hg debuginstall -T '{pythonexe}') -m pip install hg-evolve hg-git --no-cache-dir --user
cp docker/hgrc $HOME/.hgrc
cp .github/workflows/.fluidfft-site.cfg $HOME
tox
nox -s test_without_fft_and_pythran
nox -s test_with_fft_and_pythran
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
85 changes: 79 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ stages:
- image
- lint
- test
- report
- doc

variables:
CODECOV_TOKEN: 4d2d8534-60ec-48b3-bf55-93b92f25913d
COVERAGE_DIR: .coverage_$CI_COMMIT_SHA

image: registry.heptapod.net:443/fluiddyn/fluidsim/ci/default:stable

# ugly workaround https://gitlab.com/gitlab-org/gitlab/-/issues/370052#note_1207556577
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH

# check_bug:
# image: fluiddyn/python3-stable:lastest
# script:
Expand Down Expand Up @@ -48,20 +58,83 @@ CI image:
--cleanup
--destination registry.heptapod.net:443/fluiddyn/fluidsim/ci/$CI_COMMIT_HG_BRANCH:stable
validate_code:
stage: lint
needs:
- job: "CI image"
optional: true
script:
- pdm install -G dev --no-self
- pdm run make lint
- pdm run make black_check
- echo "CI_COMMIT_HG_BRANCH $CI_COMMIT_HG_BRANCH"
- echo "CI_COMMIT_BRANCH $CI_COMMIT_BRANCH"
- nox -s validate_code


test_without_fft_and_pythran:
stage: test
needs:
- job: "CI image"
optional: true
script:
- nox -s test_without_fft_and_pythran
- mkdir $COVERAGE_DIR
- cp -r .coverage/* $COVERAGE_DIR
artifacts:
paths:
- $COVERAGE_DIR/*
expire_in: 60 mins

tests:
test_with_fft_and_pythran:
stage: test
needs:
- job: "CI image"
optional: true
script:
- tox -e py39,py39-fft,codecov
- nox -s test_with_fft_and_pythran
- mkdir $COVERAGE_DIR
- cp -r .coverage/* $COVERAGE_DIR
artifacts:
paths:
- $COVERAGE_DIR/*
expire_in: 60 mins


report_coverage:
stage: report
rules:
- when: on_success
script:
- mv $COVERAGE_DIR .coverage
- pip install coverage
- coverage combine
- coverage report


doc:build:
stage: doc
needs:
- job: "CI image"
optional: true
variables:
FLUIDFFT_TRANSONIC_BACKEND: "python"
script:
- python -m venv .venv
- . .venv/bin/activate
- pip install fluidfft
- pdm install -G doc -G fft -G test --no-self
- pip install . --config-settings=setup-args=-Dtransonic-backend=python
- pdm run xvfb-run --auto-servernum sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
- mkdir -p public/$CI_COMMIT_REF_NAME
- rsync -rvc --delete doc/_build/html/* public/$CI_COMMIT_REF_NAME/
# This directory can become too large leading to error.
# It can be purged with the botton "Clear runner caches"
# in https://foss.heptapod.net/fluiddyn/fluidsim/-/pipelines
- ls public
- echo "CI_COMMIT_REF_NAME="$CI_COMMIT_REF_NAME
- echo See https://fluiddyn.pages.heptapod.net/fluidsim/$CI_COMMIT_REF_NAME
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- public
expire_in: 5 days
when: always
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __pycache__
.pytest_cache/
.mypy_cache/
.coverage/
.nox

bench/launcher_*
bench/SLURM*
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.req

This file was deleted.

23 changes: 8 additions & 15 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
post_create_environment:
- pip install pdm pip -U
post_install:
- pdm use -f $READTHEDOCS_VIRTUALENV_PATH
- FLUIDFFT_TRANSONIC_BACKEND="python" pip install fluidfft
- pdm install -G doc -G fft -G test --no-self
- pip install . --config-settings=setup-args=-Dtransonic-backend=python

# Build documentation in the doc directory with Sphinx
sphinx:
configuration: doc/conf.py

python:
install:
- requirements: .readthedocs.req
- method: pip
path: .
extra_requirements:
- doc
- fft
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ shortlog:
@hg log -M -r$(RELEASE): --template '- {desc|firstline} (:rev:`{node|short}`)\n'

black:
black -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"
pdm black

black_check:
black --check -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"
pdm black_check

lint:
pdm lint

validate_code:
pdm validate_code

tests:
pytest -v lib
Expand Down Expand Up @@ -84,9 +90,6 @@ _report_coverage:
coverage: _tests_coverage _report_coverage


lint:
pylint -rn --rcfile=pylintrc --jobs=$(shell nproc) fluidsim --exit-zero

define _init_coverage
rm -rf .coverage
mkdir -p .coverage
Expand Down
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# ![FluidSim](https://foss.heptapod.net/fluiddyn/fluidsim/raw/branch/default/doc/logo.svg)

[![Latest version](https://badge.fury.io/py/fluidsim.svg)](https://pypi.python.org/pypi/fluidsim/)
![Supported Python versions](https://img.shields.io/pypi/pyversions/fluidsim.svg)
[![Documentation status](https://readthedocs.org/projects/fluidsim/badge/?version=latest)](http://fluidsim.readthedocs.org)
[![Chat room](https://img.shields.io/matrix/fluiddyn-users:matrix.org.svg)](https://matrix.to/#/#fluiddyn-users:matrix.org)
[![Code coverage](https://codecov.io/gh/fluiddyn/fluidsim/branch/branch%2Fdefault/graph/badge.svg)](https://codecov.io/gh/fluiddyn/fluidsim)
[![Heptapod CI](https://foss.heptapod.net/fluiddyn/fluidsim/badges/branch/default/pipeline.svg)](https://foss.heptapod.net/fluiddyn/fluidsim/-/pipelines)
[![Github Actions](https://github.com/fluiddyn/fluidsim/actions/workflows/ci.yml/badge.svg?branch=branch/default)](https://github.com/fluiddyn/fluidsim/actions)

Fluidsim is an extensible framework for studying fluid dynamics with
numerical simulations using Python. Fluidsim is an object-oriented
library to develop solvers (mainly using pseudo-spectral methods) by
writing mainly Python code. The result is **very efficient** even
compared to a pure Fortran or C++ code since the time-consuming tasks
are performed by optimized compiled functions.

**Documentation**: <https://fluidsim.readthedocs.io>

## Getting started

To try fluidsim without installation:
[![Binder notebook](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fluiddyn/fluidsim/branch%2Fdefault?urlpath=lab/tree/doc/ipynb)

For a **basic installation** it should be sufficient to run:

pip install fluidsim

or with conda:

conda install -c conda-forge fluidsim

Much more detailed instructions are given in [the
documentation](https://fluidsim.readthedocs.io/en/latest/install.html).

## How does it work?

Fluidsim is a
[HPC](https://en.wikipedia.org/wiki/High-performance_computing) code. It
is part of the wider project
[FluidDyn](https://pypi.python.org/pypi/fluiddyn/) and its
pseudospectral solvers rely on the library
[fluidfft](http://fluidfft.readthedocs.io) to use very efficient FFT
libraries. Fluidfft is written in C++, Cython and Python. Fluidfft and
fluidsim take advantage of
[Pythran](https://github.com/serge-sans-paille/pythran), an
ahead-of-time compiler which produces very efficient binaries by
compiling Python via C++11.

An advantage of a CFD code written mostly in Python is that, to run
simulations and analyze the results, the users communicate (possibly
interactively) together and with the machine with Python, which is
nowadays among the best languages to do these tasks. Moreover, it is
much simpler and faster than with pure Fortran or C++ codes to add any
complicated analysis or to write a modified solver. Fluidsim can also be
used to extend existing solvers with Python interfaces such as
[Basilisk](http://basilisk.fr).

We have created fluidsim to be **easy and nice to use and to develop**,
**efficient** and **robust**.

*Keywords and ambitions*: fluid dynamics research with Python (>=3.6);
modular, object-oriented, collaborative, tested and documented, free and
open-source software.

## License

FluidSim is distributed under the
[CeCILL](http://www.cecill.info/index.en.html) License, a GPL compatible
french license.

## Metapapers and citations

If you use FluidSim to produce scientific articles, please cite our
metapapers presenting the [FluidDyn
project](https://openresearchsoftware.metajnl.com/articles/10.5334/jors.237/),
[FluidFFT](https://openresearchsoftware.metajnl.com/articles/10.5334/jors.238/),
and
[FluidSim](https://openresearchsoftware.metajnl.com/articles/10.5334/jors.239/):

@article{fluiddyn, doi = {10.5334/jors.237}, year = {2019}, publisher
= {Ubiquity Press, Ltd.}, volume = {7}, author = {Pierre Augier and
Ashwin Vishnu Mohanan and Cyrille Bonamy}, title = {{FluidDyn}: A
Python Open-Source Framework for Research and Teaching in Fluid
Dynamics by Simulations, Experiments and Data Processing}, journal =
{Journal of Open Research Software} }

@article{fluidfft, doi = {10.5334/jors.238}, year = {2019}, publisher
= {Ubiquity Press, Ltd.}, volume = {7}, author = {Ashwin Vishnu
Mohanan and Cyrille Bonamy and Pierre Augier}, title = {{FluidFFT}:
Common {API} (C\$mathplusmathplus\$ and Python) for Fast Fourier
Transform {HPC} Libraries}, journal = {Journal of Open Research
Software} }

@article{fluidsim, doi = {10.5334/jors.239}, year = {2019}, publisher
= {Ubiquity Press, Ltd.}, volume = {7}, author = {Mohanan, Ashwin
Vishnu and Bonamy, Cyrille and Linares, Miguel Calpe and Augier,
Pierre}, title = {{FluidSim}: {Modular}, {Object}-{Oriented} {Python}
{Package} for {High}-{Performance} {CFD} {Simulations}}, journal =
{Journal of Open Research Software} }
Loading

0 comments on commit c21ff1e

Please sign in to comment.