Skip to content

Commit

Permalink
Merge pull request #318 from juaml/chore/fix-ci
Browse files Browse the repository at this point in the history
[CI]: Improve CI
  • Loading branch information
synchon authored Jun 21, 2024
2 parents b890e54 + 8d0956c commit 531589d
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 24 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,43 @@ jobs:
sudo tcsh @update.afni.binaries -package linux_ubuntu_16_64 -bindir /afni
echo "/afni" >> $GITHUB_PATH
if: matrix.python-version == 3.11
# Bypass AFNI installation failure
continue-on-error: true
- name: Check AFNI
run: |
echo "Using AFNI : $(afni --version)"
if: matrix.python-version == 3.11
# Bypass AFNI installation failure
continue-on-error: true
- name: Install ANTs
run: |
sudo apt-get install -y -qq unzip
curl -fsSL -o ants.zip https://github.com/ANTsX/ANTs/releases/download/v2.5.1/ants-2.5.1-ubuntu-22.04-X64-gcc.zip
curl -fsSL -o ants.zip https://github.com/ANTsX/ANTs/releases/download/v2.5.2/ants-2.5.2-ubuntu-22.04-X64-gcc.zip
unzip ants.zip -d /opt
mv /opt/ants-2.5.1/bin/* /opt/ants-2.5.1
mv /opt/ants-2.5.2/bin/* /opt/ants-2.5.2
rm ants.zip
echo "/opt/ants-2.5.1" >> $GITHUB_PATH
echo "/opt/ants-2.5.2" >> $GITHUB_PATH
if: matrix.python-version == 3.11
# Bypass ANTs installation failure
continue-on-error: true
- name: Check ANTs
run: |
echo "Using ANTs : $(antsRegistration --version)"
if: matrix.python-version == 3.11
# Bypass ANTs installation failure
continue-on-error: true
- name: Install FSL
run: |
sudo apt-get install -y -qq python3
curl -fsSL https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | python3 - -d /opt/fsl-6.0.6.4 -V 6.0.6.4
curl -fsSL https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | python - -d /opt/fsl/
FSLOUTPUTTYPE="NIFTI_GZ"
FSLMULTIFILEQUIT="TRUE"
FSLTCLSH="/opt/fsl-6.0.6.4/bin/fsltclsh"
FSLWISH="/opt/fsl-6.0.6.4/bin/fslwish"
FSLTCLSH="/opt/fsl/bin/fsltclsh"
FSLWISH="/opt/fsl/bin/fslwish"
FSLLOCKDIR=""
FSLMACHINELIST=""
FSLREMOTECALL=""
FSLGECUDAQ="cuda.q"
echo "/opt/fsl-6.0.6.4" >> $GITHUB_PATH
echo "/opt/fsl" >> $GITHUB_PATH
if: matrix.python-version == 3.11
# Bypass FSL installation failure
continue-on-error: true
Expand Down
1 change: 1 addition & 0 deletions docs/changes/newsfragments/318.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve CI to allow external tool installation to fail gracefully and update necessary dependency version and conditional checks by `Synchon Mandal`_
4 changes: 2 additions & 2 deletions junifer/api/tests/test_api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# License: AGPL

import platform as pl
import sys

import pytest

Expand Down Expand Up @@ -49,8 +50,7 @@ def test_get_dependency_information_short() -> None:
"looseversion",
]

python_minor_version = int(pl.python_version_tuple()[1])
if python_minor_version < 10:
if sys.version_info < (3, 11):
dependency_list.append("importlib_metadata")

assert frozenset(dependency_information.keys()) == frozenset(
Expand Down
9 changes: 6 additions & 3 deletions junifer/markers/brainprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

try:
from importlib.metadata import packages_distributions
except ImportError: # pragma: no cover
import sys


if sys.version_info < (3, 11): # pragma: no cover
from importlib_metadata import packages_distributions
else:
from importlib.metadata import packages_distributions

import uuid
from copy import deepcopy
Expand Down
4 changes: 2 additions & 2 deletions junifer/markers/falff/_afni_falff.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def compute(
convert_alff_cmd = [
"3dAFNItoNIFTI",
f"-prefix {alff_afni_to_nifti_out_path.resolve()}",
f"{alff_falff_out_path_prefix}_ALFF+tlrc.BRIK",
f"{alff_falff_out_path_prefix}_ALFF+orig.BRIK",
]
# Call 3dAFNItoNIFTI
run_ext_cmd(name="3dAFNItoNIFTI", cmd=convert_alff_cmd)
Expand All @@ -136,7 +136,7 @@ def compute(
convert_falff_cmd = [
"3dAFNItoNIFTI",
f"-prefix {falff_afni_to_nifti_out_path.resolve()}",
f"{alff_falff_out_path_prefix}_fALFF+tlrc.BRIK",
f"{alff_falff_out_path_prefix}_fALFF+orig.BRIK",
]
# Call 3dAFNItoNIFTI
run_ext_cmd(name="3dAFNItoNIFTI", cmd=convert_falff_cmd)
Expand Down
2 changes: 1 addition & 1 deletion junifer/markers/reho/_afni_reho.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def compute(
convert_cmd = [
"3dAFNItoNIFTI",
f"-prefix {reho_afni_to_nifti_out_path.resolve()}",
f"{reho_out_path_prefix}+tlrc.BRIK",
f"{reho_out_path_prefix}+orig.BRIK",
]
# Call 3dAFNItoNIFTI
run_ext_cmd(name="3dAFNItoNIFTI", cmd=convert_cmd)
Expand Down
10 changes: 7 additions & 3 deletions junifer/pipeline/pipeline_step_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

try:
from importlib.metadata import packages_distributions
except ImportError: # pragma: no cover
import sys


if sys.version_info < (3, 11): # pragma: no cover
from importlib_metadata import packages_distributions
else:
from importlib.metadata import packages_distributions


from importlib.util import find_spec
from itertools import chain
Expand Down
2 changes: 1 addition & 1 deletion junifer/preprocess/smoothing/_afni_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def preprocess(
convert_cmd = [
"3dAFNItoNIFTI",
f"-prefix {blur_afni_to_nifti_out_path.resolve()}",
f"{blur_out_path_prefix}+tlrc.BRIK",
f"{blur_out_path_prefix}+orig.BRIK",
]
# Call 3dAFNItoNIFTI
run_ext_cmd(name="3dAFNItoNIFTI", cmd=convert_cmd)
Expand Down
8 changes: 5 additions & 3 deletions junifer/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

try:
import sys


if sys.version_info < (3, 12):
from distutils.version import LooseVersion
except ImportError: # pragma: no cover
else: # pragma: no cover
from looseversion import LooseVersion

import logging
import sys
from pathlib import Path
from subprocess import PIPE, Popen, TimeoutExpired
from typing import Dict, NoReturn, Optional, Type, Union
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
"tqdm==4.66.1",
"templateflow>=23.0.0",
"lapy>=1.0.0,<2.0.0",
"importlib_metadata; python_version<'3.10'",
"importlib_metadata; python_version<'3.9'",
"looseversion==1.3.0; python_version>='3.12'",
]
dynamic = ["version"]
Expand Down

0 comments on commit 531589d

Please sign in to comment.