def test_from(self): """Docker --from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(c.toString(container_type.DOCKER), 'COPY --from=dev a b') self.assertEqual(c.toString(container_type.SINGULARITY), '%files\n a b')
def test_multiple(self): """Multiple source files specified""" c = copy(src=['a1', 'a2', 'a3'], dest='b') self.assertEqual(c.toString(container_type.DOCKER), 'COPY a1 \\\n a2 \\\n a3 \\\n b/') self.assertEqual(c.toString(container_type.SINGULARITY), '%files\n a1 b\n a2 b\n a3 b')
def runtime(self, _from='0'): """Install the runtime from a full build in a previous stage""" instructions = [] instructions.append(comment('PGI compiler')) if self.__ospackages: instructions.append(packages(ospackages=self.__ospackages)) instructions.append( copy(_from=_from, src=os.path.join(self.__basepath, self.__version, 'REDIST', '*.so'), dest=os.path.join(self.__basepath, self.__version, 'lib', ''))) instructions.append( shell(commands=[ 'ln -s {0} {1}'.format( os.path.join(self.__basepath, self.__version, 'lib', 'libpgnuma.so'), os.path.join(self.__basepath, self.__version, 'lib', 'libnuma.so')) ])) instructions.append( environment( variables={ 'LD_LIBRARY_PATH': '{}:$LD_LIBRARY_PATH'.format( os.path.join(self.__basepath, self.__version, 'lib')) })) return instructions
def __str__(self): """String representation of the building block""" ospackages = list(self.__ospackages) # Installer needs perl ospackages.append('perl') instructions = [] instructions.append( comment('PGI compiler version {}'.format(self.__version))) if self.__tarball: # Use tarball from local build context instructions.append( copy(src=self.__tarball, dest=os.path.join(self.__wd, self.__tarball))) else: # Downloading, so need wget ospackages.append('wget') if ospackages: instructions.append(packages(ospackages=ospackages)) instructions.append(shell(commands=self.__commands)) instructions.append( environment( variables={ 'PATH': '{}:$PATH'.format( os.path.join(self.__basepath, self.__version, 'bin')), 'LD_LIBRARY_PATH': '{}:$LD_LIBRARY_PATH'.format( os.path.join(self.__basepath, self.__version, 'lib')) })) return '\n'.join(str(x) for x in instructions)
def runtime(self, _from='0'): """Install the runtime from a full build in a previous stage""" instructions = [] instructions.append(comment('Charm++')) instructions.append( copy(_from=_from, src=self.__installdir, dest=self.__installdir)) instructions.append( environment(variables=self.__environment_variables)) return instructions
def runtime(self, _from='0'): """Install the runtime from a full build in a previous stage""" instructions = [] instructions.append(comment('OpenMPI')) instructions.append(packages(ospackages=self.__runtime_ospackages)) instructions.append( copy(_from=_from, src=self.prefix, dest=self.prefix)) instructions.append( environment(variables=self.__environment_variables)) return instructions
def runtime(self, _from='0'): """Install the runtime from a full build in a previous stage""" instructions = [] instructions.append(comment('MVAPICH2')) # TODO: move the definition of runtime ospackages instructions.append(packages(ospackages=self.__runtime_ospackages)) instructions.append( copy(_from=_from, src=self.prefix, dest=self.prefix)) # No need to workaround compiler wrapper issue for the runtime. # Copy the dictionary so not to modify the original. vars = dict(self.__environment_variables) del vars['PROFILE_POSTLIB'] instructions.append(environment(variables=vars)) return instructions
def __str__(self): """String representation of the building block""" instructions = [] if self.__directory: instructions.append(comment('FFTW')) else: instructions.append( comment('FFTW version {}'.format(self.__version))) instructions.append(packages(ospackages=self.__ospackages)) if self.__directory: # Use source from local build context instructions.append( copy(src=self.__directory, dest=os.path.join(self.__wd, self.__directory))) instructions.append(shell(commands=self.__commands)) instructions.append( environment(variables=self.__environment_variables)) return '\n'.join(str(x) for x in instructions)
def test_empty(self): """No source or destination specified""" c = copy() self.assertEqual(c.toString(container_type.DOCKER), '')
def test_from_singularity(self): """Docker --from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(str(c), '%files\n a b')
def test_from_docker(self): """Docker --from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(str(c), 'COPY --from=dev a b')
def test_multiple_singularity(self): """Multiple source files specified""" c = copy(src=['a1', 'a2', 'a3'], dest='b') self.assertEqual(str(c), '%files\n a1 b\n a2 b\n a3 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_single_singularity(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(str(c), '%files\n a b')
def test_single_docker(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(str(c), 'COPY a b')
def test_invalid_ctype(self): """Invalid container type specified""" c = copy(src='a', dest='b') with self.assertRaises(RuntimeError): str(c)
def test_empty(self): """No source or destination specified""" c = copy() self.assertEqual(str(c), '')
def test_invalid_ctype(self): """Invalid container type specified""" c = copy(src='a', dest='b') self.assertEqual(c.toString(None), '')
def test_single(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(c.toString(container_type.DOCKER), 'COPY a b') self.assertEqual(c.toString(container_type.SINGULARITY), '%files\n a b')