Skip to content

Commit

Permalink
Moving Fastsurfer and Pytest environment setup to local_runner image,…
Browse files Browse the repository at this point in the history
… thus simplifying, and streamlining the workflow and improving execution time significantly.

Adding Labelled output directories for each run

Removing unnecessary import statements from pytest files
  • Loading branch information
taha-abdullah committed Sep 10, 2024
1 parent 450b902 commit af9be34
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 64 deletions.
62 changes: 6 additions & 56 deletions .github/workflows/quicktest_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,53 +62,11 @@ jobs:
echo "Error: FreeSurfer installation directory does not exist at $FREESURFER_HOME"
exit 1
fi
# Set up Python using setup-python@v3 action
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
# Check if FastSurfer environment already exists
- name: Check Environment
run: |
if [ ! -f "$MAMBAPATH" ]; then
echo "FastSurfer environment does not exist. Creating FastSurfer Environment..."
echo "HAS_MAMBA=true" >> $GITHUB_OUTPUT
else
echo "FastSurfer environment exists. Skipping FastSurfer Environment creation..."
echo "HAS_MAMBA=false" >> $GITHUB_OUTPUT
fi
id: check-environment
# Create FastSurfer environment if it does not exist
- name: Create FastSurfer Environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: env/fastsurfer.yml
micromamba-root-path: $MAMBAROOT
micromamba-binary-path: $MAMBAPATH
cache-downloads: true
cache-environment: true
init-shell: none
if: steps.check-environment.outputs.HAS_MAMBA == 'true'
# Set up cache for python packages
- name: Cache Python packages
uses: actions/cache@v3
with:
path: /home/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Install required python packages
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip \
setuptools wheel
python -m pip install --progress-bar off .[test]
# Run fastsurfer on list of subjects
# Run FastSurfer on test subjects
- name: Run FastSurfer
run: |
echo "Running FastSurfer..."
export FREESURFER_HOME=/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.sh
echo "Output will be saved in data/${GITHUB_SHA:0:7}"
export FASTSURFER_HOME=$(pwd)
export THIS_RUN_OUTDIR=${GITHUB_SHA:0:7}
mkdir -p $SUBJECTS_DIR/$THIS_RUN_OUTDIR
Expand All @@ -120,18 +78,10 @@ jobs:
# Test fastsurfer output
run-pytest:
runs-on: self-hosted
if: always()
needs: run-fastsurfer
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Cache Python packages
uses: actions/cache@v3
with:
path: /home/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Run pytest
run: python -m pytest test/quick_test
run: |
source /venv-pytest/bin/activate
python -m pytest test/quick_test
1 change: 0 additions & 1 deletion test/quick_test/test_errors_in_logfiles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import pytest
import yaml
from pathlib import Path
Expand Down
2 changes: 0 additions & 2 deletions test/quick_test/test_file_existence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import pytest
import yaml

from .common import *

Expand Down
3 changes: 0 additions & 3 deletions test/quick_test/test_images.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import pytest
from pathlib import Path
import nibabel as nib
import nibabel.cmdline.diff
import numpy as np
import yaml

from collections import OrderedDict

Expand Down
2 changes: 0 additions & 2 deletions test/quick_test/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from .conftest import *

import os
from pathlib import Path

import pandas as pd
import pytest
import yaml
import numpy as np

from .common import *

Expand Down

0 comments on commit af9be34

Please sign in to comment.