From 8e8c617181edfb341ee10809b38ee54c11f362d9 Mon Sep 17 00:00:00 2001 From: vsoch Date: Thu, 4 Nov 2021 17:36:08 -0600 Subject: [PATCH 1/3] .version file should be written at the top level of module folders Signed-off-by: vsoch --- CHANGELOG.md | 1 + docs/getting_started/user-guide.rst | 5 ++++- shpc/main/modules/__init__.py | 7 +++++++ shpc/version.py | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a7a1c6ea..12e5c5b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are: The versions coincide with releases on pip. Only major versions will be released as tags on Github. ## [0.0.x](https://github.scom/singularityhub/singularity-hpc/tree/master) (0.0.x) + - `.version` file should be written in top level of module folders [#450](https://github.com/singularityhub/singularity-hpc/issues/450) (0.0.35) - Tcl modules use shell functions for bash, to export to child shells (0.0.34) - fixed missing singularity -B flag for custom home feature - fixed singularity.tcl to always replace $ with \$ for custom home feature diff --git a/docs/getting_started/user-guide.rst b/docs/getting_started/user-guide.rst index 81b8cf868..0ca94be04 100644 --- a/docs/getting_started/user-guide.rst +++ b/docs/getting_started/user-guide.rst @@ -327,9 +327,12 @@ you can add or remove entries via the config variable ``registry`` .. code-block:: console # change to your own registry of container yaml configs - $ shpc config set registry:/opt/lmod/registry + $ shpc config add registry:/opt/lmod/registry +# Note that "add" is used for lists of things (e.g., the registry config variable is a list) +and "set" is used to set a key value pair. + Module Names ------------ diff --git a/shpc/main/modules/__init__.py b/shpc/main/modules/__init__.py index f934313b8..6e661855b 100644 --- a/shpc/main/modules/__init__.py +++ b/shpc/main/modules/__init__.py @@ -11,6 +11,7 @@ from datetime import datetime import os +from pathlib import Path import shutil import subprocess import sys @@ -304,6 +305,12 @@ def install(self, name, tag=None, **kwargs): container_dir = self.container.container_dir(subfolder) shpc.utils.mkdirp([module_dir, container_dir]) + # Add a .version file to indicate the level of versioning + version_dir = os.path.join(self.settings.module_base, uri) + version_file = os.path.join(version_dir, ".version") + if not os.path.exists(version_file): + Path(version_file).touch() + # For Singularity this is a path, podman is a uri. If None is returned # there was an error and we cleanup container_path = self.container.registry_pull( diff --git a/shpc/version.py b/shpc/version.py index 0f59b0760..a602d6278 100644 --- a/shpc/version.py +++ b/shpc/version.py @@ -2,7 +2,7 @@ __copyright__ = "Copyright 2021, Vanessa Sochat" __license__ = "MPL 2.0" -__version__ = "0.0.34" +__version__ = "0.0.35" AUTHOR = "Vanessa Sochat" NAME = "singularity-hpc" PACKAGE_URL = "https://github.com/singularityhub/singularity-hpc" From bb72ce14ab9098f0b30367869305d48ac7bf8454 Mon Sep 17 00:00:00 2001 From: vsoch Date: Thu, 4 Nov 2021 17:44:27 -0600 Subject: [PATCH 2/3] do not write .version file for tcl Signed-off-by: vsoch --- shpc/main/modules/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shpc/main/modules/__init__.py b/shpc/main/modules/__init__.py index 6e661855b..83436b57f 100644 --- a/shpc/main/modules/__init__.py +++ b/shpc/main/modules/__init__.py @@ -305,11 +305,12 @@ def install(self, name, tag=None, **kwargs): container_dir = self.container.container_dir(subfolder) shpc.utils.mkdirp([module_dir, container_dir]) - # Add a .version file to indicate the level of versioning - version_dir = os.path.join(self.settings.module_base, uri) - version_file = os.path.join(version_dir, ".version") - if not os.path.exists(version_file): - Path(version_file).touch() + # Add a .version file to indicate the level of versioning (not for tcl) + if self.module_extension != "tcl": + version_dir = os.path.join(self.settings.module_base, uri) + version_file = os.path.join(version_dir, ".version") + if not os.path.exists(version_file): + Path(version_file).touch() # For Singularity this is a path, podman is a uri. If None is returned # there was an error and we cleanup From 6dc57aa61699b402f105c13585066b604dca3cfd Mon Sep 17 00:00:00 2001 From: vsoch Date: Thu, 4 Nov 2021 20:00:02 -0600 Subject: [PATCH 3/3] have .version generation determined by default_version in settings with default as true, as it makes the modules a little better organized. Signed-off-by: vsoch --- docs/getting_started/user-guide.rst | 3 +++ shpc/main/modules/__init__.py | 2 +- shpc/main/schemas.py | 1 + shpc/settings.yml | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/getting_started/user-guide.rst b/docs/getting_started/user-guide.rst index 0ca94be04..9f6e732b3 100644 --- a/docs/getting_started/user-guide.rst +++ b/docs/getting_started/user-guide.rst @@ -174,6 +174,9 @@ variable replacement. A summary table of variables is included below, and then f * - updated_at - a timestamp to keep track of when you last saved - never + * - default_version + - A boolean to indicate generating a .version file (LMOD or lua modules only) + - true * - singularity_module - if defined, add to module script to load this Singularity module first - null diff --git a/shpc/main/modules/__init__.py b/shpc/main/modules/__init__.py index 83436b57f..1e72422e7 100644 --- a/shpc/main/modules/__init__.py +++ b/shpc/main/modules/__init__.py @@ -306,7 +306,7 @@ def install(self, name, tag=None, **kwargs): shpc.utils.mkdirp([module_dir, container_dir]) # Add a .version file to indicate the level of versioning (not for tcl) - if self.module_extension != "tcl": + if self.module_extension != "tcl" and self.settings.default_version == True: version_dir = os.path.join(self.settings.module_base, uri) version_file = os.path.join(version_dir, ".version") if not os.path.exists(version_file): diff --git a/shpc/main/schemas.py b/shpc/main/schemas.py index 3a1220479..ae0d7d0a0 100644 --- a/shpc/main/schemas.py +++ b/shpc/main/schemas.py @@ -122,6 +122,7 @@ "module_name": {"type": "string"}, "config_editor": {"type": "string"}, "environment_file": {"type": "string"}, + "default_version": {"type": "boolean"}, "enable_tty": {"type": "boolean"}, "container_tech": {"type": "string", "enum": ["singularity", "podman", "docker"]}, "singularity_shell": {"type": "string", "enum": shells}, diff --git a/shpc/settings.yml b/shpc/settings.yml index 8006dbd21..c89aa78f0 100644 --- a/shpc/settings.yml +++ b/shpc/settings.yml @@ -26,6 +26,9 @@ module_base: $root_dir/modules # This is where you might add a prefix to your module names, if desired. module_name: '{{ tool }}' +# Create a .version file for LMOD in the module folder +default_version: true + # store containers separately from module files container_base: