Skip to content

Commit

Permalink
Merge branch 'main' into linearize
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 authored Dec 23, 2024
2 parents 135a455 + 9dc1167 commit 95342f7
Show file tree
Hide file tree
Showing 32 changed files with 800 additions and 115 deletions.
53 changes: 21 additions & 32 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
docker_toml: ${{ steps.filter.outputs.docker_toml }}
dockerfiles: ${{ steps.set-matrix.outputs.dockerfiles }}
imagenames: ${{ steps.set-matrix.outputs.imagenames }}
docker_tasks: ${{ steps.set-matrix.outputs.docker_tasks }}
steps:
- name: Checkout mrpro repo
uses: actions/checkout@v4
Expand All @@ -39,20 +38,17 @@ jobs:
id: set-matrix
if: steps.filter.outputs.docker_toml == 'true' || github.event_name == 'push'
run: |
cd ./docker/
ls
dockerfiles=$(ls Dockerfile_* | jq -R -s -c 'split("\n")[:-1]')
echo "dockerfiles: $dockerfiles"
echo "dockerfiles=$dockerfiles" >> $GITHUB_OUTPUT
imagenames=$(ls Dockerfile_* | sed -e 's/Dockerfile_/ghcr.io\/ptb-mr\/mrpro_/' | jq -R -s -c 'split("\n")[:-1]')
echo "image names: $imagenames"
echo "imagenames=$imagenames" >> $GITHUB_OUTPUT
# docker_tasks is a list of pairs (dictionaries) with keys 'filepath' and 'image_name' like:
# [{"filepath": "docker/Dockerfile_x1", "image_name": "ghcr.io/ptb-mr/mrpro_x1"}, ...]
docker_tasks=$(find docker -type f -name 'Dockerfile*' | jq -R -s -c 'split("\n")[:-1]' | \
jq -r -c 'map({filepath: ., image_name: . | sub("docker/Dockerfile"; "ghcr.io\/ptb-mr\/mrpro")})')
echo "docker_tasks: $docker_tasks"
echo "docker_tasks=$docker_tasks" >> $GITHUB_OUTPUT
- name: Dockerfile overview
if: steps.filter.outputs.docker_toml == 'true' || github.event_name == 'push'
run: |
echo "final list of dockerfiles: ${{ steps.set-matrix.outputs.dockerfiles }}"
echo "final list of images: ${{ steps.set-matrix.outputs.imagenames }}"
echo "final list of docker_tasks: ${{ steps.set-matrix.outputs.docker_tasks }}"
push_test:
name: Create test images and push to GCR
Expand All @@ -64,16 +60,15 @@ jobs:
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create image name
- name: Get image basename
id: image_name
run: |
dockerfile=${{ matrix.dockerfile }}
echo "image_name=${dockerfile/Dockerfile_/ghcr.io/ptb-mr/mrpro_}" >> $GITHUB_OUTPUT
echo "dockerfile_basename=$(basename ${{ matrix.docker_task.filepath }})" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -89,11 +84,11 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha,scope=${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=${{ matrix.dockerfile }}
file: ./docker/${{ matrix.dockerfile }}
cache-from: type=gha,scope=$${{ steps.image_name.outputs.dockerfile_basename }})
cache-to: type=gha,mode=max,scope=${{ steps.image_name.outputs.dockerfile_basename }}
file: ${{ matrix.docker_task.filepath }}
push: true
tags: ${{ steps.image_name.outputs.image_name }}:test
tags: ${{ matrix.docker_task.image_name }}:test

test:
name: Test docker containers
Expand All @@ -105,10 +100,10 @@ jobs:
contents: write
strategy:
matrix:
imagename: ${{ fromJson(needs.get_dockerfiles.outputs.imagenames) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
# runs within Docker container
container:
image: ${{ matrix.imagename }}:test
image: ${{ matrix.docker_task.image_name }}:test
options: --user runner

steps:
Expand All @@ -134,17 +129,11 @@ jobs:
packages: write
strategy:
matrix:
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create image name
id: image_name
run: |
dockerfile=${{ matrix.dockerfile }}
echo "image_name=${dockerfile/Dockerfile_/ghcr.io/ptb-mr/mrpro_}" >> $GITHUB_OUTPUT
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
Expand All @@ -154,6 +143,6 @@ jobs:

- name: Pull and push Docker image with new tag
run: |
docker pull ${{ steps.image_name.outputs.image_name }}:test
docker tag ${{ steps.image_name.outputs.image_name }}:test ${{ steps.image_name.outputs.image_name }}:latest
docker push ${{ steps.image_name.outputs.image_name }}:latest
docker pull ${{ matrix.docker_task.image_name }}:test
docker tag ${{ matrix.docker_task.image_name }}:test ${{ matrix.docker_task.image_name }}:latest
docker push ${{ matrix.docker_task.image_name}}:latest
11 changes: 5 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ jobs:

- id: set-matrix
run: |
cd ./examples/
ls
echo "notebooks=$(ls *.ipynb | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
echo "notebooks=$(find examples -type f -name '*.ipynb' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
- name: Notebook overview
run: |
Expand Down Expand Up @@ -113,14 +111,14 @@ jobs:
env:
RUNNER: ${{ toJson(runner) }}
with:
notebook: ./examples/${{ matrix.notebook }}
notebook: ./${{ matrix.notebook }}

- name: Get artifact names
id: artifact_names
run: |
notebook=${{ matrix.notebook }}
echo "ARTIFACT_NAME=${notebook/.ipynb/}" >> $GITHUB_OUTPUT
echo "IPYNB_EXECUTED=${notebook}" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=$(basename ${notebook/.ipynb})" >> $GITHUB_OUTPUT
echo "IPYNB_EXECUTED=$(basename $notebook)" >> $GITHUB_OUTPUT
- name: Upload notebook
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -155,6 +153,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: ./docs/source/_notebooks/
merge-multiple: true

- name: Build docs
run: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ jobs:
outputs:
imagenames: ${{ steps.set-matrix.outputs.imagenames }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Retrieve Docker Image Names
id: set-matrix
env:
GH_TOKEN: ${{ secrets.GHCR_TOKEN }}
run: |
imagenames=$(curl -s --request GET \
--url "https://api.github.com/orgs/PTB-MR/packages?package_type=container" \
--header "Authorization: Bearer $GH_TOKEN" | jq -r '.[].name')
# 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 $(echo $imagenames)
for image in $imagenames
do
echo "checking $image ..."
if docker manifest inspect "ghcr.io/ptb-mr/"$image":latest" >/dev/null; then
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.1
hooks:
- id: ruff # linter
args: [--fix]
- id: ruff-format # formatter

- repo: https://github.com/crate-ci/typos
rev: v1.27.0
rev: typos-dict-v0.11.37
hooks:
- id: typos

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# MRpro
<h1 align="center">
<img src="docs/source/_static/logo.svg" alt="MRpro logo" width="50%">
</h1><br>

![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)
![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![Coverage Bagde](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/ckolbPTB/48e334a10caf60e6708d7c712e56d241/raw/coverage.json)

Expand Down Expand Up @@ -84,5 +86,3 @@ We are looking forward to your contributions via Pull-Requests.
4. Setup pre-commit hook: ``` pre-commit install ```

Please look at our [contributor guide](https://ptb-mr.github.io/mrpro/contributor_guide.html) for more information on the repository structure, naming conventions, and other useful information.


Loading

0 comments on commit 95342f7

Please sign in to comment.