Skip to content

Commit 199864c

Browse files
committed
Add container message to trackusage
1 parent df40db3 commit 199864c

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,38 @@ RUN mkdir -p /opt/miniconda3; \
1919
. /root/.bashrc; \
2020
\
2121
# Create a conda env and install FSL tools needed for (me)deface and slicereport. NB: Keep the version the same as the Docker base image
22-
conda create -n fsl python=3.10; \
22+
conda create -n fsl python=3.12; \
2323
conda install -n fsl -c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ -c conda-forge fsl-libvis fsl-avwutils fsl-flirt; \
2424
\
25-
# Pack the fsl environment into fsl.tar.gz and unpack it in /opt/fsl \
25+
# Pack the fsl environment into fsl.tar.gz and unpack it in /opt/fsl
2626
conda install -c conda-forge conda-pack; \
2727
conda pack -n fsl; \
2828
mkdir /opt/fsl && tar -xzf fsl.tar.gz -C /opt/fsl; \
29-
/opt/fsl/bin/conda-unpack
29+
/opt/fsl/bin/conda-unpack; \
30+
\
31+
# Clone bidscoin
32+
git clone https://github.com/Donders-Institute/bidscoin.git /opt/bidscoin; \
33+
cd /opt/bidscoin; \
34+
rm -rf docs tests .git
3035

3136

3237
FROM python:3.12-slim
3338

3439
# Install the dcm2niix build. NB: Obsolete with the new `pip install bidscoin[dcm2niix2bids]` extras option
3540
COPY --from=builder /usr/local/bin/dcm2niix /usr/local/bin/dcm2niix
3641
COPY --from=builder /opt/fsl /opt/fsl
42+
# Only needed for pip install from GitHub
43+
# COPY --from=builder /opt/bidscoin /opt/bidscoin
3744

45+
# Set environment variables
3846
ENV FSLDIR=/opt/fsl FSLOUTPUTTYPE=NIFTI_GZ \
3947
PATH=$PATH:/opt/fsl/bin \
40-
PIP_NO_CACHE_DIR=off
48+
PIP_NO_CACHE_DIR=off \
49+
CONTAINER=Docker
4150

4251
# First install pyqt as Debian package to solve dependencies issues occurring when installed with pip
4352
# Then install the latest stable BIDScoin release (add build-essential for newer python:3-slim base images (pip needs gcc and wayland support is not yet provided for))
4453
RUN apt update && apt -y --no-install-recommends install pigz curl python3-pyqt6 build-essential libgl1 libxcb-cursor0 dbus qt6-wayland && apt clean; \
4554
pip install bidscoin[spec2nii2bids,deface]
55+
# pip install bidscoin[spec2nii2bids,deface]==VERSION
56+
# pip install /opt/bidscoin[spec2nii2bids,deface] # = GitHub. NB: Also uncomment in xfiles from builder: `/opt/bidscoin /opt/bidscoin`

apptainer.def

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Stage: builder
2424
. /root/.bashrc
2525

2626
# Create a conda env and install FSL tools needed for (me)deface and slicereport. NB: Keep the version the same as the Docker base image
27-
conda create -n fsl python=3.10
27+
conda create -n fsl python=3.12
2828
conda install -n fsl -c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ -c conda-forge fsl-libvis fsl-avwutils fsl-flirt
2929

3030
# Pack the fsl environment into fsl.tar.gz and unpack it in /opt/fsl
@@ -63,14 +63,15 @@ Stage: final
6363
3) The current image does not include the Freesurfer/synthstrip software (needed for `skullstrip`)
6464

6565
%files from builder
66-
# /opt/bidscoin /opt/bidscoin # Only needed for pip install from github
6766
/usr/local/bin/dcm2niix /usr/local/bin/dcm2niix
6867
/opt/fsl /opt/fsl
68+
# /opt/bidscoin /opt/bidscoin # Only needed for pip install from GitHub
6969

7070
%environment
7171
export FSLDIR=/opt/fsl FSLOUTPUTTYPE=NIFTI_GZ
7272
export PATH=$PATH:/opt/fsl/bin
7373
export PIP_NO_CACHE_DIR=off
74+
export CONTAINER=Apptainer
7475

7576
%post
7677
# Install curl (sometimes needed by dcm2niix) and pigz (to speed up dcm2niix)
@@ -81,9 +82,9 @@ Stage: final
8182
apt -y --no-install-recommends install python3-pyqt6 build-essential libgl1 libxcb-cursor0 dbus qt6-wayland && apt clean # Add build-essential for newer python:3-slim base images (pip needs gcc and wayland support is not yet provided for)
8283

8384
# Install BIDScoin
84-
# pip install /opt/bidscoin[spec2nii2bids,deface] # Also uncomment in xfiles from builder: `/opt/bidscoin /opt/bidscoin`
85-
# pip install bidscoin[spec2nii2bids,deface]==VERSION
8685
pip install bidscoin[spec2nii2bids,deface]
86+
# pip install bidscoin[spec2nii2bids,deface]==VERSION
87+
# pip install /opt/bidscoin[spec2nii2bids,deface] # = GitHub. NB: Also uncomment in xfiles from builder: `/opt/bidscoin /opt/bidscoin`
8788

8889
# Uncomment the line below if you get errors like: ImportError: libQt5Core.so.5: cannot open shared object file: No such file or directory
8990
# strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

bidscoin/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ def trackusage(event: str, message='', dryrun: bool=False) -> dict:
192192
'hostid': hashlib.md5(platform.node().encode('utf8')).hexdigest()}
193193
if message:
194194
data['message'] = str(message)
195+
if container := os.getenv('CONTAINER'):
196+
data['container'] = container
195197

196198
# Return if the user disallows tracking, if it is a dry-, pytest-, or a DRMAA-run, or if this is not a stable (#.#.#) version
197199
if not (os.getenv('BIDSCOIN_TRACKUSAGE') or config['bidscoin'].get('trackusage','yes')).upper() in ('1', 'TRUE', 'Y', 'YES') or dryrun \

0 commit comments

Comments
 (0)