Skip to content

Commit

Permalink
env fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-abdullah committed Sep 6, 2024
1 parent 262d21e commit 8501c47
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 62 deletions.
66 changes: 12 additions & 54 deletions .github/workflows/quicktest_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,76 +62,34 @@ 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
- name: create env
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
if [[ "$(md5sum /fastsurfer/fastsurfer.yml)" != "$(md5sum env/fastsurfer.yml)" ]] ; then
mamba env create -n "fastsurfer_$GITHUB_SHA" -f env/fastsurfer.yml
mamba activate "fastsurfer_$GITHUB_SHA"
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
- name: Run FastSurfer
run: |
echo "Running FastSurfer..."
export FREESURFER_HOME=/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.sh
export FASTSURFER_HOME=$(pwd)
export THIS_RUN_OUTDIR=${GITHUB_SHA:0:7}
mkdir -p $SUBJECTS_DIR/$THIS_RUN_OUTDIR
./brun_fastsurfer.sh --subject_list $RUNNER_FS_MRI_DATA/subjects_list.txt \
--sd $SUBJECTS_DIR/$THIS_RUN_OUTDIR \
--parallel --threads 4 --3T --parallel_subjects surf
export TEST_DIR=$THIS_RUN_OUTDIR
- name: cleanup
run: |
if [[ "$(md5sum /fastsurfer/fastsurfer.yml)" != "$(md5sum env/fastsurfer.yml)" ]] ; then
mamba env remove -n "fastsurfer_$GITHUB_SHA"
fi
# Test fastsurfer output
run-pytest:
runs-on: self-hosted
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 8501c47

Please sign in to comment.