Skip to content

Commit e40b6e7

Browse files
authored
Add support for singularity_options and docker_options (#440)
* add support for singularity_options and docker_options * missing code block yaml in developer guide! Signed-off-by: vsoch <[email protected]> Co-authored-by: vsoch <[email protected]>
1 parent 45b8642 commit e40b6e7

File tree

15 files changed

+42
-25
lines changed

15 files changed

+42
-25
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.scom/singularityhub/singularity-hpc/tree/master) (0.0.x)
17+
- Adding singularity and docker specific options (0.0.32)
18+
- Adding more documentation on aliases
19+
- Bugfix to output error message if path does not exist for inspect
1720
- Fixing bug with using variables in recipe options (0.0.31)
1821
- Removing un-used defaults and lmod_base (0.0.30)
1922
- Allow environment variables in settings (0.0.29)

docs/getting_started/developer-guide.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,30 @@ Each recipe has an optional section for defining aliases in the modulefile; ther
169169
aliases:
170170
python: /usr/local/bin/python
171171
172-
A second form is allowed, using dicts, in those cases where the command requires to specify custom options for the container runtime. For instance, suppose the python interpreter above requires an isolated shell environment (``--cleanenv`` in Singularity):
172+
This format is container technology agnostic, because the command (``python``) and executable it targets (``/usr/local/bin/python``) would be consistent between
173+
Podman and Singularity, for example. A second form is allowed, using dicts, in those cases where the command requires to specify custom options for the container runtime. For instance, suppose the python interpreter above requires an isolated shell environment (``--cleanenv`` in Singularity):
173174

174175
.. code-block:: yaml
175176
176177
aliases:
177178
- name: python
178179
command: /usr/local/bin/python
179-
options: --cleanenv
180+
singularity_options: --cleanenv
181+
182+
183+
Or perhaps the container required the docker options ``-it`` because it was an interactive, terminal session:
184+
185+
.. code-block:: yaml
186+
187+
aliases:
188+
- name: python
189+
command: /usr/local/bin/python
190+
docker_options: -it
191+
192+
193+
For each of the above, depending on the prefix of options that you choose, it will write them into the module files for Singularity and Docker, respectively.
194+
This means that if you design a new registry recipe, you should consider how to run it for both kinds of technology. Also note that ``docker_options`` are
195+
those that will also be used for Podman.
180196

181197

182198
Environment Variables

registry/jupyter/datascience-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ tags:
1010
aliases:
1111
- name: run-notebook
1212
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
13-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
14-
-d):/run/user
13+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

registry/jupyter/minimal-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ tags:
1010
aliases:
1111
- name: run-notebook
1212
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
13-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
14-
-d):/run/user
13+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

registry/jupyter/pyspark-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ tags:
1010
aliases:
1111
- name: run-notebook
1212
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
13-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
14-
-d):/run/user
13+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

registry/jupyter/r-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ tags:
1010
aliases:
1111
- name: run-notebook
1212
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
13-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
14-
-d):/run/user
13+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

registry/jupyter/scipy-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ tags:
1010
aliases:
1111
- name: run-notebook
1212
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
13-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
14-
-d):/run/user
13+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

registry/jupyter/tensorflow-notebook/container.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ filter:
1212
aliases:
1313
- name: run-notebook
1414
command: jupyter notebook --no-browser --port=$(shuf -i 2000-65000 -n 1) --ip 0.0.0.0
15-
options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp
16-
-d):/run/user
15+
singularity_options: --home ${HOME} --bind ${HOME}/.local:/home/joyvan/.local --bind $(mktemp -d):/run/user

shpc/main/container/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ def installed_tags(self, module_name):
119119
"""
120120
Get a list of installed tags.
121121
"""
122-
return os.listdir(os.path.join(self.settings.module_base, module_name))
122+
module_dir = os.path.join(self.settings.module_base, module_name)
123+
if not os.path.exists(module_dir):
124+
logger.exit("%s does not exist." % module_dir)
125+
return os.listdir(module_dir)
123126

124127
def get_environment_file(self, module_name):
125128
"""

shpc/main/modules/templates/docker.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Commands include:
2525
{{ command }} inspect <container>
2626
2727
{% if aliases %}{% for alias in aliases %} - {{ alias.name }}:
28-
{{ command }} run -i{% if tty %}t{% endif %} -u `id -u`:`id -g` --rm --entrypoint {{ alias.entrypoint }} {% if envfile %}--env-file {{ module_dir }}/{{ envfile }}{% endif %} {% if bindpaths %}-v {{ bindpaths }} {% endif %}{% if alias.options %}{{ alias.options }} {% endif %} -v ${PWD} -w ${PWD} <container> "{{ alias.args }}"
28+
{{ command }} run -i{% if tty %}t{% endif %} -u `id -u`:`id -g` --rm --entrypoint {{ alias.entrypoint }} {% if envfile %}--env-file {{ module_dir }}/{{ envfile }}{% endif %} {% if bindpaths %}-v {{ bindpaths }} {% endif %}{% if alias.docker_options %}{{ alias.docker_options }} {% endif %} -v ${PWD} -w ${PWD} <container> "{{ alias.args }}"
2929
{% endfor %}{% endif %}
3030
3131
For each of the above, you can export:
@@ -58,7 +58,7 @@ conflict(myModuleName(){% if aliases %}{% for alias in aliases %}{% if alias.nam
5858

5959
-- exec functions to provide "alias" to module commands
6060
{% if aliases %}{% for alias in aliases %}
61-
set_shell_function("{{ alias.name }}", execCmd .. {% if alias.options %} "{{ alias.options }} " .. {% endif %} " --entrypoint {{ alias.entrypoint }} " .. containerPath .. " {{ alias.args }} $@", execCmd .. {% if alias.options %} "{{ alias.options }} " .. {% endif %} " --entrypoint {{ alias.entrypoint }} " .. containerPath .. " {{ alias.args }}")
61+
set_shell_function("{{ alias.name }}", execCmd .. {% if alias.docker_options %} "{{ alias.docker_options }} " .. {% endif %} " --entrypoint {{ alias.entrypoint }} " .. containerPath .. " {{ alias.args }} $@", execCmd .. {% if alias.docker_options %} "{{ alias.docker_options }} " .. {% endif %} " --entrypoint {{ alias.entrypoint }} " .. containerPath .. " {{ alias.args }}")
6262
{% endfor %}{% endif %}
6363

6464
{% if aliases %}

0 commit comments

Comments
 (0)