Skip to content

Add support for viewed_as_real #2289

Add support for viewed_as_real

Add support for viewed_as_real #2289

Workflow file for this run

name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
BART_VERSION: "1.0.0"
ref_backend: "finufft"
jobs:
get-commit-message:
runs-on: ubuntu-latest
outputs:
message: ${{ steps.get_commit_message.outputs.message }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get commit message
id: get_commit_message
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo "Commit message $COMMIT_MESSAGE"
echo "::set-output name=message::$COMMIT_MESSAGE"
test-cpu:
runs-on: cpu
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
strategy:
matrix:
backend: [finufft, pynfft, pynufft-cpu, bart, sigpy, torchkbnufft-cpu, ducc0]
exclude:
- backend: bart
- backend: pynufft-cpu
- backend: torchkbnufft-cpu
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup UV
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install Python Deps
shell: bash
run: |
uv sync --extra test --extra ${{env.ref_backend}} --extra ${{ matrix.backend }}
- name: Install BART if needed
if: ${{ matrix.backend == 'bart' || env.ref_backend == 'bart'}}
shell: bash
run: |
cd $RUNNER_WORKSPACE
sudo apt-get install make gcc libfftw3-dev liblapacke-dev libpng-dev libopenblas-dev
wget https://github.com/mrirecon/bart/archive/v${{ env.BART_VERSION }}.tar.gz
tar xzvf v${{ env.BART_VERSION }}.tar.gz
cd bart-${{ env.BART_VERSION }}
make
echo $PWD >> $GITHUB_PATH
- name: Run Tests
shell: bash
run: |
export COVERAGE_FILE=coverage_${{ matrix.backend }}
uv run pytest -k='operators' --backend ${{ matrix.backend }} --ref ${{ env.ref_backend }} --cov --disable-pytest-warnings --cov-branch --cov-report=term --durations=10
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.backend }}
path: coverage_${{ matrix.backend }}
test-gpu:
runs-on: gpu
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
strategy:
matrix:
backend: [cufinufft, gpunufft, torchkbnufft-gpu, tensorflow]
exclude:
# There is an issue with tensorflow and cupy. This was working. See #156
- backend: tensorflow
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install mri-nufft and finufft
shell: bash
run: |
uv sync --extra finufft --extra ${{ matrix.backend }} --extra autodiff --extra test
- name: Run Tests
shell: bash
run: |
export COVERAGE_FILE=coverage_${{ matrix.backend }}
uv run pytest -k='operators' --ref ${{ env.ref_backend }} --backend ${{ matrix.backend }} --disable-pytest-warnings --cov --cov-branch --cov-report=term --durations=10
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.backend }}
path: coverage_${{ matrix.backend }}
test-other:
runs-on: [gpu]
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install mri-nufft and finufft
shell: bash
run: |
uv sync --extra test --extra autodiff --extra finufft --extra extra
uv pip install cupy-cuda13x[ctk]
- name: Run non operators tests
shell: bash
run: |
export COVERAGE_FILE=coverage_other
uv run pytest -n=4 -k "not operators" --cov --cov-branch --cov-report=term --durations=10 --disable-pytest-warnings
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: coverage_other
path: coverage_other
test-examples:
runs-on: gpu
needs: get-commit-message
if: ${{ !contains(needs.get-commit-message.outputs.message, '[style]') || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Restore cached brainweb-dl directory
uses: actions/cache/restore@v4
id: cache-restore
with:
path: ~/.cache/brainweb
key: ${{ runner.os }}-Brainweb
- name: Install Python deps
shell: bash
run: |
uv sync --extra test --extra dev --extra finufft --extra cufinufft --extra sigpy --extra gpunufft --extra extra --extra autodiff --extra doc --extra io
- name: Run examples
shell: bash
run: |
export COVERAGE_FILE=coverage_plots
export MRINUFFT_BACKEND=cufinufft
uv run pytest examples -n=4 --cov --cov-branch --cov-report=term --durations=10
- name: Cache brainweb-dl directory
uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ~/.cache/brainweb
key: ${{ runner.os }}-Brainweb
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: coverage_plots
path: coverage_plots
coverage:
runs-on: ubuntu-latest
needs: [test-cpu, test-gpu, test-examples, test-other]
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect Coverages
uses: actions/download-artifact@v4
with:
path: coverage_data
pattern: coverage_*
merge-multiple: true
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@v7
- name: add the coverage tool
shell: bash
run: |
uv sync
uv pip install coverage[toml]
- name: Combine coverage
run: |
export COVERAGE_FILE=coverage_combined
uv run coverage combine -a coverage_data/*
- name: Upload Combined coverage
uses: actions/upload-artifact@v4
with:
name: coverage_combined
path: coverage_combined
- name: Reports
run: |
export COVERAGE_FILE=coverage_combined
uv run coverage xml
uv run coverage report
echo COVERAGE_PERC=$(uv run coverage report | tail -n 1 | grep -oE [0-9\.]*?% | cut -d '%' -f1) >> $GITHUB_ENV
- name: Create a Coverage Badge
uses: emibcn/badge-action@v2.0.2
if: ${{github.event_name == 'push'}}
# run: |
# wget https://img.shields.io/badge/coverage-${{env.COVERAGE_PERC}}%25-green -O coverage_badge.svg
with:
path: coverage_badge.svg
label: coverage
status: ${{env.COVERAGE_PERC}}%
color: green
- name: Upload badge as artifact
if: ${{github.event_name == 'push'}}
uses: actions/upload-artifact@v4
with:
name: coverage_badge
path: coverage_badge.svg