PennLINC / aslprep

Preprocessing of arterial spin labeling (ASL) data
https://aslprep.readthedocs.io
Other
41 stars 15 forks source link

/home/aslprep/.cache not writable in singularity container #391

Closed stebo85 closed 8 months ago

stebo85 commented 9 months ago

Summary

Since 0.0.6 aslprep expects that /home/aslprep/.cache is writable. But this doesn't work inside a singularity container. Is there any chance to change this to ~/.cache as this would map to a writable home directory inside a singularity container.

Additional details

What were you trying to do?

Run ASLprep in a singularity container converted from the docker container.

What did you expect to happen?

To start ok

What actually happened?

Traceback (most recent call last): File "/usr/local/miniconda/bin/aslprep", line 5, in from aslprep.cli.run import main File "/usr/local/miniconda/lib/python3.10/site-packages/aslprep/cli/run.py", line 25, in from aslprep import config File "/usr/local/miniconda/lib/python3.10/site-packages/aslprep/config.py", line 114, in from templateflow import version as _tf_ver File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/init.py", line 18, in from . import api File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/api.py", line 8, in from .conf import TF_LAYOUT, TF_S3_ROOT, TF_USE_DATALAD, requires_layout File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/conf/init.py", line 53, in _init_cache() File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/conf/init.py", line 50, in _init_cache _update_s3(TF_HOME, local=True, overwrite=True) File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/conf/_s3.py", line 19, in update retval = _update_skeleton(skel_file, dest, overwrite=overwrite, silent=silent) File "/usr/local/miniconda/lib/python3.10/site-packages/templateflow/conf/_s3.py", line 51, in _update_skeleton dest.mkdir(exist_ok=True, parents=True) File "/usr/local/miniconda/lib/python3.10/pathlib.py", line 1179, in mkdir self.parent.mkdir(parents=True, exist_ok=True) File "/usr/local/miniconda/lib/python3.10/pathlib.py", line 1175, in mkdir self._accessor.mkdir(self, mode) OSError: [Errno 30] Read-only file system: '/home/aslprep/.cache'

Reproducing the bug

Build a singularity container from the 0.0.6 docker container and start aslprep

tsalo commented 9 months ago

@stebo85 could you please post the command you used to run ASLPrep?

stebo85 commented 9 months ago

Just running ‘aslprep’ in the singularity container will trigger the error above, so it doesn’t even print the help.

tsalo commented 9 months ago

In that case can you try out the solutions for using TemplateFlow with Singularity in the NiPreps documentation here?

stebo85 commented 8 months ago

We found the problem and a solution to this:

The problem is that the aslprep container sets the HOME variable incorrectly to /home/aslprep - but for a singularity container, this needs to be dynamically set to the home directory of the user running the container. In Neurodesk we now overwrite this variable and the singularity container now runs as expected: https://github.com/NeuroDesk/neurocontainers/blob/28be80f50c71612d088fabb3d5eed4dec99017b9/recipes/aslprep/build.sh#L24

stebo85 commented 8 months ago

This seems to be the cause of the problem: https://github.com/PennLINC/aslprep_build/blame/4711628e2eeba1afd1f746a6ac22582c5620875b/Dockerfile#L221

Would it make sense to replace this with a generic home directory like ENV HOME="~/"