Skip to content

Merge pull request #78 from AhmedBasem20/fix-badge #95

Merge pull request #78 from AhmedBasem20/fix-badge

Merge pull request #78 from AhmedBasem20/fix-badge #95

Workflow file for this run

name: Algorithm Analysis
on:
push:
branches:
- 'main'
- 'analysis/**'
jobs:
algorithms:
runs-on: ubuntu-latest
outputs: # here we use the outputs from steps, and set outputs for the job `configure`
algorithms: ${{ steps.algorithms.outputs.algorithms }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup_python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache pip
uses: actions/cache@v3
id: pip-cache
with:
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
path: ${{ env.pythonLocation }}
if: steps.pip-cache.outputs.cache-hit != 'true'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Read algorithms
id: algorithms
run: |
echo 'algorithms<<EOF' >> $GITHUB_OUTPUT
cat ./tests/IVIMmodels/unit_tests/algorithms.json >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Log algorithms
run: |
echo "${{fromJson(steps.algorithms.outputs.algorithms)}}"
echo "${{fromJson(steps.algorithms.outputs.algorithms).algorithms}}"
- name: Log algorithms file
run: cat ./tests/IVIMmodels/unit_tests/algorithms.json
build:
runs-on: ubuntu-latest
needs: algorithms
continue-on-error: false
strategy:
fail-fast: false
matrix:
algorithm: ${{fromJson(needs.algorithms.outputs.algorithms).algorithms}}
SNR: [10, 30, 50, 100, 200]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
if: steps.pip-cache.outputs.cache-hit != 'true'
- name: Restore cache
id: python-cache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
path: ${{ env.pythonLocation }}
- name: Generate fitting data
run: |
python -m pytest -m slow --selectAlgorithm ${{ matrix.algorithm }} --saveFileName test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv --SNR ${{ matrix.SNR }} --fitCount 300 --saveDurationFileName test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
- name: Upload raw data
uses: actions/upload-artifact@v3
with:
name: Working_Data
retention-days: 1
path: |
test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
merge:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Merge fitting results
run: |
head -n 1 $(ls artifacts/Working_Data/test_output_*.csv | head -n 1) > test_output.csv
tail -q -n +2 artifacts/Working_Data/test_output_*.csv >> test_output.csv
- name: Merge timing results
run: |
head -n 1 $(ls artifacts/Working_Data/test_duration_*.csv | head -n 1) > test_duration.csv
tail -q -n +2 artifacts/Working_Data/test_duration_*.csv >> test_duration.csv
- name: Upload merged artifacts
uses: actions/upload-artifact@v3
with:
name: Data
path: |
test_output.csv
test_duration.csv
analyze:
runs-on: ubuntu-latest
needs: merge
steps:
- uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
any::plyr
any::dplyr
any::tidyverse
any::data.table
any::ggplot2
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Data
- name: Generate figures
run: Rscript --vanilla tests/IVIMmodels/unit_tests/analyze.r test_output.csv test_duration.csv
- name: Upload figures
uses: actions/upload-artifact@v3
if: always()
with:
name: Figures
path: |
D.pdf
f.pdf
Dp.pdf
D_limited.pdf
f_limited.pdf
Dp_limited.pdf
durations.pdf
curve_plot.pdf
fitted_curves.pdf
compare:
runs-on: ubuntu-latest
needs: merge
steps:
- uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
any::tidyverse
any::assertr
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Data
- name: Test against previous results
run: Rscript --vanilla tests/IVIMmodels/unit_tests/compare.r test_output.csv test_reference.csv tests/IVIMmodels/unit_tests/reference_output.csv test_results.csv
- name: Upload data
uses: actions/upload-artifact@v3
if: always()
with:
name: Comparison
path: |
test_reference.csv
test_results.csv