|
| 1 | +name: Algorithm Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + - 'analysis/**' |
| 8 | + |
| 9 | +jobs: |
| 10 | + algorithms: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: # here we use the outputs from steps, and set outputs for the job `configure` |
| 13 | + algorithms: ${{ steps.algorithms.outputs.algorithms }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - name: Set up Python |
| 17 | + id: setup_python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: "3.11" |
| 21 | + - name: Cache pip |
| 22 | + uses: actions/cache@v3 |
| 23 | + id: pip-cache |
| 24 | + with: |
| 25 | + key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 26 | + path: ${{ env.pythonLocation }} |
| 27 | + if: steps.pip-cache.outputs.cache-hit != 'true' |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + pip install -r requirements.txt |
| 32 | +
|
| 33 | + - name: Read algorithms |
| 34 | + id: algorithms |
| 35 | + run: | |
| 36 | + echo 'algorithms<<EOF' >> $GITHUB_OUTPUT |
| 37 | + cat ./tests/IVIMmodels/unit_tests/algorithms.json >> $GITHUB_OUTPUT |
| 38 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 39 | + - name: Log algorithms |
| 40 | + run: | |
| 41 | + echo "${{fromJson(steps.algorithms.outputs.algorithms)}}" |
| 42 | + echo "${{fromJson(steps.algorithms.outputs.algorithms).algorithms}}" |
| 43 | + - name: Log algorithms file |
| 44 | + run: cat ./tests/IVIMmodels/unit_tests/algorithms.json |
| 45 | + |
| 46 | + build: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: algorithms |
| 49 | + continue-on-error: false |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + algorithm: ${{fromJson(needs.algorithms.outputs.algorithms).algorithms}} |
| 54 | + SNR: [10, 30, 50, 100, 200] |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + - name: Set up Python |
| 58 | + uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.11" |
| 61 | + if: steps.pip-cache.outputs.cache-hit != 'true' |
| 62 | + - name: Restore cache |
| 63 | + id: python-cache |
| 64 | + uses: actions/cache@v3 |
| 65 | + with: |
| 66 | + key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 67 | + path: ${{ env.pythonLocation }} |
| 68 | + |
| 69 | + - name: Generate fitting data |
| 70 | + run: | |
| 71 | + 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 |
| 72 | + - name: Upload raw data |
| 73 | + uses: actions/upload-artifact@v3 |
| 74 | + with: |
| 75 | + name: Working_Data |
| 76 | + retention-days: 1 |
| 77 | + path: | |
| 78 | + test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv |
| 79 | + test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv |
| 80 | +
|
| 81 | + merge: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: build |
| 84 | + steps: |
| 85 | + - name: Download artifacts |
| 86 | + uses: actions/download-artifact@v3 |
| 87 | + with: |
| 88 | + path: artifacts |
| 89 | + - name: Merge fitting results |
| 90 | + run: | |
| 91 | + head -n 1 $(ls artifacts/Working_Data/test_output_*.csv | head -n 1) > test_output.csv |
| 92 | + tail -q -n +2 artifacts/Working_Data/test_output_*.csv >> test_output.csv |
| 93 | + - name: Merge timing results |
| 94 | + run: | |
| 95 | + head -n 1 $(ls artifacts/Working_Data/test_duration_*.csv | head -n 1) > test_duration.csv |
| 96 | + tail -q -n +2 artifacts/Working_Data/test_duration_*.csv >> test_duration.csv |
| 97 | + - name: Upload merged artifacts |
| 98 | + uses: actions/upload-artifact@v3 |
| 99 | + with: |
| 100 | + name: Data |
| 101 | + path: | |
| 102 | + test_output.csv |
| 103 | + test_duration.csv |
| 104 | +
|
| 105 | + analyze: |
| 106 | + runs-on: ubuntu-latest |
| 107 | + needs: merge |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v4 |
| 110 | + - name: Set up R |
| 111 | + uses: r-lib/actions/setup-r@v2 |
| 112 | + with: |
| 113 | + use-public-rspm: true |
| 114 | + - name: Install R dependencies |
| 115 | + uses: r-lib/actions/setup-r-dependencies@v2 |
| 116 | + with: |
| 117 | + packages: | |
| 118 | + any::plyr |
| 119 | + any::dplyr |
| 120 | + any::tidyverse |
| 121 | + any::data.table |
| 122 | + any::ggplot2 |
| 123 | + - name: Download artifacts |
| 124 | + uses: actions/download-artifact@v3 |
| 125 | + with: |
| 126 | + name: Data |
| 127 | + - name: Generate figures |
| 128 | + run: Rscript --vanilla tests/IVIMmodels/unit_tests/analyze.r test_output.csv test_duration.csv |
| 129 | + - name: Upload figures |
| 130 | + uses: actions/upload-artifact@v3 |
| 131 | + if: always() |
| 132 | + with: |
| 133 | + name: Figures |
| 134 | + path: | |
| 135 | + D.pdf |
| 136 | + f.pdf |
| 137 | + Dp.pdf |
| 138 | + D_limited.pdf |
| 139 | + f_limited.pdf |
| 140 | + Dp_limited.pdf |
| 141 | + durations.pdf |
| 142 | + curve_plot.pdf |
| 143 | + fitted_curves.pdf |
| 144 | +
|
| 145 | + compare: |
| 146 | + runs-on: ubuntu-latest |
| 147 | + needs: merge |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v4 |
| 150 | + - name: Set up R |
| 151 | + uses: r-lib/actions/setup-r@v2 |
| 152 | + with: |
| 153 | + use-public-rspm: true |
| 154 | + - name: Install R dependencies |
| 155 | + uses: r-lib/actions/setup-r-dependencies@v2 |
| 156 | + with: |
| 157 | + packages: | |
| 158 | + any::tidyverse |
| 159 | + any::assertr |
| 160 | + - name: Download artifacts |
| 161 | + uses: actions/download-artifact@v3 |
| 162 | + with: |
| 163 | + name: Data |
| 164 | + - name: Test against previous results |
| 165 | + 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 |
| 166 | + - name: Upload data |
| 167 | + uses: actions/upload-artifact@v3 |
| 168 | + if: always() |
| 169 | + with: |
| 170 | + name: Comparison |
| 171 | + path: | |
| 172 | + test_reference.csv |
| 173 | + test_results.csv |
0 commit comments