Skip to content

Commit 1234c3e

Browse files
authored
Merge pull request #29 from nipype/auto-conv
updated ci-cd to use neurocontainer for the ANTs package used in tests
2 parents d4c0bb9 + bd93e8c commit 1234c3e

File tree

2 files changed

+85
-43
lines changed

2 files changed

+85
-43
lines changed

.github/workflows/ci-cd.yaml

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ permissions:
2727
id-token: write
2828

2929
env: # Define environment variables
30-
ANTS_VERSION: v2.5.1
31-
ANTS_INSTALL_PATH: /opt/ants
30+
SCIGET_NAME: ants
31+
SCIGET_VERSION: 2.6.0
32+
# ANTS_VERSION: v2.5.1
33+
# ANTS_INSTALL_PATH: /opt/ants
3234
# Force tox and pytest to use color
3335
FORCE_COLOR: true
3436
jobs:
@@ -56,47 +58,66 @@ jobs:
5658

5759
steps:
5860

59-
- name: Install prerequisite packages
60-
run: sudo apt install -y cmake
61-
6261
- name: Removed unnecessary tools to free space
6362
run: |
6463
sudo rm -rf /usr/share/dotnet
6564
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
6665
67-
- name: Create ANTs install directory
68-
run: |
69-
sudo mkdir -p ${{ env.ANTS_INSTALL_PATH }}
70-
sudo chown $USER ${{ env.ANTS_INSTALL_PATH }}
66+
- name: Checkout repo
67+
uses: actions/checkout@v4
7168

72-
- name: Cache ANTs Install
73-
id: cache-install
74-
uses: actions/cache@v4
75-
with:
76-
path: ${{ env.ANTS_INSTALL_PATH }}
77-
key: ants-${{ env.ANTS_VERSION }}-${{ runner.os }}
69+
- name: Install Apptainer and Lmod
70+
run: |
71+
sudo add-apt-repository -y ppa:apptainer/ppa
72+
sudo apt-get update
73+
sudo apt-get install -y lmod apptainer
7874
79-
- name: Install ANTs Package
80-
if: steps.cache-install.outputs.cache-hit != 'true'
75+
- name: Install Neurocommand
8176
run: |
82-
pushd ~
83-
git clone https://github.com/ANTsX/ANTs.git
84-
pushd ./ANTs
85-
git checkout ${{ env.ANTS_VERSION }}
86-
popd
87-
mkdir build install
88-
cd build
89-
cmake -DCMAKE_INSTALL_PREFIX=${{ env.ANTS_INSTALL_PATH }} ../ANTs
90-
make -j 4
91-
cd ANTS-build
92-
make install
93-
echo "Installation completed successfully"
94-
echo "PATH=${{ env.ANTS_INSTALL_PATH }}/bin:$PATH" >> $GITHUB_ENV
95-
echo "LD_LIBRARY_PATH=${{ env.ANTS_INSTALL_PATH }}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
77+
git clone https://github.com/NeuroDesk/neurocommand.git
78+
pushd neurocommand
79+
pip3 install -r neurodesk/requirements.txt --user
80+
bash build.sh --cli
81+
echo "APPTAINER_BINDPATH=`pwd -P`" >> $GITHUB_ENV
82+
83+
source /etc/profile.d/lmod.sh
84+
./containers.sh "${{ env.SCIGET_NAME }}" | grep -E "^\s*\|\s*${{ env.SCIGET_NAME }}\s*\|\s*${{ env.SCIGET_VERSION }}\s*\|" | awk -F '|' '{gsub(/ /,"",$4); print $4}'
85+
SCIGET_BUILDVERSION=$(./containers.sh "${{ env.SCIGET_NAME }}" | grep -E "^\s*\|\s*${{ env.SCIGET_NAME }}\s*\|\s*${{ env.SCIGET_VERSION }}\s*\|" | awk -F '|' '{gsub(/ /,"",$4); print $4}')
86+
87+
./local/fetch_containers.sh ${{ env.SCIGET_NAME }} ${{ env.SCIGET_VERSION }} $SCIGET_BUILDVERSION
88+
echo "SCIGET_BUILDVERSION=$SCIGET_BUILDVERSION" >> $GITHUB_ENV
9689
popd
9790
98-
- name: Checkout repo
99-
uses: actions/checkout@v4
91+
# - name: Create ANTs install directory
92+
# run: |
93+
# sudo mkdir -p ${{ env.ANTS_INSTALL_PATH }}
94+
# sudo chown $USER ${{ env.ANTS_INSTALL_PATH }}
95+
96+
# - name: Cache ANTs Install
97+
# id: cache-install
98+
# uses: actions/cache@v4
99+
# with:
100+
# path: ${{ env.ANTS_INSTALL_PATH }}
101+
# key: ants-${{ env.ANTS_VERSION }}-${{ runner.os }}
102+
103+
# - name: Install ANTs Package
104+
# if: steps.cache-install.outputs.cache-hit != 'true'
105+
# run: |
106+
# pushd ~
107+
# git clone https://github.com/ANTsX/ANTs.git
108+
# pushd ./ANTs
109+
# git checkout ${{ env.ANTS_VERSION }}
110+
# popd
111+
# mkdir build install
112+
# cd build
113+
# cmake -DCMAKE_INSTALL_PREFIX=${{ env.ANTS_INSTALL_PATH }} ../ANTs
114+
# make -j 4
115+
# cd ANTS-build
116+
# make install
117+
# echo "Installation completed successfully"
118+
# echo "PATH=${{ env.ANTS_INSTALL_PATH }}/bin:$PATH" >> $GITHUB_ENV
119+
# echo "LD_LIBRARY_PATH=${{ env.ANTS_INSTALL_PATH }}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
120+
# popd
100121

101122
- name: Set up Python ${{ matrix.python-version }}
102123
uses: actions/setup-python@v5
@@ -110,7 +131,12 @@ jobs:
110131
- name: Show tox config
111132
run: tox c
112133
- name: Run tox
113-
run: tox -v --exit-and-dump-after 1200
134+
run: |
135+
source /etc/profile.d/lmod.sh
136+
module use $PWD/neurocommand/local/containers/modules/
137+
module load ${{ env.SCIGET_NAME }}/${{ env.SCIGET_VERSION }}
138+
tox -v --exit-and-dump-after 1200
139+
114140
- name: Upload coverage to Codecov
115141
uses: codecov/codecov-action@v5
116142
with:

nipype-auto-conv/generate

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44
conv_dir=$(dirname $0)
55

66
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
7+
AUTO_CONV_SUFFIX="-auto-conv"
8+
REBASED_SUFFIX="-rebased-on-auto-conv"
79

810
if ! git diff-index --quiet HEAD --; then
911
echo "Current branch '$CURRENT_BRANCH' has uncommitted changes. Please commit or stash them before proceeding."
@@ -12,24 +14,38 @@ fi
1214

1315
echo "Automatically converting Nipype tasks to Pydra tasks..."
1416

15-
echo "Apply latest changes to nipype-auto-conv specs to auto-conv branch..."
16-
git fetch origin auto-conv || echo "Wasn't able to fetch origin/auto-conv, please check your internet connection"
17-
git checkout -b ${CURRENT_BRANCH}-auto-conv
17+
echo "Create '$CURRENT_BRANCH$REBASED_SUFFIX' and '$CURRENT_BRANCH$AUTO_CONV_SUFFIX' branches if not present and switch to $CURRENT_BRANCH$AUTO_CONV_SUFFIX"
18+
echo "NB: $CURRENT_BRANCH$AUTO_CONV_SUFFIX will contain the conversion specs from '$CURRENT_BRANCH' and the auto-converted tasks,"
19+
echo "wherease '$CURRENT_BRANCH$REBASED_SUFFIX' will be the changes in the current branch rebased on that"
20+
if [ "$CURRENT_BRANCH" == "*$REBASED_SUFFIX"]; then
21+
BASE_BRANCH=${CURRENT_BRANCH%"$REBASED_SUFFIX"}$AUTO_CONV_SUFFIX
22+
REBASE_BRANCH=$CURRENT_BRANCH
23+
git checkout $BASE_BRANCH
24+
git reset --hard $CURRENT_BRANCH
25+
else
26+
REBASE_BRANCH=${CURRENT_BRANCH}$REBASED_SUFFIX
27+
BASE_BRANCH=${CURRENT_BRANCH}$AUTO_CONV_SUFFIX
28+
git checkout -b $REBASE_BRANCH
29+
git checkout -b $BASE_BRANCH
30+
fi
31+
32+
echo "Apply nipype-auto-conv spec changes between current branch and the main auto-conv branch to the rebase branch..."
33+
git fetch origin auto-conv
1834
git reset origin/auto-conv
1935
git add $conv_dir/specs
2036
git commit -m "Update auto-conv specs with latest changes from '$CURRENT_BRANCH'" || echo true
21-
# Ignore any other changes outside the auto-conv directory
37+
# Ignore any other changes outside the nipype-auto-conv/specs directory
2238
git reset --hard HEAD
2339

2440
echo "Running nipype2pydra conversion..."
2541
nipype2pydra convert $conv_dir/specs $conv_dir/..
2642

27-
echo "Committing converted tasks to ${CURRENT_BRANCH}-auto-conv..."
43+
echo "Committing converted tasks to ${CURRENT_BRANCH}$AUTO_CONV_SUFFIX..."
2844
git add pydra/tasks/ants
2945
git commit -m "Auto-converted Nipype tasks to Pydra tasks" || echo true
3046

31-
echo "Rebasing '$CURRENT_BRANCH' to apply changes..."
32-
git checkout $CURRENT_BRANCH
33-
git rebase ${CURRENT_BRANCH}-auto-conv
47+
echo "Rebasing '$REBASE_BRANCH' to apply changes..."
48+
git checkout $REBASE_BRANCH
49+
git rebase $BASE_BRANCH
3450

35-
echo "Successfully converted Nipype tasks to Pydra tasks and rebased '$CURRENT_BRANCH' on top of the 'auto-conv' branch."
51+
echo "Successfully converted Nipype tasks to Pydra tasks and rebased manual edits over the top of them in '$REBASE_BRANCH'

0 commit comments

Comments
 (0)