9
9
This module is a singularity container wrapper for {{ name }} v{{ version }}
10
10
{% if description %}{{ description }}{% endif %}
11
11
12
- Container:
12
+ Container (available through variable SINGULARITY_CONTAINER) :
13
13
14
14
- {{ container_sif }}
15
15
@@ -25,6 +25,8 @@ Commands include:
25
25
singularity inspect -r <container>
26
26
- {|module_name|}-inspect-deffile:
27
27
singularity inspect -d <container>
28
+ - {|module_name|}-container:
29
+ echo "$SINGULARITY_CONTAINER"
28
30
29
31
{% if aliases %}{% for alias in aliases %} - {{ alias.name }}:
30
32
singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home }} --home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 }} {% endif %}{% if settings.environment_file %}-B <moduleDir>/{{ settings.environment_file }}:/.singularity.d/env/{{ settings.environment_file }}{% endif %} {% if settings.bindpaths %}-B {{ settings.bindpaths }} {% endif %}{% if alias.singularity_options %}{{ alias.singularity_options }} {% endif %}<container> {{ alias.command }} "$@"
@@ -34,6 +36,7 @@ For each of the above, you can export:
34
36
35
37
- SINGULARITY_OPTS: to define custom options for singularity (e.g., --debug)
36
38
- SINGULARITY_COMMAND_OPTS: to define custom options for the command (e.g., -b)
39
+ - SINGULARITY_CONTAINER: full path to the Singularity Container
37
40
]] )
38
41
39
42
{% include " includes/default_version.lua" % }
@@ -50,8 +53,12 @@ setenv("SINGULARITY_SHELL", "{{ settings.singularity_shell }}")
50
53
if not os.getenv (" SINGULARITY_OPTS" ) then setenv (" SINGULARITY_OPTS" , " " ) end
51
54
if not os.getenv (" SINGULARITY_COMMAND_OPTS" ) then setenv (" SINGULARITY_COMMAND_OPTS" , " " ) end
52
55
53
- -- interactive shell to any container, plus exec for aliases
54
56
local containerPath = ' {{ container_sif }}'
57
+ -- service environment variable to access full SIF image path
58
+ setenv (" SINGULARITY_CONTAINER" , containerPath )
59
+ set_shell_function (" {|module_name|}-container" , " echo " .. containerPath , " echo " .. containerPath )
60
+
61
+ -- interactive shell to any container, plus exec for aliases
55
62
local shellCmd = " singularity ${SINGULARITY_OPTS} shell ${SINGULARITY_COMMAND_OPTS} -s {{ settings.singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home }} --home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 }} {% endif %}{% if settings.environment_file %}-B " .. moduleDir .. " /{{ settings.environment_file }}:/.singularity.d/env/{{ settings.environment_file }}{% endif %} {% if settings.bindpaths %}-B {{ settings.bindpaths }}{% endif %} " .. containerPath
56
63
local execCmd = " singularity ${SINGULARITY_OPTS} exec ${SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home }} --home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 }} {% endif %}{% if settings.environment_file %}-B " .. moduleDir .. " /{{ settings.environment_file }}:/.singularity.d/env/{{ settings.environment_file }}{% endif %} {% if settings.bindpaths %}-B {{ settings.bindpaths }}{% endif %} "
57
64
local runCmd = " singularity ${SINGULARITY_OPTS} run ${SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home }} --home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 }} {% endif %}{% if settings.environment_file %}-B " .. moduleDir .. " /{{ settings.environment_file }}:/.singularity.d/env/{{ settings.environment_file }}{% endif %} {% if settings.bindpaths %}-B {{ settings.bindpaths }}{% endif %} " .. containerPath
0 commit comments