Skip to content

Commit

Permalink
Merge branch 'topic/default/ci-doc-nox' into 'branch/default'
Browse files Browse the repository at this point in the history
CI with Nox

See merge request fluiddyn/transonic!128
  • Loading branch information
paugier committed Jan 16, 2024
2 parents 35bb54f + ec6059f commit 3499280
Show file tree
Hide file tree
Showing 150 changed files with 6,019 additions and 1,944 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML

34 changes: 34 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI Linux

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: apt install
run: |
sudo apt install -y libopenmpi-dev
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pdm nox
- name: Test with nox
run: |
nox -s test_without_pythran test_with_pythran
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
31 changes: 31 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI-windows

on:
- push
- pull_request

jobs:
tests:
runs-on: windows-2022
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
- uses: prefix-dev/[email protected]
with:
pixi-version: v0.11.1
cache: false
- name: Tests
run: |
pixi run install-editable
pixi run pytest tests
pixi run mpirun -np 2 pytest tests
echo "TRANSONIC_BACKEND=python" >> $GITHUB_ENV
pixi run pytest tests
echo "TRANSONIC_BACKEND=numba" >> $GITHUB_ENV
pixi run pytest tests
42 changes: 27 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
stages:
- pixi
- image
- lint
- test
Expand All @@ -7,20 +8,25 @@ stages:
- release

variables:
CODECOV_TOKEN: b1c3afe7-4ef3-4c69-9656-78beec52ec16
OMPI_ALLOW_RUN_AS_ROOT: "1"
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: "1"
PDM_CACHE_DIR: ${CI_PROJECT_DIR}/.pdm-cache

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

before_script:
- export PATH=/root/.local/bin:$PATH
- pip install -U pdm tox tox-pdm --user

pixi:test:
stage: pixi
image: registry.heptapod.net:443/fluiddyn/fluidsim/ci/default:pixi
script:
- pixi info
- pixi run install-editable
- pixi run pytest tests
- pixi run mpirun -np 2 pytest tests
- TRANSONIC_BACKEND=python pixi run pytest tests


# Build an image for the above tasks; this should be a scheduled job, as
# it is quite unnecessary to run on every invocation.
CI image:
image:build:
stage: image
tags:
- container-registry-push
Expand Down Expand Up @@ -50,44 +56,48 @@ CI image:
--single-snapshot
--cleanup
--destination registry.heptapod.net:443/fluiddyn/transonic/ci/$CI_COMMIT_HG_BRANCH:stable
# --destination registry.heptapod.net:443/fluiddyn/transonic/ci/default:stable
validate_code:
stage: lint
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- pdm install -G dev
- pdm run make lint


step_without_pythran:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310,codecov
- nox -s test_without_pythran

step_pythran_then_cython:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310-pythran,py310-cython,codecov
- nox -s test_with_pythran test_with_cython

step_pythran_cython:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310-pythran-cython
- nox -s test_with_pythran_cython


pages:
stage: publish
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- pdm install -G doc
Expand All @@ -107,6 +117,7 @@ pages:
expire_in: 5 days
when: always


build:package:
stage: build
before_script:
Expand All @@ -126,6 +137,7 @@ build:package:
paths:
- ${PDM_CACHE_DIR}


# manually set PDM_PUBLISH_PASSWORD in web interface to your pypi API token
release:package:
stage: release
Expand Down
8 changes: 5 additions & 3 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ doc/**.zip

*.so

build/*
build
dist/*.tar.gz
dist*
.tox/*
.coverage/*
.tox
.coverage
.nox
.pixi

**/tmp*.py

Expand Down
10 changes: 6 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Release notes

## Future

See the [ROADMAP.md file](https://transonic.readthedocs.io/en/latest/roadmap.html).

% Unreleased_
% -----------

## [0.6.0] (unpublished)

- Support for [Meson build](https://transonic.readthedocs.io/en/latest/packaging.html)
through `transonic --meson`
- Support for Python 3.12

## [0.5.3] (2023-08-21)

- [!110](https://foss.heptapod.net/fluiddyn/transonic/-/merge_requests/110)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
COV=pytest --cov --cov-config=pyproject.toml

develop:
pdm install
pdm sync --clean

black:
black -l 82 src _transonic_testing data_tests tests
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Documentation status](https://readthedocs.org/projects/transonic/badge/?version=latest)](http://transonic.readthedocs.org)
![Supported Python versions](https://img.shields.io/pypi/pyversions/transonic.svg)
[![Heptapod CI](https://foss.heptapod.net/fluiddyn/transonic/badges/branch/default/pipeline.svg)](https://foss.heptapod.net/fluiddyn/transonic/-/pipelines)
[![Github Actions](https://github.com/fluiddyn/transonic/actions/workflows/ci.yml/badge.svg?branch=branch/default)](https://github.com/fluiddyn/transonic/actions)
[![mybinder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fluiddyn/transonic/branch/default?urlpath=lab/tree/doc/ipynb/executed)
[![sonarcloud](https://sonarcloud.io/api/project_badges/measure?project=fluiddyn_transonic&metric=alert_status)](https://sonarcloud.io/dashboard?id=fluiddyn_transonic)

Expand Down
89 changes: 45 additions & 44 deletions data_tests/package_for_test_meson/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,10 @@

project('package_for_test_meson', 'cpp')

py = import('python').find_installation(pure: false)

# Taken from Scipy

# This uses the path as is, and avoids running the interpreter.
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
if incdir_numpy == 'not-given'
# see also what is done in Scipy and Fluidsim (more robust)
incdir_numpy = run_command(py,
[
'-c',
'''import numpy as np
incdir = np.get_include()
print(incdir)
'''
],
check: true
).stdout().strip()

else
_incdir_numpy_abs = incdir_numpy
endif

inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)
# https://mesonbuild.com/Python-module.html
py_mod = import('python')
py = py_mod.find_installation('python3', pure: false)
py_dep = py.dependency()

backend = get_option('transonic-backend')

Expand All @@ -40,24 +19,47 @@ endif

use_pythran = backend.contains('pythran')
if use_pythran
incdir_numpy = run_command(
py,
[
'-c',
'''import os
import numpy as np
try:
incdir = os.path.relpath(np.get_include())
except Exception:
incdir = np.get_include()
print(incdir)'''
],
check: true
).stdout().strip()

pythran = find_program('pythran', native: true)
inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)

# This external-property may not be needed if we can use the native include
# dir, see https://github.com/serge-sans-paille/pythran/issues/1394
incdir_pythran = meson.get_external_property('pythran-include-dir', 'not-given')
if incdir_pythran == 'not-given'
incdir_pythran = run_command(py,
incdir_pythran = run_command(
py,
[
'-c',
'''import pythran
incdir = pythran.get_include()
print(incdir)
'''
'''import os
import pythran;
incdir = os.path.dirname(pythran.__file__)
try:
incdir = os.path.relpath(incdir)
except Exception:
pass
print(incdir)'''
],
check: true
).stdout().strip()
endif

pythran = find_program('pythran', native: true)

cpp_args_pythran = [
'-DENABLE_PYTHON_MODULE',
'-D__PYTHRAN__=3',
'-DPYTHRAN_BLAS_NONE'
]

if get_option('use-xsimd') == true
# xsimd is unvendored from pythran by conda-forge, and due to a compiler
Expand All @@ -68,22 +70,21 @@ print(incdir)
include_directories: incdir_pythran,
dependencies: xsimd_dep,
)
cpp_args_pythran += ['-DUSE_XSIMD']
else
pythran_dep = declare_dependency(
include_directories: incdir_pythran,
)
endif

cpp_args_pythran = [
'-DENABLE_PYTHON_MODULE',
'-D__PYTHRAN__=3',
'-DPYTHRAN_BLAS_NONE'
]

pythran_complex_hook = get_option('pythran-complex-hook')
if pythran_complex_hook == 'os-dependent'
pythran_complex_hook = host_machine.system() == 'linux'
endif

else
pythran_dep = []
if get_option('native')
cpp_args_pythran += ['-march=native', '-Ofast']
endif

endif

Expand Down
20 changes: 16 additions & 4 deletions data_tests/package_for_test_meson/meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ option(
value: 'pythran,python,numba',
description:
'pythran,python,numba (default), cython, numpy, numba; ' +
'or comma separated value representing multi-backends'
'or comma separated value representing multi-backends',
)
option('use-xsimd', type: 'boolean', value: true, description: 'use xsimd')
option(
'pythran-complex-hook',
'native',
type: 'boolean',
value: false,
description: 'Performance oriented and not portable build',
)
option(
'use-xsimd',
type: 'boolean',
value: true,
description: 'Pythran complex_hook option'
description: 'Turns on xsimd vectorization',
)
option(
'pythran-complex-hook',
type: 'combo',
choices: ['os-dependent', 'true', 'false'],
value: 'os-dependent',
description: 'Pythran complex_hook option',
)
2 changes: 1 addition & 1 deletion data_tests/saved__backend__/cython/block_fluidsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt):
# float64[][] diss2;
# float dt
# )
state_spect_n12[:] = (state_spect + ((dt / 2) * tendencies_n)) * diss2
state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2


arguments_blocks = {
Expand Down
Loading

0 comments on commit 3499280

Please sign in to comment.