Skip to content

Commit

Permalink
Merge branch 'add/symlink-install' into add/symlink-install-cli-arg
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoch committed Mar 9, 2022
2 parents 372f3e0 + 10cf953 commit 8771e11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ __pycache__
*.img
.eggs
modules
symlinks
9 changes: 5 additions & 4 deletions docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ variable replacement. A summary table of variables is included below, and then f
- singularity
* - symlink_base
- If set, where you want to install a simplified module tree to using ``--symlink-tree``
- unset
- $root_dir/symlinks
* - symlink_tree
- If set to true, ALWAYS generate a symlink tree given that a symlink base is defined regardless of ``--symlink-tree`` flag
- false
Expand Down Expand Up @@ -385,8 +385,9 @@ By default, your modules are installed to your ``module_base`` described above w
namespace, meaning the container registry from where they arise. We do this so that the namespace
is consistent and there are no conflicts. However, if you want a simplified tree to install from,
meaning the module full names are _just_ the final container name, you can set the ``symlink_base``
in your settings to a different root. For example, let's say we want to install a set of modules,
after seting our symlink base to ``tmp-modules``. We could do:
in your settings to a different root. For example, let's say we want to install a set of modules.
We can use the default ``symlink_base`` of ``$root_dir/symlinks`` or set our own ``symlink_base``
in the settings.yaml. We could do:

.. code-block:: console
Expand All @@ -398,7 +399,7 @@ available!

.. code-block:: console
$ module use ./tmp-modules
$ module use ./symlinks
$ module load clingo/5.5.1/module
This is much more efficient compared to the install that uses the full paths:
Expand Down
11 changes: 5 additions & 6 deletions shpc/main/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,12 @@ def check_symlink(self, module_dir, symlink=False):
Given an install command, if --symblink is provided make sure we have
a symlink_base defined in settings and the directory exists.
"""

if not symlink:
return
if symlink and not self.settings.symlink_base:
logger.exit('To request symlink you must set symlink_base in settings.yml: shpc config set symlink_base:/path/desired')

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

# Get the symlink path - does it exist?
symlink_path = self.get_symlink_path(module_dir)
Expand Down Expand Up @@ -381,7 +379,8 @@ def install(self, name, tag=None, symlink=False, **kwargs):

# Global override to arg
symlink = self.settings.symlink_tree is True or symlink
# Cut out early if symlink desired but no home

# Cut out early if symlink desired or already exists
self.check_symlink(module_dir, symlink)
shpc.utils.mkdirp([module_dir, container_dir])

Expand Down
4 changes: 2 additions & 2 deletions shpc/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ container_base: $root_dir/containers

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

# Always generate a symlink, even without the command line argument
symlink_tree: false
Expand Down Expand Up @@ -76,7 +76,7 @@ wrapper_scripts:
podman: docker.sh

# use for singularity aliases (set to null to disable)
singularity: singularity.sh
singularity: singularity.sh

# Add an extra custom template directory (searched first)
templates: null
Expand Down

0 comments on commit 8771e11

Please sign in to comment.