Skip to content

Add gradient and autodiff checks for linear operators #3921

Add gradient and autodiff checks for linear operators

Add gradient and autodiff checks for linear operators #3921

Workflow file for this run

name: PyTest
on:
pull_request:
push:
branches:
- main
jobs:
get_dockerfiles:
name: Get List of Dockerfiles for Containers
runs-on: ubuntu-latest
permissions:
packages: read
outputs:
imagenames: ${{ steps.set-matrix.outputs.imagenames }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve Docker Image Names
id: set-matrix
run: |
# search for Dockerfile* in the docker directory, replace "Dockerfile" prefix with "mrpro" and to imagenames
imagenames=$(find docker -type f -name 'Dockerfile*' -exec basename {} \; | sed 's/^Dockerfile/mrpro/')
echo "image names: $imagenames"
# if imagenames is empty - fail the workflow
if [ -z "$imagenames" ]; then
echo "No Dockerfiles found in the docker directory. Exiting..."
exit 1
fi
imagenames_latest=()
for image in $imagenames
do
echo "checking $image ..."
if docker manifest inspect "ghcr.io/ptb-mr/"$image":latest" >/dev/null; then
echo "... $image added"
imagenames_latest+=$image":"
fi
done
echo "image names with tag latest: $imagenames_latest"
imagenames_latest=$(echo $imagenames_latest | jq -R -c 'split(":")[:-1]')
echo "image names with tag latest: $imagenames_latest"
echo "imagenames=$imagenames_latest" >> $GITHUB_OUTPUT
- name: Dockerfile Overview
run: |
echo "Final list of images with tag latest: ${{ steps.set-matrix.outputs.imagenames }}"
test:
name: Run Tests and Coverage Report
needs: get_dockerfiles
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
imagename: ${{ fromJson(needs.get_dockerfiles.outputs.imagenames) }}
container:
image: ghcr.io/ptb-mr/${{ matrix.imagename }}:latest
options: --user runner
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install MRpro and Dependencies
# use cpu version of torch
run: pip install --index-url=https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple/ --upgrade --upgrade-strategy eager .[test]
- name: Install PyTest GitHub Annotation Plugin
run: pip install pytest-github-actions-annotate-failures
- name: Run PyTest and Generate Coverage Report
# shell bash sets the -o pipefail
run: |
pytest -n 4 -m "not cuda" --junitxml=pytest.xml \
--cov-report=term-missing:skip-covered --cov=mrpro | tee pytest-coverage.txt
shell: bash
- name: Upload PyTest Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-report-${{ matrix.imagename }}
path: |
pytest-coverage.txt
pytest.xml
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true