Skip to content

updated ci-cd to use neurocontainer for the ANTs package used in tests #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
86fc691
updated ci-cd to use neurocontainer for the ANTs package used in tests
tclose Aug 8, 2025
add6a32
added sudo to apt-get commands
tclose Aug 8, 2025
090d3e4
debugging ci-cd
tclose Aug 8, 2025
ebb7737
debugging ci-cd more
tclose Aug 8, 2025
965eef7
more debugging of ci-cd
tclose Aug 8, 2025
094c457
fixing up ci-cd
tclose Aug 8, 2025
b6cc040
fixing up ci-cd
tclose Aug 8, 2025
56bc590
Install lmod
aswinnarayanan Aug 8, 2025
2a04c63
Run ci/cid on auto-conv branch
aswinnarayanan Aug 8, 2025
d0e0281
Debug module
aswinnarayanan Aug 8, 2025
46e356c
debugging lmod withing ci-cd
tclose Aug 8, 2025
817ace5
Test install lmod
aswinnarayanan Aug 8, 2025
c6845bc
fixed version of ants package
tclose Aug 8, 2025
795a118
Test module installation
aswinnarayanan Aug 8, 2025
afb814e
Setup shell profile for lmod
aswinnarayanan Aug 8, 2025
8acd7d1
Install apptainer
aswinnarayanan Aug 8, 2025
a6bda10
Fetch container buildversion
aswinnarayanan Aug 8, 2025
d1c9eb7
added module avail to ci-cd to debug
tclose Aug 11, 2025
cab7c0b
reworking generate script to allow regeneration of auto-conv on same …
tclose Aug 11, 2025
c95d642
more debugging
tclose Aug 11, 2025
f4983a3
fixing up modules path in ci-cd
tclose Aug 11, 2025
66eccc2
more ci-cd debugging
tclose Aug 11, 2025
7ab006d
reworking generate script
tclose Aug 11, 2025
b6b71f4
more debugging
tclose Aug 11, 2025
381f057
more debugging
tclose Aug 11, 2025
0849745
yet more debugging
tclose Aug 11, 2025
79067fd
yet more
tclose Aug 11, 2025
436eec5
Get debug info
aswinnarayanan Aug 11, 2025
5c5d478
Fix paths
aswinnarayanan Aug 11, 2025
098d8b0
Debug info
aswinnarayanan Aug 11, 2025
7de082e
Fix path to containers.sh
aswinnarayanan Aug 11, 2025
5b252ec
Replace TOOL with env.PKG_NAME
aswinnarayanan Aug 11, 2025
6c77cb7
Move package downlaoder to neurocontainer installation step
aswinnarayanan Aug 11, 2025
4139a61
Fix paths
aswinnarayanan Aug 11, 2025
e17dfbc
Debug info
aswinnarayanan Aug 11, 2025
232c0b3
Debug info
aswinnarayanan Aug 11, 2025
5b4e6cb
Use ants 2.6.0
aswinnarayanan Aug 12, 2025
a4b6718
Debug info
aswinnarayanan Aug 12, 2025
65c0b63
Debug
aswinnarayanan Aug 12, 2025
82add1d
Move checkout to pre installation
aswinnarayanan Aug 12, 2025
5d91b6f
Remove debug info
aswinnarayanan Aug 12, 2025
6bd3d7d
Disable ci trigger on auto-conv branch
aswinnarayanan Aug 12, 2025
14843d5
Merge branch 'auto-conv' of github.com:aswinnarayanan/pydra-tasks-ant…
aswinnarayanan Aug 12, 2025
bd93e8c
Merge pull request #31 from aswinnarayanan/auto-conv
tclose Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 60 additions & 34 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ permissions:
id-token: write

env: # Define environment variables
ANTS_VERSION: v2.5.1
ANTS_INSTALL_PATH: /opt/ants
SCIGET_NAME: ants
SCIGET_VERSION: 2.6.0
# ANTS_VERSION: v2.5.1
# ANTS_INSTALL_PATH: /opt/ants
# Force tox and pytest to use color
FORCE_COLOR: true
jobs:
Expand Down Expand Up @@ -56,47 +58,66 @@ jobs:

steps:

- name: Install prerequisite packages
run: sudo apt install -y cmake

- name: Removed unnecessary tools to free space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- name: Create ANTs install directory
run: |
sudo mkdir -p ${{ env.ANTS_INSTALL_PATH }}
sudo chown $USER ${{ env.ANTS_INSTALL_PATH }}
- name: Checkout repo
uses: actions/checkout@v4

- name: Cache ANTs Install
id: cache-install
uses: actions/cache@v4
with:
path: ${{ env.ANTS_INSTALL_PATH }}
key: ants-${{ env.ANTS_VERSION }}-${{ runner.os }}
- name: Install Apptainer and Lmod
run: |
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update
sudo apt-get install -y lmod apptainer

- name: Install ANTs Package
if: steps.cache-install.outputs.cache-hit != 'true'
- name: Install Neurocommand
run: |
pushd ~
git clone https://github.com/ANTsX/ANTs.git
pushd ./ANTs
git checkout ${{ env.ANTS_VERSION }}
popd
mkdir build install
cd build
cmake -DCMAKE_INSTALL_PREFIX=${{ env.ANTS_INSTALL_PATH }} ../ANTs
make -j 4
cd ANTS-build
make install
echo "Installation completed successfully"
echo "PATH=${{ env.ANTS_INSTALL_PATH }}/bin:$PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${{ env.ANTS_INSTALL_PATH }}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
git clone https://github.com/NeuroDesk/neurocommand.git
pushd neurocommand
pip3 install -r neurodesk/requirements.txt --user
bash build.sh --cli
echo "APPTAINER_BINDPATH=`pwd -P`" >> $GITHUB_ENV

source /etc/profile.d/lmod.sh
./containers.sh "${{ env.SCIGET_NAME }}" | grep -E "^\s*\|\s*${{ env.SCIGET_NAME }}\s*\|\s*${{ env.SCIGET_VERSION }}\s*\|" | awk -F '|' '{gsub(/ /,"",$4); print $4}'
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}')

./local/fetch_containers.sh ${{ env.SCIGET_NAME }} ${{ env.SCIGET_VERSION }} $SCIGET_BUILDVERSION
echo "SCIGET_BUILDVERSION=$SCIGET_BUILDVERSION" >> $GITHUB_ENV
popd

- name: Checkout repo
uses: actions/checkout@v4
# - name: Create ANTs install directory
# run: |
# sudo mkdir -p ${{ env.ANTS_INSTALL_PATH }}
# sudo chown $USER ${{ env.ANTS_INSTALL_PATH }}

# - name: Cache ANTs Install
# id: cache-install
# uses: actions/cache@v4
# with:
# path: ${{ env.ANTS_INSTALL_PATH }}
# key: ants-${{ env.ANTS_VERSION }}-${{ runner.os }}

# - name: Install ANTs Package
# if: steps.cache-install.outputs.cache-hit != 'true'
# run: |
# pushd ~
# git clone https://github.com/ANTsX/ANTs.git
# pushd ./ANTs
# git checkout ${{ env.ANTS_VERSION }}
# popd
# mkdir build install
# cd build
# cmake -DCMAKE_INSTALL_PREFIX=${{ env.ANTS_INSTALL_PATH }} ../ANTs
# make -j 4
# cd ANTS-build
# make install
# echo "Installation completed successfully"
# echo "PATH=${{ env.ANTS_INSTALL_PATH }}/bin:$PATH" >> $GITHUB_ENV
# echo "LD_LIBRARY_PATH=${{ env.ANTS_INSTALL_PATH }}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# popd

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -110,7 +131,12 @@ jobs:
- name: Show tox config
run: tox c
- name: Run tox
run: tox -v --exit-and-dump-after 1200
run: |
source /etc/profile.d/lmod.sh
module use $PWD/neurocommand/local/containers/modules/
module load ${{ env.SCIGET_NAME }}/${{ env.SCIGET_VERSION }}
tox -v --exit-and-dump-after 1200

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
34 changes: 25 additions & 9 deletions nipype-auto-conv/generate
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
conv_dir=$(dirname $0)

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
AUTO_CONV_SUFFIX="-auto-conv"
REBASED_SUFFIX="-rebased-on-auto-conv"

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

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

echo "Apply latest changes to nipype-auto-conv specs to auto-conv branch..."
git fetch origin auto-conv || echo "Wasn't able to fetch origin/auto-conv, please check your internet connection"
git checkout -b ${CURRENT_BRANCH}-auto-conv
echo "Create '$CURRENT_BRANCH$REBASED_SUFFIX' and '$CURRENT_BRANCH$AUTO_CONV_SUFFIX' branches if not present and switch to $CURRENT_BRANCH$AUTO_CONV_SUFFIX"
echo "NB: $CURRENT_BRANCH$AUTO_CONV_SUFFIX will contain the conversion specs from '$CURRENT_BRANCH' and the auto-converted tasks,"
echo "wherease '$CURRENT_BRANCH$REBASED_SUFFIX' will be the changes in the current branch rebased on that"
if [ "$CURRENT_BRANCH" == "*$REBASED_SUFFIX"]; then
BASE_BRANCH=${CURRENT_BRANCH%"$REBASED_SUFFIX"}$AUTO_CONV_SUFFIX
REBASE_BRANCH=$CURRENT_BRANCH
git checkout $BASE_BRANCH
git reset --hard $CURRENT_BRANCH
else
REBASE_BRANCH=${CURRENT_BRANCH}$REBASED_SUFFIX
BASE_BRANCH=${CURRENT_BRANCH}$AUTO_CONV_SUFFIX
git checkout -b $REBASE_BRANCH
git checkout -b $BASE_BRANCH
fi

echo "Apply nipype-auto-conv spec changes between current branch and the main auto-conv branch to the rebase branch..."
git fetch origin auto-conv
git reset origin/auto-conv
git add $conv_dir/specs
git commit -m "Update auto-conv specs with latest changes from '$CURRENT_BRANCH'" || echo true
# Ignore any other changes outside the auto-conv directory
# Ignore any other changes outside the nipype-auto-conv/specs directory
git reset --hard HEAD

echo "Running nipype2pydra conversion..."
nipype2pydra convert $conv_dir/specs $conv_dir/..

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

echo "Rebasing '$CURRENT_BRANCH' to apply changes..."
git checkout $CURRENT_BRANCH
git rebase ${CURRENT_BRANCH}-auto-conv
echo "Rebasing '$REBASE_BRANCH' to apply changes..."
git checkout $REBASE_BRANCH
git rebase $BASE_BRANCH

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