Skip to content

Commit 10cf953

Browse files
committed
do not require symlink_base to be defined
we can have a default of $root_dir/symlinks instead Signed-off-by: vsoch <[email protected]>
1 parent 60e5867 commit 10cf953

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ __pycache__
1717
*.img
1818
.eggs
1919
modules
20+
symlinks

docs/getting_started/user-guide.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ variable replacement. A summary table of variables is included below, and then f
181181
- singularity
182182
* - symlink_base
183183
- If set, where you want to install a simplified module tree to using ``--symlink-tree``
184-
- unset
184+
- $root_dir/symlinks
185185
* - symlink_tree
186186
- If set to true, ALWAYS generate a symlink tree given that a symlink base is defined regardless of ``--symlink-tree`` flag
187187
- false
@@ -385,8 +385,9 @@ By default, your modules are installed to your ``module_base`` described above w
385385
namespace, meaning the container registry from where they arise. We do this so that the namespace
386386
is consistent and there are no conflicts. However, if you want a simplified tree to install from,
387387
meaning the module full names are _just_ the final container name, you can set the ``symlink_base``
388-
in your settings to a different root. For example, let's say we want to install a set of modules,
389-
after seting our symlink base to ``tmp-modules``. We could do:
388+
in your settings to a different root. For example, let's say we want to install a set of modules.
389+
We can use the default ``symlink_base`` of ``$root_dir/symlinks`` or set our own ``symlink_base``
390+
in the settings.yaml. We could do:
390391

391392
.. code-block:: console
392393
@@ -398,7 +399,7 @@ available!
398399

399400
.. code-block:: console
400401
401-
$ module use ./tmp-modules
402+
$ module use ./symlinks
402403
$ module load clingo/5.5.1/module
403404
404405
This is much more efficient compared to the install that uses the full paths:

shpc/main/modules/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,12 @@ def check_symlink(self, module_dir, symlink=False):
214214
"""
215215
# Global override to arg
216216
symlink = self.settings.symlink_tree is True or symlink
217-
218217
if not symlink:
219218
return
220-
if symlink and not self.settings.symlink_base:
221-
logger.exit('To request symlink you must set symlink_base in settings.yml: shpc config set symlink_base:/path/desired')
222219

223-
elif symlink and not os.path.exists(self.settings.symlink_base):
224-
logger.exit('%s does not exist, create before trying to use it!' % self.settings.symlink_base)
220+
# Create the symlink base for the user if it does not exist
221+
if symlink and not os.path.exists(self.settings.symlink_base):
222+
utils.mkdirp([self.settings.symlink_base])
225223

226224
# Get the symlink path - does it exist?
227225
symlink_path = self.get_symlink_path(module_dir)
@@ -381,7 +379,7 @@ def install(self, name, tag=None, symlink=False, **kwargs):
381379
subfolder = os.path.join(uri, tag.name)
382380
container_dir = self.container.container_dir(subfolder)
383381

384-
# Cut out early if symlink desired but no home
382+
# Cut out early if symlink desired or already exists
385383
self.check_symlink(module_dir, symlink)
386384
shpc.utils.mkdirp([module_dir, container_dir])
387385

shpc/settings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ container_base: $root_dir/containers
3636

3737
# If defined, create a simplified "symlink install" that shortens module names
3838
# to be just the container, e.g., ghcr.io/autamus/samtools -> module load samtools
39-
symlink_base: null
39+
symlink_base: $root_dir/symlinks
4040

4141
# Always generate a symlink, even without the command line argument
4242
symlink_tree: false
@@ -76,7 +76,7 @@ wrapper_scripts:
7676
podman: docker.sh
7777

7878
# use for singularity aliases (set to null to disable)
79-
singularity: singularity.sh
79+
singularity: singularity.sh
8080

8181
# Add an extra custom template directory (searched first)
8282
templates: null

0 commit comments

Comments
 (0)