Skip to content

improve type hints based on mypy analysis #571

improve type hints based on mypy analysis

improve type hints based on mypy analysis #571

Workflow file for this run

name: Build and test
on:
push:
branches:
- "**"
pull_request:
jobs:
gfortran:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
version: [9, 10, 11, 12]
os: [ubuntu-latest]
include:
#- version: 4.8
# os: ubuntu-18.04
# cmake_args: -DFABM_USE_IEEE_ARITHMETIC=OFF
#- version: 5
# os: ubuntu-18.04
#- version: 6
# os: ubuntu-18.04
- version: 7
os: ubuntu-20.04
- version: 8
os: ubuntu-20.04
cmake_args: -DFABM_USE_CONTIGUOUS=OFF
- version: 13
os: ubuntu-24.04
- version: 14
os: ubuntu-24.04
fail-fast: false
runs-on: ${{ matrix.os }}
env:
FFLAGS: -fcheck=all
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip pyyaml
- name: Install compiler
run: |
sudo apt-get update
sudo apt-get install gfortran-${{ matrix.version }}
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: python3 util/developers/run_all_testcases.py harness --show_logs --compiler gfortran-${{ matrix.version }} ${{ matrix.cmake_args }}
- name: Run all test cases with pyfabm
run: python3 util/developers/run_all_testcases.py pyfabm --show_logs --compiler gfortran-${{ matrix.version }} ${{ matrix.cmake_args }}
ifort:
# for available versions, see https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
include:
- version: "2021.1.2.62"
url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/17508"
# - version: "2022.2.1.16992"
# url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18998"
# - version: "2023.2.0.49254"
# url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/237236c4-434b-4576-96ac-020ceeb22619"
- version: "2024.2.0.426"
url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/801143de-6c01-4181-9911-57e00fe40181"
fail-fast: false
runs-on: ubuntu-latest
env:
FFLAGS: -check all
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip pyyaml
- name: Install compiler
run: |
wget --no-verbose ${{ matrix.url_dir }}/l_fortran-compiler_p_${{ matrix.version }}_offline.sh
/bin/sh l_fortran-compiler_p_${{ matrix.version }}_offline.sh -a --silent --cli --install-dir ${HOME}/intel --eula accept
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: |
source ${HOME}/intel/setvars.sh
python3 util/developers/run_all_testcases.py harness --show_logs --compiler ifort
- name: Run all test cases with pyfabm
run: |
source ${HOME}/intel/setvars.sh
python3 util/developers/run_all_testcases.py pyfabm --show_logs --compiler ifort
env:
FFLAGS: ${{ env.FFLAGS }} -fp-model precise -fp-model source
ifx:
# for available versions, see https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
include:
- version: "2023.2.0.49254"
url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/237236c4-434b-4576-96ac-020ceeb22619"
fflags: -check all,nouninit,nocontiguous
# nouninit because https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-missing-clang-rt-msan-to-link-Fortran-program-in-debug-build/m-p/1536555
# nocontiguous because spurious errors occur when assigning null() to contiguous pointers, see https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-2024-0-2-runtime-error-about-non-contiguous-target/m-p/1583909
#- version: "2024.0.2.28"
# url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/41df6814-ec4b-4698-a14d-421ee2b02aa7"
- version: "2024.2.0.426"
url_dir: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/801143de-6c01-4181-9911-57e00fe40181"
fflags: -check all,nouninit,nocontiguous
# memory sanitizer (uninit) still seems broken, as it reports errors in libc.so (it should be auto-linked to sanitized libc, but apparently not)
# contiguous check still broken, to be fixed in 2025.x as per https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-2024-0-2-runtime-error-about-non-contiguous-target/m-p/1583909
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip pyyaml
- name: Install compiler
run: |
wget --no-verbose ${{ matrix.url_dir }}/l_fortran-compiler_p_${{ matrix.version }}_offline.sh
/bin/sh l_fortran-compiler_p_${{ matrix.version }}_offline.sh -a --silent --cli --install-dir ${HOME}/intel --eula accept
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: |
source ${HOME}/intel/setvars.sh
python3 util/developers/run_all_testcases.py harness --show_logs --compiler ifx
env:
FFLAGS: ${{ matrix.fflags }}
- name: Run all test cases with pyfabm
run: |
source ${HOME}/intel/setvars.sh
python3 util/developers/run_all_testcases.py pyfabm --show_logs --compiler ifx
env:
FFLAGS: ${{ matrix.fflags }} -fp-model=precise
nvfortran:
# for available versions, see https://developer.nvidia.com/nvidia-hpc-sdk-releases
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
include:
- version: "20.7" # released 2020-08
exe: nvhpc_2020_207_Linux_x86_64_cuda_11.0
# - version: "20.9" # released 2020-10
# exe: nvhpc_2020_209_Linux_x86_64_cuda_11.0
# - version: "22.9" # released 2022-10
# exe: nvhpc_2022_229_Linux_x86_64_cuda_11.7
# - version: "23.7" # released 2023-07
# exe: nvhpc_2023_237_Linux_x86_64_cuda_12.2
- version: "24.5" # released 2024-05
exe: nvhpc_2024_245_Linux_x86_64_cuda_12.4
fail-fast: false
runs-on: ubuntu-latest
env:
FFLAGS: -Mbounds -Mchkptr
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip pyyaml
- name: Install compiler
run: |
wget --no-verbose https://developer.download.nvidia.com/hpc-sdk/${{ matrix.version }}/${{ matrix.exe }}.tar.gz
tar xpzf ${{ matrix.exe }}.tar.gz
rm ${{ matrix.exe }}.tar.gz
${{ matrix.exe }}/install
env:
NVHPC_SILENT: true
NVHPC_INSTALL_DIR: /home/runner/nvhpc
NVHPC_INSTALL_TYPE: single
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: python3 util/developers/run_all_testcases.py harness --show_logs --compiler /home/runner/nvhpc/Linux_x86_64/${{ matrix.version }}/compilers/bin/pgfortran
- name: Run all test cases with pyfabm
run: python3 util/developers/run_all_testcases.py pyfabm --show_logs --compiler /home/runner/nvhpc/Linux_x86_64/${{ matrix.version }}/compilers/bin/pgfortran
aocc:
# for available versions, see https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/aocc/package.py
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
include:
- version: "3.2.0" # released 2021-12-02 (LLVM 13.0)
pyfabm_cmake_args: -DCMAKE_Fortran_FLAGS_DEBUG= # skip -g as that triggers segfault
url_dir: https://download.amd.com/developer/eula/aocc-compiler
# - version: "4.0.0" # released 2022-11-10 (LLVM 14.0.6)
# url_dir: https://download.amd.com/developer/eula/aocc-compiler
# - version: "4.1.0" # released 2023-08-04 (LLVM 16.0.3)
# url_dir: https://download.amd.com/developer/eula/aocc/aocc-4-1
- version: "4.2.0" # released 2024-02-27 (LLVM 16.0.3)
url_dir: https://download.amd.com/developer/eula/aocc/aocc-4-2
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip pyyaml
- name: Install compiler
run: |
cd /home/runner
wget --no-verbose ${{ matrix.url_dir }}/aocc-compiler-${{ matrix.version }}.tar
tar xpf aocc-compiler-${{ matrix.version }}.tar
rm aocc-compiler-${{ matrix.version }}.tar
./aocc-compiler-${{ matrix.version }}/install.sh
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: |
source /home/runner/setenv_AOCC.sh
python3 util/developers/run_all_testcases.py harness --show_logs --compiler flang
- name: Run all test cases with pyfabm
run: |
source /home/runner/setenv_AOCC.sh
python3 util/developers/run_all_testcases.py pyfabm --show_logs --compiler flang ${{ matrix.pyfabm_cmake_args }}
flang-new:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
os: [windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: cmd /C call {0}
env:
CMAKE_GENERATOR: Ninja
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
- name: Install Python dependencies
run: conda install -c conda-forge pyyaml flang>=19.0 ninja c-compiler
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run all test cases with host emulators
run: |
set CMAKE_GENERATOR_PLATFORM=
set CMAKE_GENERATOR_TOOLSET=
python util/developers/run_all_testcases.py harness --show_logs --compiler flang-new
- name: Run all test cases with pyfabm
run: |
set CMAKE_GENERATOR_PLATFORM=
set CMAKE_GENERATOR_TOOLSET=
python util/developers/run_all_testcases.py pyfabm --show_logs --compiler flang-new -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE
pyfabm:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
defaults:
run:
shell: bash -el {0}
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
- name: Install dependencies
run: conda install pip python-build
- name: Build distribution
run: python -m build
- name: Install
run: python -m pip install -v .
- name: Test
run: |
python -c "import pyfabm;print('pyfabm version =', getattr(pyfabm, '__version__', None))"
for f in testcases/*.yaml; do fabm_describe_model $f; done
for f in testcases/*.yaml; do fabm_complete_yaml --add_missing $f; done
- name: Run notebooks
if: matrix.python-version != '3.7' # due to https://github.com/conda-forge/webcolors-feedstock/issues/26
run: |
conda install ipython jupyterlab ipympl matplotlib scipy
cd testcases/python
for f in *.ipynb; do ipython --gui qt -c "%run $f"; done
- name: Type checking with mypy
if: matrix.python-version != '3.7'
run: |
conda install mypy pyyaml
mypy src/pyfabm
- name: Install with customization via command line arguments
run: |
rm -rf build
python -m pip install -v -C--build-option=build_ext -C--build-option="--cmake-opts=-DFABM_INSTITUTES=examples" .
- name: Install with customization via setup.cfg
run: |
rm -rf build
echo "[build_ext]" > setup.cfg
echo "cmake_opts=-DFABM_INSTITUTES=examples" >> setup.cfg
python -m pip install -v .
fabm0d:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Install NetCDF
run: |
sudo apt-get update
sudo apt-get install libnetcdff-dev
- name: Clone FABM
uses: actions/checkout@v4
with:
submodules: recursive
- name: Clone GOTM
uses: actions/checkout@v4
with:
repository: gotm-model/code
ref: v6.0
path: gotm
submodules: recursive
- name: Build
run: |
cmake -S src/drivers/0d -B build -DGOTM_BASE=gotm
cmake --build build --target install
stat ~/local/fabm/0d/bin/fabm0d
cmake:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
cmake-version: ["3.13"]
runs-on: ubuntu-latest
steps:
- name: Clone FABM
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download and extract cmake
run: |
wget --no-verbose https://cmake.org/files/v${{ matrix.cmake-version }}/cmake-${{ matrix.cmake-version }}.0-Linux-x86_64.tar.gz
tar -xvf cmake-${{ matrix.cmake-version }}.0-Linux-x86_64.tar.gz
- name: Build
run: |
cmake-${{ matrix.cmake-version }}.0-Linux-x86_64/bin/cmake -S . -B build
cmake-${{ matrix.cmake-version }}.0-Linux-x86_64/bin/cmake --build build --target install
ninja:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Clone FABM
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install ninja-build
- name: Build
run: |
cmake -S . -B build -G Ninja
cmake --build build --target install
binder:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python with conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
environment-file: .binder/environment.yml
activate-environment: fabm
- name: Install
run: .binder/postBuild
env:
REPO_DIR: .