@@ -18,19 +18,19 @@ proc ModulesHelp { } {
18
18
puts stderr " Commands include:"
19
19
puts stderr " "
20
20
puts stderr " - {|module_name|}-run:"
21
- puts stderr " singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
21
+ puts stderr " singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
22
22
puts stderr " - {|module_name|}-shell:"
23
- puts stderr " singularity shell -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
23
+ puts stderr " singularity shell -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
24
24
puts stderr " - {|module_name|}-exec:"
25
- puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container> $*"
25
+ puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container> $*"
26
26
puts stderr " - {|module_name|}-inspect-runscript:"
27
27
puts stderr " singularity inspect -r <container>"
28
28
puts stderr " - {|module_name|}-inspect-deffile:"
29
29
puts stderr " singularity inspect -d <container>"
30
30
puts stderr " "
31
31
{% if aliases %}{% for alias in aliases %} puts stderr " - {{ alias.name }}:"
32
- puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}{% if alias.singularity_options %}{{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %}<container> {{ alias.command | replace(" $" , " \$ " ) }}"
33
- {% endfor %}{% else %} puts stderr " - {|module_name|}: singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %}<container>" {% endif %}
32
+ puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}{% if alias.singularity_options %}{{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %}<container> {{ alias.command | replace(" $" , " \$ " ) }}"
33
+ {% endfor %}{% else %} puts stderr " - {|module_name|}: singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %}<container>" {% endif %}
34
34
puts stderr " "
35
35
puts stderr " For each of the above, you can export:"
36
36
puts stderr " "
@@ -66,19 +66,30 @@ conflict {{ name }}
66
66
setenv SINGULARITY_SHELL {{ singularity_shell }}
67
67
68
68
# interactive shell to any container, plus exec for aliases
69
- set shellCmd " singularity \$ {SINGULARITY_OPTS} shell \$ {SINGULARITY_COMMAND_OPTS} -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
70
- set execCmd " singularity \$ {SINGULARITY_OPTS} exec \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} "
71
- set runCmd " singularity \$ {SINGULARITY_OPTS} run \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
69
+ set shellCmd " singularity \$ {SINGULARITY_OPTS} shell \$ {SINGULARITY_COMMAND_OPTS} -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
70
+ set execCmd " singularity \$ {SINGULARITY_OPTS} exec \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} "
71
+ set runCmd " singularity \$ {SINGULARITY_OPTS} run \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
72
72
set inspectCmd " singularity \$ {SINGULARITY_OPTS} inspect \$ {SINGULARITY_COMMAND_OPTS} "
73
73
74
74
# set_shell_function takes bashStr and cshStr
75
75
set -alias {|module_name|}-shell " ${shellCmd} "
76
76
77
-
78
77
# exec functions to provide "alias" to module commands
79
- {% if aliases %}{% for alias in aliases %}
80
- set -alias {{ alias.name }} " ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}"
81
- {% endfor %}{% endif %}
78
+ {% if aliases %}
79
+ if { [ module-info shell bash ] } {
80
+ if { [ module-info mode load ] } {
81
+ {% for alias in aliases %} puts stdout " function {{ alias.name }}() { ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}; }; export -f {{ alias.name }};"
82
+ {% endfor %}
83
+ }
84
+ if { [ module-info mode remove ] } {
85
+ {% for alias in aliases %} puts stdout " unset -f {{ alias.name }};"
86
+ {% endfor %}
87
+ }
88
+ } else {
89
+ {% for alias in aliases %} set-alias {{ alias.name }} " ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}"
90
+ {% endfor %}
91
+ }
92
+ {% endif %}
82
93
83
94
# A customizable exec function
84
95
set -alias {|module_name|}-exec " ${execCmd} ${containerPath} "
0 commit comments