NeuroDesk / transparent-singularity

Deploying a singularity container so that it behaves like one would have installed software natively
https://neurodesk.org
MIT License
4 stars 2 forks source link

Add TMPDIR environment variables to handle non-default temp directories #12

Closed marcelzwiers closed 3 months ago

marcelzwiers commented 4 months ago

See Github issue #11

stebo85 commented 4 months ago

thank you for sending that pull request. I am hoping to be able to test this next week. Did you test your changes on your system and did it work? I think it also needs mount points in addition for this to work?

marcelzwiers commented 4 months ago

Yes, you are right. I copied over what I had on our HPC, but indeed for us the non-default tmpdir is automatically mounted on all apptainers. So perhaps it is better to script this and check if any of the TMPDIR variables (as used in this PR) are non-empty and then bindmount them as /tmp?

marcelzwiers commented 4 months ago

So something like:

CUSTOMTMPDIR="/tmp"
for CUSTOMDIR in $TMP $TMPDIR $TEMP $TEMPDIR; do
   CUSTOMTMPDIR=$CUSTOMDIR
done

apptainer run --cleanenv --no-mount tmp --bind ${CUSTOMTMPDIR}:/tmp etc
stebo85 commented 3 months ago

cool! Does this work on your system now? Then I test on the HPCs I have access to and we can make it available for all

marcelzwiers commented 3 months ago

If I manually edit our singularity run-scripts likewise then it works for us :-)

stebo85 commented 3 months ago

thank you for confirming :)

marcelzwiers commented 3 months ago

I didn't look into setting this bind option centrally, perhaps that is also possible as an alternative

marcelzwiers commented 3 months ago

https://apptainer.org/docs/user/main/bind_paths_and_mounts.html#system-defined-bind-paths https://apptainer.org/docs/user/main/cli/apptainer_config_global.html#apptainer-config-global

stebo85 commented 3 months ago

yes, that would also be possible

marcelzwiers commented 3 months ago

Indeed, I now see that there exists a variable for this, i.e. APPTAINER_WORKDIR (see here). But that also does something with the HOME directory?

marcelzwiers commented 3 months ago

I just tested the new run_fetch code and it works nicely :-)