Skip to content

Commit

Permalink
Merge branch 'main' into write_fluxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apolline Elbaz committed May 24, 2024
2 parents b5ab0fb + d99f879 commit c2c878b
Show file tree
Hide file tree
Showing 90 changed files with 28,415 additions and 6,114 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ on:

jobs:
ubuntu:
name: (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-20.04", "ubuntu-22.04"]

name: Code checks ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install build-essential make openjdk-11-jre-headless
sudo apt-get update
sudo apt-get install build-essential openjdk-17-jdk
python -m venv test
. test/bin/activate
python -m pip install --upgrade pip
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,25 @@ on:

jobs:
ubuntu:
name: (${{ matrix.os }} | py-${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04']
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Documentation ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.11'

- name: Install dependencies
run: |
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install build-essential make gcc gfortran gdal-bin libgdal-dev
sudo apt-get install build-essential gfortran
python -m venv test
. test/bin/activate
python -m pip install --upgrade pip
pip install wheel numpy
pip install gdal==$(gdal-config --version)
pip install -r requirements-dev.txt
- name: Build
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,28 @@ on:

jobs:
ubuntu:
name: (${{ matrix.os }} | py-${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
name: Unit tests ubuntu-latest py-${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04']
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install build-essential make gcc gfortran gdal-bin libgdal-dev
sudo apt-get install build-essential gfortran
python -m venv test
. test/bin/activate
python -m pip install --upgrade pip
pip install wheel numpy
pip install gdal==$(gdal-config --version)
pip install -r requirements-dev.txt
- name: Build
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This is partially adopted from scipy.
# See: https://github.com/scipy/scipy/blob/main/.github/workflows/wheels.yml
# License: 3-clause BSD, https://github.com/scipy/scipy/blob/main/LICENSE.txt

name: Wheels

# Controls when the action will run.
on:

push:
branches:
- main

pull_request:
branches:
- main
- maintenance/**

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build_wheels:
name: Build wheel ${{ matrix.python-version }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
matrix:
buildplat:
- [ubuntu-latest, manylinux, x86_64]
# Use windows-2019 otherwise there is undefined reference to _setjmpex. This is linked to f90wrap
# and f90wrap_abort with FortranDerivedTypeArray
- [windows-2019, win, AMD64]

python-version: ['cp39', 'cp310', 'cp311']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python-version }}-${{ matrix.buildplat[1] }}*
CIBW_ARCHS: ${{ matrix.buildplat[2] }}

- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ matrix.python-version }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parts/
sdist/
var/
wheels/
wheelhouse/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -60,9 +61,9 @@ f90wrap*.f90
**/fcore/_m*.py

# Tapenade files
tapenade/*.msg*
tapenade/*.f90*
tapenade/*~
# Tapenade files
tapenade/*_db.*
*_db.msg*

# Temporary files
tmp*
Expand Down
34 changes: 13 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
FROM ubuntu:22.04
# Derived from Pandas
FROM python:3.11
WORKDIR /home/smash

ADD . /app/

WORKDIR /app

RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y \
build-essential \
make \
openjdk-11-jre-headless \
gcc \
gfortran \
gdal-bin \
libgdal-dev \
python3-pip

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/

RUN export JAVA_HOME

RUN pip3 install -r requirements-dev.txt

RUN make
openjdk-17-jdk \
gfortran

RUN python -m pip install --upgrade pip
COPY requirements-dev.txt /tmp
RUN python -m pip install -r /tmp/requirements-dev.txt
RUN git config --global --add safe.directory /home/smash
CMD ["/bin/bash"]
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#% Meson options (see meson.options)
use-openmp := true

#% Build smash
all:
pip install -Csetup-args=-Duse-openmp=$(use-openmp) .

#% Build smash in editable mode
edit:
pip install -Csetup-args=-Duse-openmp=$(use-openmp) --no-build-isolation --config-settings=editable-verbose=true --editable .

TAP_FILES := $(addprefix smash/fcore/*/,mwd_*.f90 md_*.f90 forward.f90)

#% Generate tapenade files (adjoint and tangent linear models)
tap:
python tapenade/generate_tapenade.py $(TAP_FILES) --build-dir smash/fcore/forward --openmp -m forward_openmp
python tapenade/generate_tapenade.py $(TAP_FILES) --build-dir smash/fcore/forward -m forward

#% Compare tapenade files
tap-cmp:
python tapenade/generate_tapenade.py $(TAP_FILES) --build-dir tapenade --openmp -m forward_openmp
python tapenade/generate_tapenade.py $(TAP_FILES) --build-dir tapenade -m forward
cmp tapenade/forward_openmp_db.f90 smash/fcore/forward/forward_openmp_db.f90
cmp tapenade/forward_db.f90 smash/fcore/forward/forward_db.f90

#% Generate sphinx documentation
doc:
make html -C doc

#% Clean sphinx documentation
doc-clean:
make clean -C doc

#% Testing code with pytest
test:
cd smash/tests ; pytest

#% Testing code with pytest and coverage
test-coverage:
cd smash/tests ; pytest --cov-report term --cov-report html --cov=smash

#% Generate baseline for test with args (see argparser in gen_baseline.py)
test-baseline:
cd smash/tests ; python3 gen_baseline.py

#% Format Python files with ruff and Fortran files with fprettify
format:
ruff format
fprettify -e forward_db.f90 -e forward_openmp_db.f90 -e f90wrap -f .f90 --indent 4 -r smash

#% Check Python files with ruff linters
check:
ruff check --fix --exit-non-zero-on-fix

#% Clean
clean:
@rm -rf build

.PHONY: all edit tap tap-cmp doc doc-clean test test-baseline format check clean
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<h1 align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="doc/source/_static/corporate_logo_dark.svg">
<img src="doc/source/_static/corporate_logo.svg" width="300", hspace=30>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/DassHydro/smash/main/doc/source/_static/corporate_logo_dark.svg">
<img src="https://raw.githubusercontent.com/DassHydro/smash/main/doc/source/_static/corporate_logo.svg" width="300", hspace=30>
</picture>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="doc/source/_static/logo_smash_dark.svg">
<img src="doc/source/_static/logo_smash.svg" width="300", hspace=30>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/DassHydro/smash/main/doc/source/_static/logo_smash_dark.svg">
<img src="https://raw.githubusercontent.com/DassHydro/smash/main/doc/source/_static/logo_smash.svg" width="300", hspace=30>
</picture>
</h1><br>

- **Documentation:** https://smash.recover.inrae.fr
- **Source code:** https://github.com/DassHydro/smash
- **Contributors and contact:** https://smash.recover.inrae.fr/contributors/index.html
- **Contributing:** https://smash.recover.inrae.fr/developers_guide/index.html
- **Contributing:** https://smash.recover.inrae.fr/contributor_guide/index.html
- **Scientific references from latest version:** https://smash.recover.inrae.fr/bibliography/index.html
- **Bug reports:** https://github.com/DassHydro/smash/issues

**smash** is a Python library, that provides a variety of user-friendly routines for hydrological modeling, including data preprocessing, high-dimensional optimization tools, sensitivity and signatures analysis, all interfaced with an efficient Fortran solver.

**smash** offers a range of advanced optimization techniques, including Variational Data Assimilation (VDA), Bayesian estimation, and Artificial Neural Network (ANN) approaches, using an adjoint model generated with the **Tapenade** Automatic Differentiation Engine.

- **Tapenade** website: https://team.inria.fr/ecuador/en/tapenade/
- **Tapenade** article: https://doi.org/10.1145/2450153.2450158
- **Tapenade** source code: https://gitlab.inria.fr/tapenade/tapenade.git

Whether you are managing water resources or conducting research on hydrological models, **smash** can provide an easy-to-use yet powerful solution for your work. See [this documentation](https://smash.recover.inrae.fr/getting_started/index.html) for the installation instructions.
Whether you are managing water resources or conducting research on hydrological models, **smash** can provide an easy-to-use yet powerful solution for your work. See [this documentation](https://smash.recover.inrae.fr/getting_started/index.html) for the installation instructions.
Loading

0 comments on commit c2c878b

Please sign in to comment.