Skip to content

Commit 1ed7d5d

Browse files
authored
make default containers directory alongside modules for faster loading (#490)
* make default containers directory alongside modules for faster loading Signed-off-by: vsoch <[email protected]> * tweak release workflow Signed-off-by: vsoch <[email protected]> * Tweak settings container base test Co-authored-by: vsoch <[email protected]>
1 parent f36143e commit 1ed7d5d

File tree

7 files changed

+44
-29
lines changed

7 files changed

+44
-29
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ jobs:
1919
export PATH="/usr/share/miniconda/bin:$PATH"
2020
source activate shpc
2121
pip install -e .
22-
pip install setuptools wheel
22+
pip install setuptools wheel twine
2323
- name: Build and publish
2424
env:
2525
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
2626
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
2727
run: |
28+
export PATH="/usr/share/miniconda/bin:$PATH"
29+
source activate shpc
2830
python setup.py sdist bdist_wheel
2931
twine upload dist/*

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ and **Merged pull requests**. Critical items to know are:
1313

1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

16-
## [0.0.x](https://github.scom/singularityhub/singularity-hpc/tree/master) (0.0.x)
16+
## [0.0.x](https://github.scom/singularityhub/singularity-hpc/tree/main) (0.0.x)
17+
- default containers directory should be separate from modules (0.0.43)
1718
- remove redundancy of manual bindpaths and SINGULARITY_BINDPATH (0.0.42)
1819
- Do not unset container environment vars if they are already set (0.0.41)
1920
- Central config should be read first (and updated with user config) (0.0.4)

docs/getting_started/developer-guide.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ this:
112112
└── container.yaml
113113
114114
115-
And this is what gets installed to the modules folder, where each is kept in
115+
And this is what gets installed to the modules and containers directories, where each is kept in
116116
a separate directory based on version.
117117

118118
.. code-block:: console
@@ -121,10 +121,14 @@ a separate directory based on version.
121121
modules/
122122
└── python
123123
└── 3.9.2
124-
├── module.lua
124+
└── module.lua
125+
126+
$ tree containers/
127+
containers/
128+
└── python
129+
└── 3.9.2
125130
└── python-3.9.2.sif
126131
127-
2 directories, 2 files
128132
129133
So different versions could exist alongside one another.
130134

@@ -468,7 +472,7 @@ or ask for help directly!
468472
469473
Container:
470474
471-
- /home/vanessa/Desktop/Code/singularity-hpc/modules/python/3.9.2-slim/python-3.9.2-slim-sha256:85ed629e6ff79d0bf796339ea188c863048e9aedbf7f946171266671ee5c04ef.sif
475+
- /home/vanessa/Desktop/Code/singularity-hpc/containers/python/3.9.2-slim/python-3.9.2-slim-sha256:85ed629e6ff79d0bf796339ea188c863048e9aedbf7f946171266671ee5c04ef.sif
472476
473477
Commands include:
474478
@@ -500,5 +504,4 @@ commands to shell, run, exec, and inspect. The custom commands (e.g., Python) ar
500504
Make sure to write to files outside of the container so you don't muck with permissions.
501505
Since we are using module use, this means that you can create module files as a user
502506
or an admin - it all comes down to who has permission to write to the modules
503-
folder, and of course use it. Note that I have not tested this on an HPC system
504-
but plan to shortly.
507+
and containers folder, and of course use it.

docs/getting_started/user-guide.rst

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ that you might set, the following variables are available to you:
147147

148148
Additionally, the variables ``module_base``, ``container_base``, and ``registry``
149149
can be set with environment variables that will be expanded at runtime. You cannot
150-
use the protected set of substitution variables (``$install_dir`` and ``$install_root``)
150+
use the protected set of substitution variables (``$install_dir`` and ``$root_dir``)
151151
as environment variables, as they will be subbed in by shpc before environment
152152
variable replacement. A summary table of variables is included below, and then further discussed in detail.
153153

@@ -169,8 +169,8 @@ variable replacement. A summary table of variables is included below, and then f
169169
- The install directory for modules
170170
- $root_dir/modules
171171
* - container_base
172-
- Where to install containers. If not defined, they are installed alongside modules.
173-
- null
172+
- Where to install containers. If not defined, they are installed in "containers" in the install root
173+
- $root_dir/containers
174174
* - container_tech
175175
- The container technology to use (singularity or podman)
176176
- singularity
@@ -287,29 +287,32 @@ your install:
287287
$ shpc config set module_base:\$root_dir/modules
288288
289289
290-
This directory will be the base where lua files are added, and container are stored.
291-
For example, if you were to add a container with unique resource identifier `python/3.8`
292-
you would see:
290+
This directory will be the base where lua files are added, and containers are stored
291+
in a directory alongside it. For example, if you were to add a container with unique
292+
resource identifier `python/3.8` you would see:
293293

294294
.. code-block:: console
295295
296296
$install_dir/modules/
297297
└── python
298298
└── 3.9.2
299-
├── module.lua
299+
└── module.lua
300+
301+
$install_dir/containers/
302+
└── python
303+
└── 3.9.2
300304
└── python-3.9.2.sif
301305
302-
Although your module path might have multiple locations, Singularity Registry HPC
303-
assumes this one location to install container modules to in order to ensure
306+
Singularity Registry HPC uses this simple directory structure to ensure
304307
a unique namespace.
305308

306309

307310
Container Images Folder
308311
-----------------------
309312

310-
If you don't want your container images (sif files) to live alongside your
311-
module files, then you should define the ``container_base`` to be something
312-
non-null (a path that exists). For example:
313+
If you don't want your container images (sif files) to live in the root of shpc
314+
in a directory called "containers," then you should define the ``container_base`` to be something
315+
different. For example:
313316

314317
.. code-block:: console
315318
@@ -318,7 +321,9 @@ non-null (a path that exists). For example:
318321
319322
320323
The same hierarchy will be preserved as to not put all containers in the same
321-
directory.
324+
directory. It's strongly recommended to keep modules separate from containers
325+
for faster loading (applies to container technologies like Singularity that
326+
pull binary files directly).
322327

323328

324329
Registry
@@ -567,10 +572,13 @@ and then a message to indicate that the module was created.
567572
modules/
568573
└── python
569574
└── 3.9.2
570-
├── module.lua
571-
└── python-3.9.2.sif
575+
└── module.lua
572576
573-
2 directories, 2 files
577+
$ tree containers/
578+
containers/
579+
└── python
580+
└── 3.9.2
581+
└── python-3.9.2.sif
574582
575583
576584
You can also install a specific tag (as shown in list).
@@ -1015,10 +1023,10 @@ If you want to quickly get the path to a container binary, you can use get.
10151023
.. code-block:: console
10161024
10171025
$ shpc get vanessa/salad:latest
1018-
/home/vanessa/Desktop/Code/singularity-hpc/modules/vanessa/salad/latest/vanessa-salad-latest-sha256:8794086402ff9ff9f16c6facb93213bf0b01f1e61adf26fa394b78587be5e5a8.sif
1026+
/home/vanessa/Desktop/Code/singularity-hpc/containers/vanessa/salad/latest/vanessa-salad-latest-sha256:8794086402ff9ff9f16c6facb93213bf0b01f1e61adf26fa394b78587be5e5a8.sif
10191027
10201028
$ shpc get tensorflow/tensorflow:2.2.2
1021-
/home/vanessa/Desktop/Code/singularity-hpc/modules/tensorflow/tensorflow/2.2.2/tensorflow-tensorflow-2.2.2-sha256:e2cde2bb70055511521d995cba58a28561089dfc443895fd5c66e65bbf33bfc0.sif
1029+
/home/vanessa/Desktop/Code/singularity-hpc/containers/tensorflow/tensorflow/2.2.2/tensorflow-tensorflow-2.2.2-sha256:e2cde2bb70055511521d995cba58a28561089dfc443895fd5c66e65bbf33bfc0.sif
10221030
10231031
If you select a higher level module directory or there is no sif, you'll see:
10241032

shpc/settings.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module_name: '{{ tool }}'
3030
default_version: true
3131

3232
# store containers separately from module files
33-
container_base:
33+
# It's recommended to do this for faster loading
34+
container_base: $root_dir/containers
3435

3536
# if defined, add to lmod script to load this Singularity module first
3637
singularity_module:

shpc/tests/test_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_set_get(tmp_path):
3232
"""Test variable set/get"""
3333
settings_file = os.path.join(root, "settings.yml")
3434
settings = Settings(settings_file)
35-
assert not settings.container_base
35+
assert settings.container_base.endswith("containers")
3636
settings.set("container_base", "/tmp/containers")
3737
settings.set("container_features", "gpu:amd")
3838
assert settings.container_base == "/tmp/containers"

shpc/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__copyright__ = "Copyright 2021-2022, Vanessa Sochat"
33
__license__ = "MPL 2.0"
44

5-
__version__ = "0.0.42"
5+
__version__ = "0.0.43"
66
AUTHOR = "Vanessa Sochat"
77
NAME = "singularity-hpc"
88
PACKAGE_URL = "https://github.com/singularityhub/singularity-hpc"

0 commit comments

Comments
 (0)