Skip to content

Commit 1d01bba

Browse files
Merge pull request #1 from boegel/singularity_tmp
--container-tmpdir fix + test
2 parents 0ba1794 + ada96e5 commit 1d01bba

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

easybuild/tools/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
124124
'container_base',
125125
'container_image_format',
126126
'container_image_name',
127-
'container_tmp_path',
127+
'container_tmpdir',
128128
'download_timeout',
129129
'dump_test_report',
130130
'easyblock',

easybuild/tools/containers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,13 @@ def build_singularity_image(def_path):
244244

245245
# resolve full path to 'singularity' binary, since it may not be available via $PATH under sudo...
246246
singularity = which('singularity')
247+
cmd_env = ''
247248

248-
singularity_tmp = build_option('container_tmp_path')
249+
singularity_tmpdir = build_option('container_tmpdir')
250+
if singularity_tmpdir:
251+
cmd_env += 'SINGULARITY_TMPDIR=%s' % singularity_tmpdir
249252

250-
cmd = "sudo SINGULARITY_TMPDIR=%s %s build %s %s %s" % (singularity_tmp, singularity, cmd_opts, img_path, def_path)
253+
cmd = ' '.join(['sudo', cmd_env, singularity, 'build', cmd_opts, img_path, def_path])
251254
print_msg("Running '%s', you may need to enter your 'sudo' password..." % cmd)
252255
run_cmd(cmd, stream_output=True)
253256
print_msg("Singularity image created at %s" % img_path, log=_log)

easybuild/tools/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def container_options(self):
637637
'build-image': ("Build container image (requires sudo privileges!)", None, 'store_true', False),
638638
'image-format': ("Container image format", 'choice', 'store', None, CONT_IMAGE_FORMATS),
639639
'image-name': ("Custom name for container image (defaults to name of easyconfig)", None, 'store', None),
640-
'tmp-path': ("Path to where container image is temporarily built", None, 'store', None),
640+
'tmpdir': ("Temporary directory where container image is built", None, 'store', None),
641641
'type': ("Type of container recipe/image to create", 'choice', 'store', DEFAULT_CONT_TYPE, CONT_TYPES),
642642
})
643643

test/framework/containers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def test_end2end_singularity_image(self):
229229
"^== Singularity tool found at %s/bin/singularity" % self.test_prefix,
230230
"^== Singularity version '2.4.0' is 2.4 or higher ... OK",
231231
"^== Singularity definition file created at %s/containers/Singularity\.toy-0.0" % self.test_prefix,
232-
"^== Running 'sudo .*/singularity build\s*/.* /.*', you may need to enter your 'sudo' password...",
232+
"^== Running 'sudo\s*\S*/singularity build\s*/.* /.*', you may need to enter your 'sudo' password...",
233233
"^== Singularity image created at %s/containers/toy-0.0\.simg" % self.test_prefix,
234234
]
235235
self.check_regexs(regexs, stdout)
@@ -246,7 +246,7 @@ def test_end2end_singularity_image(self):
246246
stdout, stderr = self.run_main(args)
247247
self.assertFalse(stderr)
248248
regexs[-3] = "^== Singularity definition file created at %s/containers/Singularity\.foo-bar" % self.test_prefix
249-
regexs[-2] = "^== Running 'sudo .*/singularity build --writable /.* /.*', you may need to enter .*"
249+
regexs[-2] = "^== Running 'sudo\s*\S*/singularity build --writable /.* /.*', you may need to enter .*"
250250
regexs[-1] = "^== Singularity image created at %s/containers/foo-bar\.img$" % self.test_prefix
251251
self.check_regexs(regexs, stdout)
252252

@@ -277,6 +277,13 @@ def test_end2end_singularity_image(self):
277277
self.assertFalse(stderr)
278278
self.check_regexs(regexs, stdout)
279279

280+
# test use of --container-tmpdir
281+
args.append('--container-tmpdir=%s' % self.test_prefix)
282+
stdout, stderr = self.run_main(args)
283+
self.assertFalse(stderr)
284+
regexs[-3] = "^== Running 'sudo\s*SINGULARITY_TMPDIR=%s \S*/singularity build .*" % self.test_prefix
285+
self.check_regexs(regexs, stdout)
286+
280287

281288
def suite():
282289
""" returns all the testcases in this module """

0 commit comments

Comments
 (0)