Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_merge_file_singularity(self):
"""merge primitives"""
c = []
c.append(copy(src='a', dest='A'))
c.append(copy(src='b', dest='B'))
merged = c[0].merge(c)
self.assertEqual(str(merged), '%files\n a A\n b B')
def test_multiple_docker(self):
"""Multiple source files specified"""
c = copy(src=['a1', 'a2', 'a3'], dest='b')
self.assertEqual(str(c), 'COPY a1 \\\n a2 \\\n a3 \\\n b/')
def test_appfiles_files_singularity(self):
"""Pairs of app-specific files specified"""
c = copy(files={'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}, _app='foo')
self.assertEqual(str(c),
'%appfiles foo\n a1 b1\n a2 b2\n a3 b3')
def test_appfiles_multiple_singularity(self):
"""Multiple app-specific source files specified"""
c = copy(src=['a1', 'a2', 'a3'], dest='b', _app='foo')
self.assertEqual(str(c),
'%appfiles foo\n a1 b\n a2 b\n a3 b')
def test_invalid_ctype(self):
"""Invalid container type specified"""
c = copy(src='a', dest='b')
with self.assertRaises(RuntimeError):
str(c)
def test_post_multiple_singularity(self):
"""move file during post"""
c = copy(src=['a', 'b'], dest='/opt', _post=True)
self.assertEqual(str(c),
'%files\n a /\n b /\n%post\n mv /a /opt/a\n mv /b /opt/b')
def test_appfiles_docker(self):
"""app-parameter is ignored in Docker"""
c = copy(src=['a1', 'a2', 'a3'], dest='b', _app='foo')
self.assertEqual(str(c), 'COPY a1 \\\n a2 \\\n a3 \\\n b/')
def __instructions(self):
"""Fill in container instructions"""
if self.__comment:
if self.url:
self += comment(self.url, reformat=False)
elif self.repository:
self += comment(self.repository, reformat=False)
elif self.package:
self += comment(self.package, reformat=False)
if self.package:
self += copy(src=self.package,
dest=posixpath.join(self.__wd,
os.path.basename(self.package)))
self += shell(_arguments=self.__run_arguments,
commands=self.__commands)
self += environment(variables=self.environment_step())
self += label(metadata=self.annotate_step())
```python
o = ofed(...)
Stage0 += o
Stage1 += o.runtime()
```
"""
if self.__prefix:
self.rt += comment('OFED')
if self.__deppackages:
self.rt += packages(ospackages=self.__deppackages)
# Suppress warnings from libibverbs
self.rt += shell(commands=['mkdir -p /etc/libibverbs.d'])
self.rt += copy(_from=_from, dest=self.__prefix, src=self.__prefix)
return str(self.rt)
else:
return str(self)
def runtime(self, _from='0'):
"""Generate the set of instructions to install the runtime specific
components from a build in a previous stage.
# Examples
```python
n = nvshmem(...)
Stage0 += n
Stage1 += n.runtime()
```
"""
self.rt += comment('NVSHMEM')
if self.__binary_tarball:
self.rt += copy(_from=_from, src=self.__prefix, dest=self.__prefix)
self.rt += environment(variables=self.environment_step())
else:
self.rt += self.__bb.runtime(_from=_from)
return str(self.rt)