Skip to content

Commit d70803e

Browse files
authored
First round of fixes (#364)
* fixing bug with shpc test and copying containers instead of moving them * adding fix for shpc inspect Signed-off-by: vsoch <[email protected]>
1 parent ed2d000 commit d70803e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
shpc.db
22
singularity_hpc.egg-info/
3+
env
34
.env
45
env
56
build

shpc/main/modules.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ def _cleanup(self, module_dir):
4949
break
5050
shutil.rmtree(module_dir)
5151

52+
@property
53+
def container_base(self):
54+
"""
55+
Quickly return what is being used for the container base
56+
"""
57+
if not self.settings.container_base:
58+
return self.settings.module_base
59+
return self.settings.container_base
60+
5261
def container_dir(self, name):
5362
"""
5463
Use a custom container directory, otherwise default to module dir.
@@ -95,7 +104,7 @@ def _test(self, module_name, module_dir, tag, template="test.sh"):
95104
Run specific tests for this module
96105
"""
97106
# Generate a test template
98-
template = self._load_template(template)
107+
template = self._load_template(template or "test.sh")
99108
test_file = os.path.join(module_dir, "test.sh")
100109

101110
# Generate the test script
@@ -117,7 +126,7 @@ def _mkdirp(self, dirnames):
117126

118127
def add(self, sif, module_name):
119128
"""
120-
Add a container directly as a module
129+
Add a container directly as a module, copying the file.
121130
"""
122131
name = self.add_namespace(module_name)
123132
registry_dir = self.settings.registry
@@ -145,7 +154,7 @@ def add(self, sif, module_name):
145154
name = module_name.replace("/", "-")
146155
digest = utils.get_file_hash(sif)
147156
dest = os.path.join(container_dir, "%s-sha256:%s.sif" % (name, digest))
148-
shutil.move(sif, dest)
157+
shutil.copyfile(sif, dest)
149158
self._install(module_dir, dest, name)
150159
logger.info("Module %s was created." % (module_name))
151160

@@ -215,9 +224,8 @@ def inspect(self, module_name):
215224
"""
216225
Return complete metadata for the user from a container.
217226
"""
218-
module_dir = os.path.join(self.settings.module_base, module_name)
219-
if not os.path.exists(module_dir):
220-
logger.exit("%s does not exist." % module_dir)
227+
if not os.path.exists(self.container_base):
228+
logger.exit("%s does not exist." % self.container_base)
221229

222230
sif = self.get(module_name)
223231
return self._container.inspect(sif[0])

0 commit comments

Comments
 (0)