diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index d2e2b585..961764ef 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -27,11 +27,10 @@ permissions: id-token: write env: # Define environment variables - # Force tox and pytest to use color - FREESURFER_VERSION: 8.1.0 - FREESURFER_HOME: /opt/freesurfer - DOWNLOADS_DIR: /tmp/downloads + SCIGET_NAME: freesurfer + SCIGET_VERSION: 7.4.1 FORCE_COLOR: true + jobs: build: @@ -69,39 +68,28 @@ jobs: if: github.event_name == 'repository_dispatch' run: git checkout $(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}') - - name: Create installation directory - run: | - sudo mkdir -p $FREESURFER_HOME - sudo chown $USER $FREESURFER_HOME - - # - name: Cache Freesurfer Download - # id: cache-install - # uses: actions/cache@v4 - # with: - # path: ${{ env.DOWNLOADS_DIR }} - # key: freesurfer-${{ env.FREESURFER_VERSION }}-${{ runner.os }} - - - name: Download FreeSurfer - # if: steps.cache-install.outputs.cache-hit != 'true' + - name: Install Apptainer and Lmod run: | - sudo mkdir -p $DOWNLOADS_DIR - sudo chown $USER $DOWNLOADS_DIR - curl -s -o $DOWNLOADS_DIR/freesurfer-linux-ubuntu22_amd64-${{ env.FREESURFER_VERSION }}.tar.gz \ - https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${{ env.FREESURFER_VERSION }}/freesurfer-linux-ubuntu22_amd64-${{ env.FREESURFER_VERSION }}.tar.gz - shell: bash + sudo add-apt-repository -y ppa:apptainer/ppa + sudo apt-get update + sudo apt-get install -y lmod apptainer - - name: Install Freesurfer - env: - FREESURFER_LICENCE: ${{ secrets.FREESURFER_LICENCE }} + - name: Install Neurocommand run: | - pushd $DOWNLOADS_DIR/ - tar -zxpf freesurfer-linux-ubuntu22_amd64-${{ env.FREESURFER_VERSION }}.tar.gz - mv freesurfer/* ${{ env.FREESURFER_HOME }} + 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 - source ${{ env.FREESURFER_HOME }}/SetUpFreeSurfer.sh - echo $FREESURFER_LICENCE > ${{ env.FREESURFER_HOME }}/license.txt - echo "PATH=${{ env.FREESURFER_HOME }}/bin:$PATH" >> $GITHUB_ENV - + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -173,7 +161,7 @@ jobs: - name: Check for PyPI token on tag id: deployable - if: github.event_name == 'release' || github.event_name == 'repository_dispatch' + if: github.event_name == 'release' env: PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_API_TOKEN }}" run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi @@ -212,7 +200,7 @@ jobs: - name: Check for PyPI token on tag id: deployable - if: github.event_name == 'release' || github.event_name == 'repository_dispatch' + if: github.event_name == 'release' env: PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_EXTRAS_API_TOKEN }}" run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi @@ -228,7 +216,6 @@ jobs: deploy: needs: [build, test, deploy-fileformats, deploy-fileformats-extras] runs-on: ubuntu-latest - if: github.event_name == 'release' permissions: attestations: write id-token: write @@ -239,7 +226,9 @@ jobs: name: Packages path: dist - name: Upload to PyPI + if: github.event_name == 'release' uses: pypa/gh-action-pypi-publish@release/v1 + # Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets. # Secrets are not accessible in the if: condition [0], so set an output variable [1] diff --git a/README.md b/README.md index aeb7a9ca..7bc57ed0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pydra-freesurfer +# pydra-tasks-freesurfer [![PyPI - Version][pypi-version]][pypi-project] [![PyPI - Python Version][pypi-pyversions]][pypi-project] @@ -40,7 +40,7 @@ to facilitate their integration into more advanced processing workflows. ## Installation ```console -pip install pydra-freesurfer +pip install pydra-tasks-freesurfer ``` A separate installation of FreeSurfer is required to use this package. @@ -181,18 +181,18 @@ This project is distributed under the terms of the [Apache License, Version 2.0] [pydra]: https://nipype.github.io/pydra -[pypi-downloads]: https://static.pepy.tech/badge/pydra-freesurfer +[pypi-downloads]: https://static.pepy.tech/badge/pydra-tasks-freesurfer -[pypi-project]: https://pypi.org/project/pydra-freesurfer +[pypi-project]: https://pypi.org/project/pydra-tasks-freesurfer -[pypi-pyversions]: https://img.shields.io/pypi/pyversions/pydra-freesurfer.svg +[pypi-pyversions]: https://img.shields.io/pypi/pyversions/pydra-tasks-freesurfer.svg -[pypi-version]: https://img.shields.io/pypi/v/pydra-freesurfer.svg +[pypi-version]: https://img.shields.io/pypi/v/pydra-tasks-freesurfer.svg [status-docs-badge]: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat -[status-cicd-badge]: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml/badge.svg +[status-cicd-badge]: https://github.com/nipype/pydra-tasks-freesurfer/actions/workflows/ci-cd.yaml/badge.svg -[status-docs-link]: https://nipype.github.io/pydra-freesurfer/ +[status-docs-link]: https://nipype.github.io/pydra-tasks-freesurfer/ -[status-cicd-link]: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml \ No newline at end of file +[status-cicd-link]: https://github.com/nipype/pydra-tasks-freesurfer/actions/workflows/ci-cd.yaml diff --git a/pydra/tasks/freesurfer/__init__.py b/pydra/tasks/freesurfer/__init__.py index 979e4e1c..3117bb39 100644 --- a/pydra/tasks/freesurfer/__init__.py +++ b/pydra/tasks/freesurfer/__init__.py @@ -18,21 +18,5 @@ "pydra-freesurfer has not been properly installed, please run " f"`pip install -e {str(pkg_path)}` to install a development version" ) -if "nipype" not in __version__: - try: - from .auto._version import nipype_version, nipype2pydra_version - except ImportError: - warn( - "Nipype interfaces haven't been automatically converted from their specs in " - f"`nipype-auto-conv`. Please run `{str(pkg_path / 'nipype-auto-conv' / 'generate')}` " - "to generated the converted Nipype interfaces in pydra.tasks.freesurfer.v7_4.auto" - ) - else: - n_ver = nipype_version.replace(".", "_") - n2p_ver = nipype2pydra_version.replace(".", "_") - __version__ += ( - "_" if "+" in __version__ else "+" - ) + f"nipype{n_ver}_nipype2pydra{n2p_ver}" - __all__ = ["__version__"] diff --git a/pyproject.toml b/pyproject.toml index 6f451734..61a45488 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ dependencies = [ "fileformats >=0.15.4", "fileformats-datascience >=0.3.2", "fileformats-medimage >=0.10.5", + "fileformats-medimage_freesurfer", ] license = { file = "LICENSE" } authors = [{ name = "Nipype developers", email = "neuroimaging@python.org" }] @@ -53,7 +54,6 @@ test = [ "fileformats-extras", "fileformats-datascience-extras", "fileformats-medimage-extras", - "fileformats-medimage-freesurfer-extras", ] @@ -120,3 +120,6 @@ ignore = ["FBT001", "FA"] [tool.ruff.lint.extend-per-file-ignores] "docs/conf.py" = ["INP001", "A001"] + +[tool.pyright] +reportAssignmentType = false diff --git a/tox.ini b/tox.ini index 7aee54e7..cdde5e68 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,9 @@ setenv = pre: UV_INDEX_STRATEGY=unsafe-best-match uv_resolution = min: lowest-direct +deps = + -e ./related-packages/fileformats + -e ./related-packages/fileformats-extras commands = pytest pydra/tasks/freesurfer --cov=pydra.tasks.freesurfer --cov-report term-missing --durations=20 --durations-min=1.0 {posargs:-n auto}