Skip to content
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

Gentoo based Dockerfile (presumably reproducible) to provide bids-app #41

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

yarikoptic
Copy link

@yarikoptic yarikoptic commented Mar 27, 2024

TODOs

  • ensure AFNI and FSL installed
  • convert to not demand external gentoo/ files
  • well -- afni still needs MNI152_2009_template_SSW.nii.gz for defacer which isn't provided by afni package in gentoo
  • possibly add bids-validator installation
  • test on a dataset to ensure that it actually works (keeps bringing up issues)
  • ideally expose a version. ATM --version just causes --help printout. github releases mention 1.0.1 ...

It is not yet finished
- did not even try FSL installation
- AFNI installation relies on incomplete fixes proposed in
  ReproNim/neurodocker#601
- moved away attempt to install bids-validator (would be useful) due
  those failing too ATM
@yarikoptic
Copy link
Author

FWIW there is an effort by @TheChymera to provide gentoo support in neurodocker:

@yarikoptic yarikoptic changed the title Prototype of a neurodocker invocation script to produce a container Gentoo based Dockerfile (presumably reproducible) to provide bids-app May 7, 2024
@yarikoptic yarikoptic marked this pull request as ready for review May 7, 2024 19:17
@ericearl
Copy link
Member

ericearl commented May 7, 2024

@Arshitha or @dmoracze, Yarik said this is ready for review.

@Arshitha
Copy link
Collaborator

Arshitha commented May 9, 2024

@yarikoptic thank you for your contribution! I'll be traveling tomorrow through the weekend but I'll review it as soon as I can. @ericearl thanks for the ping and following up on this!

@yarikoptic
Copy link
Author

might not be good enough yet

yoh@typhon:/mnt/DATA/data/yoh/1076_spacetop$ singularity run -B $PWD:$PWD:ro -B $PWD/derivatives:$PWD/derivatives:rw -B $PWD/scratch:$PWD/scratch:rw --scratch $PWD/scratch --pwd $PWD --net --network none ../dsst-defacing-pipeline/dsst-defacing-pipeline-test.sing -p 0001 -s 01 -- . derivatives/dss-defacing-1 

lead to a quick generation of bunch of

yoh@typhon:/mnt/DATA/data/yoh/1076_spacetop$ less /mnt/DATA/data/yoh/1076_spacetop/derivatives/dss-defacing-1/bids_defaced/sub-0133/ses-01/anat/defacing_pipeline.log
================================ afni_refacer_run command ================================
module load afni ; export OMP_NUM_THREADS=1 ; @afni_refacer_run -input /mnt/DATA/data/yoh/1076_spacetop/sub-0133/ses-01/anat/sub-0133_ses-01_acq-MPRAGEXp3X08mm_T1w.nii.gz -mode_deface -no_clean -prefix /mnt/DATA/data/yoh/1076_spacetop/derivatives/dss-defacing-1/bids_defaced/sub-0133/ses-01/anat/sub-0133_ses-01_acq-MPRAGEXp3X08mm_T1w
==========================================================================================
/bin/sh: line 1: module: command not found
/bin/sh: line 1: @afni_refacer_run: command not found
@afni_refacer_run work directory not found. Most probably because the refacer command failed.

filed a dedicated

I might add patching directly to this PR... we will see...

@TheChymera
Copy link

8b72b07 seems like a good idea, tested it and it appears to also be faster:

[deco]/tmp/test_gentoo_old ❱ time bash script.sh
mkdir: cannot create directory ‘repo’: File exists
/tmp/test_gentoo_old/repo /tmp/test_gentoo_old
Initialized empty Git repository in /tmp/test_gentoo_old/repo/.git/
warning: filtering not recognized by server, ignoring
remote: Enumerating objects: 4926206, done.
remote: Counting objects: 100% (53175/53175), done.
remote: Compressing objects: 100% (4372/4372), done.
remote: Total 4926206 (delta 49271), reused 48803 (delta 48803), pack-reused 4873031 (from 1)
Receiving objects: 100% (4926206/4926206), 1.18 GiB | 14.22 MiB/s, done.
Resolving deltas: 100% (3568243/3568243), done.
From https://anongit.gentoo.org/git/repo/gentoo
 * branch                      2d25617a1d085316761b06c17a93ec972f172fc6 -> FETCH_HEAD
Updating files: 100% (88342/88342), done.
HEAD is now at 2d25617a1d08 sys-kernel/gentoo-sources: drop 6.7.8
/tmp/test_gentoo_old

real	2m5.778s
user	2m14.753s
sys	0m16.466s
[deco]/tmp/test_gentoo_old ❱ cat script.sh
mkdir repo
pushd repo
git init .
git remote add origin https://anongit.gentoo.org/git/repo/gentoo.git
git fetch --filter="blob:none" origin 2d25617a1d085316761b06c17a93ec972f172fc6
git reset --hard 2d25617a1d085316761b06c17a93ec972f172fc6
rm -rf .git
popd

vs

[deco]/tmp/test_gentoo_new ❱ time bash script.sh
Cloning into 'repo'...
remote: Enumerating objects: 106861, done.
remote: Counting objects: 100% (106861/106861), done.
remote: Compressing objects: 100% (92429/92429), done.
remote: Total 106861 (delta 21371), reused 66212 (delta 13400), pack-reused 0 (from 0)
Receiving objects: 100% (106861/106861), 52.58 MiB | 12.38 MiB/s, done.
Resolving deltas: 100% (21371/21371), done.
Updating files: 100% (88772/88772), done.
/tmp/test_gentoo_new/repo /tmp/test_gentoo_new
remote: Enumerating objects: 27260, done.
remote: Counting objects: 100% (27249/27249), done.
remote: Compressing objects: 100% (15637/15637), done.
remote: Total 17400 (delta 7719), reused 6267 (delta 1743), pack-reused 0 (from 0)
Receiving objects: 100% (17400/17400), 8.97 MiB | 7.35 MiB/s, done.
Resolving deltas: 100% (7719/7719), completed with 6078 local objects.
From https://anongit.gentoo.org/git/repo/gentoo
 * branch                2d25617a1d085316761b06c17a93ec972f172fc6 -> FETCH_HEAD
HEAD is now at 2d25617a1 sys-kernel/gentoo-sources: drop 6.7.8
/tmp/test_gentoo_new

real	0m26.527s
user	0m5.100s
sys	0m2.680s
[deco]/tmp/test_gentoo_new ❱ cat script.sh
git clone --depth 1 https://anongit.gentoo.org/git/repo/gentoo.git repo
pushd repo
git fetch --depth 1 origin 2d25617a1d085316761b06c17a93ec972f172fc6
git reset --hard 2d25617a1d085316761b06c17a93ec972f172fc6
rm .git -rf
popd

I'll upstream this to my Containerfile template as well.

…v python3

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "sed -i -e 's,/usr/local/bin/python3,/usr/bin/env python3,g' src/deface.py src/generate_mappings.py src/prepare_shareable.py src/prepare_to_share.py src/register.py src/run.py",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
It is a hardcoded assumption on a configuration of the environment,
should not be there!
@yarikoptic yarikoptic marked this pull request as draft May 23, 2024 14:00
Someone could add a CLI option like

--on-error=error,continue,ignore   so that if continue
it would continue but error at the end with some summary etc,
and ignore just exit normally
Although does not matter much for this particular case, aiming for
NeuroDocker - we do need to have produced Dockerfile self contained.
Hence here we are practicing on how to make it happen
Dockerfile Outdated
COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo

ARG gentoo_hash=2d25617a1d085316761b06c17a93ec972f172fc6
ARG science_hash=73916dd3680ffd92e5bd3d32b262e5d78c86a448
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheChymera could you please provide new hashes needed here for the new/fixed up build and also add a patch for AFNI to reflect change like https://github.com/afni/afni/pull/650/files ? or could you just incorporate it to AFNI package so we could build/test?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to, but after testing the fix doesn't seem to work. collecting more logs so I can report in the upstream issue exactly what's going on how it was built etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report here → afni/afni#639 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR here (tested with this repo, for some reason the image takes a long time to build compared to the neurodocker test) → yarikoptic#1
Commot on the gentoo+neurodocker PR: ReproNim/neurodocker@758951b

@yarikoptic
Copy link
Author

With @TheChymera tune ups to AFNI packages we finally have something which works!

(dev3) yoh@typhon:/mnt/DATA/data/yoh/1076_spacetop$ datalad run -m "Doing trial run with bleeding edge 0.0.5" duct singularity run -B $PWD:$PWD:ro -B $PWD/derivatives:$PWD/derivatives:rw -B $PWD/scratch:$PWD/scratch:rw -B $PWD/../dsst-defacing-pipeline/src:/opt/dsst-defacing-pipeline:ro  --scratch $PWD/scratch --pwd $PWD --net --network none ../dsst-defacing-pipeline/dsst-defacing-pipeline-0.0.5.sif  -p 0001 -s 01 -- . derivatives/dss-defacing-0.0.5-1
[INFO   ] == Command start (output follows) =====
duct is executing singularity run -B /mnt/DATA/data/yoh/1076_spacetop:/mnt/DATA/data/yoh/1076_spacetop:ro -B /mnt/DATA/data/yoh/1076_spacetop/derivatives:/mnt/DATA/data/yoh/1076_spacetop/derivatives:rw -B /mnt/DATA/data/yoh/1076_spacetop/scratch:/mnt/DATA/data/yoh/1076_spacetop/scratch:rw -B /mnt/DATA/data/yoh/1076_spacetop/../dsst-defacing-pipeline/src:/opt/dsst-defacing-pipeline:ro --scratch /mnt/DATA/data/yoh/1076_spacetop/scratch --pwd /mnt/DATA/data/yoh/1076_spacetop --net --network none ../dsst-defacing-pipeline/dsst-defacing-pipeline-0.0.5.sif -p 0001 -s 01 -- . derivatives/dss-defacing-0.0.5-1...
Log files will be written to .duct/logs/2024.06.09T10.58.56-1623046_

ended with

saving a number of files
 .duct/logs/2024.06.09T10.58.56-1623046_info.json                                                                 |   1 +
 .duct/logs/2024.06.09T10.58.56-1623046_stderr                                                                    |   0
 .duct/logs/2024.06.09T10.58.56-1623046_stdout                                                                    |  95 ++++++++++++
 .duct/logs/2024.06.09T10.58.56-1623046_usage.json                                                                |  50 +++++++
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0001/ses-01/anat/defacing_pipeline.log                         | 165 +++++++++++++++++++++
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0001/ses-01/anat/sub-0001_ses-01_acq-MPRAGEXp3X08mm_T1w.json   | 839 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0001/ses-01/anat/sub-0001_ses-01_acq-MPRAGEXp3X08mm_T1w.nii.gz |   1 +
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0133/ses-01/anat/defacing_pipeline.log                         | 165 +++++++++++++++++++++
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0133/ses-01/anat/sub-0133_ses-01_acq-MPRAGEXp3X08mm_T1w.json   | 839 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 derivatives/dss-defacing-0.0.5-1/bids_defaced/sub-0133/ses-01/anat/sub-0133_ses-01_acq-MPRAGEXp3X08mm_T1w.nii.gz |   1 +
 derivatives/dss-defacing-0.0.5-1/defacing_QC/sub-0001/ses-01/acq-MPRAGEXp3X08mm/T1w/defaced.nii.gz               |   1 +
 derivatives/dss-defacing-0.0.5-1/defacing_QC/sub-0001/ses-01/acq-MPRAGEXp3X08mm/T1w/orig.nii.gz                  |   1 +
 derivatives/dss-defacing-0.0.5-1/defacing_QC/sub-0133/ses-01/acq-MPRAGEXp3X08mm/T1w/defaced.nii.gz               |   1 +
 derivatives/dss-defacing-0.0.5-1/defacing_QC/sub-0133/ses-01/acq-MPRAGEXp3X08mm/T1w/orig.nii.gz                  |   1 +
 derivatives/dss-defacing-0.0.5-1/logs/anat_unavailable.txt                                                       |   3 +
 derivatives/dss-defacing-0.0.5-1/logs/t1_unavailable.txt                                                         |   0
 derivatives/dss-defacing-0.0.5-1/primary_to_others_mapping.json                                                  |  14 ++
 17 files changed, 2177 insertions(+)

which I am yet to digest how to take advantage of (in particular for QC). Meanwhile would file some "operational" issues.

@yarikoptic
Copy link
Author

FWIW, generally the image works, so I am taking out of draft. It doesn't work for my dataset due to various bugs peculiarities of software + dataset.

@yarikoptic yarikoptic marked this pull request as ready for review June 11, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants