Skip to content

Commit f24060a

Browse files
authored
.version file should be written at the top level of module folders (#451)
* .version file should be written at the top level of module folders Signed-off-by: vsoch <[email protected]>
1 parent 1b80083 commit f24060a

File tree

6 files changed

+21
-2
lines changed

6 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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+
- `.version` file should be written in top level of module folders [#450](https://github.com/singularityhub/singularity-hpc/issues/450) (0.0.35)
1718
- Tcl modules use shell functions for bash, to export to child shells (0.0.34)
1819
- fixed missing singularity -B flag for custom home feature
1920
- fixed singularity.tcl to always replace $ with \$ for custom home feature

docs/getting_started/user-guide.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ variable replacement. A summary table of variables is included below, and then f
174174
* - updated_at
175175
- a timestamp to keep track of when you last saved
176176
- never
177+
* - default_version
178+
- A boolean to indicate generating a .version file (LMOD or lua modules only)
179+
- true
177180
* - singularity_module
178181
- if defined, add to module script to load this Singularity module first
179182
- null
@@ -327,8 +330,11 @@ you can add or remove entries via the config variable ``registry``
327330
.. code-block:: console
328331
329332
# change to your own registry of container yaml configs
330-
$ shpc config set registry:/opt/lmod/registry
333+
$ shpc config add registry:/opt/lmod/registry
334+
331335
336+
# Note that "add" is used for lists of things (e.g., the registry config variable is a list)
337+
and "set" is used to set a key value pair.
332338

333339

334340
Module Names

shpc/main/modules/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from datetime import datetime
1313
import os
14+
from pathlib import Path
1415
import shutil
1516
import subprocess
1617
import sys
@@ -304,6 +305,13 @@ def install(self, name, tag=None, **kwargs):
304305
container_dir = self.container.container_dir(subfolder)
305306
shpc.utils.mkdirp([module_dir, container_dir])
306307

308+
# Add a .version file to indicate the level of versioning (not for tcl)
309+
if self.module_extension != "tcl" and self.settings.default_version == True:
310+
version_dir = os.path.join(self.settings.module_base, uri)
311+
version_file = os.path.join(version_dir, ".version")
312+
if not os.path.exists(version_file):
313+
Path(version_file).touch()
314+
307315
# For Singularity this is a path, podman is a uri. If None is returned
308316
# there was an error and we cleanup
309317
container_path = self.container.registry_pull(

shpc/main/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"module_name": {"type": "string"},
123123
"config_editor": {"type": "string"},
124124
"environment_file": {"type": "string"},
125+
"default_version": {"type": "boolean"},
125126
"enable_tty": {"type": "boolean"},
126127
"container_tech": {"type": "string", "enum": ["singularity", "podman", "docker"]},
127128
"singularity_shell": {"type": "string", "enum": shells},

shpc/settings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module_base: $root_dir/modules
2626
# This is where you might add a prefix to your module names, if desired.
2727
module_name: '{{ tool }}'
2828

29+
# Create a .version file for LMOD in the module folder
30+
default_version: true
31+
2932
# store containers separately from module files
3033
container_base:
3134

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, Vanessa Sochat"
33
__license__ = "MPL 2.0"
44

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

0 commit comments

Comments
 (0)