Skip to content
Snippets Groups Projects
Commit e03da764 authored by Fidel Alfaro Almagro's avatar Fidel Alfaro Almagro :speech_balloon:
Browse files

Merge branch 'mnt/project-mgmt' into 'master'

Migrate to `pyproject.toml`, add `Dockerfile` to generate runtime image

See merge request !6
parents 6d81664a edbe081b
No related branches found
No related tags found
1 merge request!6Migrate to `pyproject.toml`, add `Dockerfile` to generate runtime image
Pipeline #23696 passed
File moved
This docker image is used for running unit tests on the BIP code base. It can
be built via Gitlab CI / CD by running the `build-dev-docker-image` job.
At the moment the image is published to
https://hub.docker.com/u/pauldmccarthy/bip-dev/.
\ No newline at end of file
......@@ -9,30 +9,27 @@ channels=(-c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/development/
conda create -y ${channels[@]} \
-p ./${envdir} \
"python=${PYTHON_VERSION}" \
c-compiler \
cxx-compiler \
pytest \
coverage \
pytest-cov \
dmri-amico \
file-tree \
file-tree-fsl \
fsl-gradunwarp \
fsl-avwutils \
fsl-cluster \
fsl-pyfix \
file-tree file-tree-fsl \
fsl-pipe \
fsl_sub \
fsl_sub_plugin_slurm \
fsl_sub_plugin_sge \
jinja2
jinja2 \
pytest \
pytest-cov
echo "channels:" > ${envdir}/.condarc
echo " https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/development/" >> ${envdir}/.condarc
echo " https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/" >> ${envdir}/.condarc
echo " conda-forge" >> ${envdir}/.condarc
source activate ${envdir}
pip install dmri-amico
pip install git+https://git.fmrib.ox.ac.uk/ndcn0236/pipe-tree.git
conda remove -p ${envdir} c-compiler cxx-compiler
conda clean -y -all
pip cache purge
FROM nvidia/cuda:11.0.3-base-centos7 as base
ENV NVARCH x86_64
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA cuda>=11.0 brand=tesla,driver>=418,driver<419
ENV NVIDIA_VISIBLE_DEVICES all
ENV NV_CUDA_CUDART_VERSION 11.0.221-1
COPY /build_image.sh /build_image.sh
RUN /bin/bash /build_image.sh && rm /build_image.sh
BIP Docker image
----------------
The `Dockerfile` can be used to create a Docker image which contains BIP and
all of its dependencies. The image contains a full BIP runtime environment,
including FSL, FreeSurfer and Connectome Workbench. Be warned that the image
is quite large, on the order of 15GB.
1. Clone the BIP repository and change into the image directory:
```
git clone https://git.fmrib.ox.ac.uk/fsl/bip.git
cd bip/.docker/bip-image
```
2. Build the image:
```
docker build . -t bip &> build_log.txt
```
3. If the image was built on a different machine than the one it is to be run
on, save it to a `.tar.gz` archive:
```
docker save bip | gzip -c > bip.tar.gz
```
Then download the archive to the target machine, and load it:
```
docker load < bip.tar.gz
```
4. Start a container from the image. Replace `<freesurfer-license>` with the
full path to your FreeSurfer license file.
```
docker run -it \
-v <freesurfer-license>:/usr/local/freesurfer/license.txt \
bip /bin/bash
```
#!/usr/bin/env bash
set -e
SHELL_PROFILE=/root/.bashrc
export TAR_OPTIONS="--no-same-owner"
export WGET_OPTIONS="--no-check-certificate -q"
# OS / build dependencies
yum install -y epel-release
yum install -y \
curl \
freetype \
git \
mesa-libGL \
nano \
openssh-clients \
parallel \
python3 \
tcsh \
unzip \
wget
# FSL
FSL_URL=https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py
wget ${WGET_OPTIONS} ${FSL_URL} -O fslinstaller.py
python fslinstaller.py -V 6.0.7.6 -d /usr/local/fsl
echo -e '\nexport FSLDIR=/usr/local/fsl/\n' >> ${SHELL_PROFILE}
echo -e '\nsource ${FSLDIR}/etc/fslconf/fsl.sh\n' >> ${SHELL_PROFILE}
rm fslinstaller.py
# BIP
/usr/local/fsl/bin/mamba install -y -n base --override-channels \
-c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/development/ \
-c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ \
-c conda-forge \
fsl-bip
# ROBEX
ROBEX_URL=https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//\?i_agree\=1\&download_now\=1
pushd /usr/local/
wget ${WGET_OPTIONS} ${ROBEX_URL} -O ROBEX.tar.gz
tar xf ROBEX.tar.gz && rm ROBEX.tar.gz
echo -e '\nexport PATH=/usr/local/ROBEX:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Brainsuite
BRAINSUITE_URL=http://brainsuite.org/data/BIDS/bse15c.biobank.tgz
pushd /usr/local/
wget ${WGET_OPTIONS} ${BRAINSUITE_URL} -O brainsuite.tgz
tar -xf brainsuite.tgz && rm brainsuite.tgz
chmod -R ugo+rx BrainSuite15c
echo -e '\nexport PATH=/usr/local/BrainSuite15c/bin:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Workbench
WORKBENCH_URL=https://humanconnectome.org/storage/app/media/workbench/workbench-rh_linux64-v1.5.0.zip
pushd /usr/local/
wget ${WGET_OPTIONS} ${WORKBENCH_URL} -O workbench.zip
unzip workbench.zip && rm workbench.zip
echo -e '\nexport PATH=/usr/local/workbench/bin_rh_linux64:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Freesurfer
FREESURFER_URL=https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-centos7_x86_64-7.4.1.tar.gz
pushd /usr/local/
wget ${WGET_OPTIONS} ${FREESURFER_URL} -O freesurfer.tgz
tar xf freesurfer.tgz && rm freesurfer.tgz
echo -e '\nexport FREESURFER_HOME=/usr/local/freesurfer\n' >> ${SHELL_PROFILE}
echo -e '\nsource ${FREESURFER_HOME}/SetUpFreeSurfer.sh\n' >> ${SHELL_PROFILE}
popd
# Clean up
/usr/local/fsl/bin/mamba clean --all --yes --force-pkgs-dirs
rm -rf /tmp/*
rm -rf ${HOME}/.cache/
yum clean all
rm -rf /var/cache/yum/*
include:
- project: fsl/conda/fsl-ci-rules
file: .gitlab-ci.yml
stages:
- docker
- test
- fsl-ci-pre
- fsl-ci-build
- fsl-ci-test
- fsl-ci-deploy
# Build docker image used for unit tests
build-dev-docker-image:
......@@ -19,8 +26,8 @@ build-dev-docker-image:
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
- TAG="$(date +%Y%m%d).${CI_COMMIT_SHORT_SHA}"
- IMAGE="pauldmccarthy/bip-dev"
- DOCKERFILE=.docker/Dockerfile
- docker build -t "${IMAGE}:${TAG}" -t "${IMAGE}:latest" -f ${DOCKERFILE} ./.docker
- DOCKERFILE=.docker/bip-dev/Dockerfile
- docker build -t "${IMAGE}:${TAG}" -t "${IMAGE}:latest" -f ${DOCKERFILE} ./.docker/bip-dev
- docker push "${IMAGE}:${TAG}"
- docker push "${IMAGE}:latest"
......
......@@ -3,10 +3,24 @@ BRAIN IMAGING PIPELINE
Fidel Alfaro Almagro, WIN-FMRIB
June, 2022
-------------------------------------------
Automated tool
Installation
------------
BIP is published as a conda package, and can be installed with a command such as:
```
mamba install \
-c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ \
-c conda-forge \
fsl-bip
```
If you want to install everythong that is needed from scratch, run:
```cd /path-to-lib/install_dir/
python setup.py install```
```
cd /path-to-lib/install_dir/
pip install -e .
```
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "bip"
dynamic = ["version"]
description = "Brain Imaging Pipeline"
readme = {file = "README.md", content-type="text/markdown"}
license = {text = "Apache License Version 2.0"}
requires-python = ">=3.8"
authors = [{name = "Fidel Alfaro Almagro", email = "fidel.alfaroalmagro@ndcn.ox.ac.uk"}]
[project.scripts]
bip = "bip.main:main"
[tool.setuptools.dynamic]
version = {file = "bip/VERSION"}
[tool.pytest.ini_options]
testpaths = ["bip/tests"]
addopts = "-v --cov=bip"
[tool.coverage.run]
source = ["bip"]
omit = ["bip/tests/*"]
[tool:pytest]
testpaths = bip/tests
addopts = -v --cov=bip
[coverage:run]
source = bip
omit = bip/tests/*
\ No newline at end of file
import os.path as op
from setuptools import setup,find_packages
with open('requirements.txt', 'rt') as f:
install_requires = [l.strip() for l in f.readlines()]
basedir = op.dirname(__file__)
version = open(op.join(basedir, 'bip', 'VERSION')).read().strip()
setup(name='bip',
version=version,
description='Brain Imaging Pipeline',
author='Fidel Alfaro Almagro',
install_requires=install_requires,
packages=find_packages(),
include_package_data=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment