Split analysis into matrix jobs #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Algorithm Analysis | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'analysis/**' | ||
jobs: | ||
read_algorithms: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Read algorithms | ||
id: read_algorithms | ||
run: | | ||
algorithms=$(cat tests/IVIMmodels/unit_tests/algorithms.json) | ||
echo "::set-output name=algorithms::$algorithms" | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: read_algorithms | ||
continue-on-error: false | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
algorithm: ${{ fromJson(needs.read_algorithms.outputs.algorithms).algorithms }} | ||
SNR: [10 30 50 100 200] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Generate fitting data | ||
run: | | ||
pip install pytest | ||
python -m pytest -m slow --selectAlgorithm ${{ matrix.algorithm }} --saveFileName test_output.csv --SNR ${{ matrix.SNR }} --fitCount 300 --saveDurationFileName test_duration.csv | ||
- name: Upload raw data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: RawData/raw_data_${{ matrix.algorithm }}_${{ matrix.SNR }} | ||
path: | | ||
test_output.csv | ||
test_duration.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: | | ||
cat artifacts/raw_data_*/test_output.csv > test_output.csv | ||
- name: Merge timing results | ||
run: | | ||
cat artifacts/raw_data_*/test_duration.csv > test_duration.csv | ||
- name: Upload merged artifacts | ||
uses: actions/upload-artifacts@v3 | ||
with: | ||
name: Raw Data | ||
path: | | ||
test_output.csv | ||
test_duration.csv | ||
analyze: | ||
runs-on: ubuntu-latest | ||
needs: merge | ||
steps: | ||
- 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: Raw 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 | ||
with: | ||
name: Fit 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 |