update ref values #180
This file contains hidden or 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/**' | |
| - 'Fix_website' | |
| 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 torch --extra-index-url https://download.pytorch.org/whl/cpu | |
| 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@v4 | |
| with: | |
| name: Working_Data_${{ matrix.algorithm }}_${{ matrix.SNR }}_${{ github.run_attempt }} | |
| retention-days: 1 | |
| path: | | |
| test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv | |
| test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv | |
| overwrite: true | |
| merge: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Merge fitting results | |
| run: | | |
| mkdir -p merged | |
| # Find all test_output CSVs and merge them | |
| head -n 1 $(find artifacts -type f -name "test_output_*.csv" | head -n 1) > merged/test_output.csv | |
| find artifacts -type f -name "test_output_*.csv" | xargs tail -q -n +2 >> merged/test_output.csv | |
| - name: Merge timing results | |
| run: | | |
| mkdir -p merged | |
| head -n 1 $(find artifacts -type f -name "test_duration_*.csv" | head -n 1) > merged/test_duration.csv | |
| find artifacts -type f -name "test_duration_*.csv" | xargs tail -q -n +2 >> merged/test_duration.csv | |
| - name: Upload merged artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Data | |
| path: | | |
| merged/test_output.csv | |
| merged/test_duration.csv | |
| overwrite: true | |
| 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@v4 | |
| 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@v4 | |
| 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 | |
| overwrite: true | |
| 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@v4 | |
| 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@v4 | |
| if: always() | |
| with: | |
| name: Comparison | |
| path: | | |
| test_reference.csv | |
| test_results.csv | |
| overwrite: true |