How to use the hpccm.primitives.label.label function in hpccm

To help you get started, we’ve selected a few hpccm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NVIDIA / hpc-container-maker / test / test_label.py View on Github external
def test_merge_docker(self):
        """merge primitives"""
        l = []
        l.append(label(metadata={'ONE': 1, 'TWO': 2}))
        l.append(label(metadata={'THREE': 3}))
        merged = l[0].merge(l)
        self.assertEqual(str(merged),
'''LABEL ONE=1 \\
    THREE=3 \\
    TWO=2''')

        l.append(label(metadata={'ONE': 'uno'}))
        key_overwrite = l[0].merge(l)
        self.assertEqual(str(key_overwrite),
'''LABEL ONE=uno \\
    THREE=3 \\
github NVIDIA / hpc-container-maker / test / test_label.py View on Github external
def test_multiple_docker(self):
        """Multiple labels specified"""
        l = label(metadata={'ONE': 1, 'TWO': 2, 'THREE': 3})
        self.assertEqual(str(l),
'''LABEL ONE=1 \\
    THREE=3 \\
github NVIDIA / hpc-container-maker / test / test_label.py View on Github external
def test_empty(self):
        """No label specified"""
        l = label()
        self.assertEqual(str(l), '')
github NVIDIA / hpc-container-maker / test / test_scif.py View on Github external
def test_allsections_docker(self):
        """One of each SCI-f section type"""
        # See comment in the test_defaults_docker test case
        scif_file = tempfile.NamedTemporaryFile(delete=False, suffix='.scif')
        s = scif(name='foo', file=scif_file.name)
        s += copy(src='file', dest='/tmp/file')
        s += comment('My app')
        s += environment(variables={'ONE': '1'})
        s += label(metadata={'A': 'B'})
        s += runscript(commands=['default_program'])
        s += shell(commands=['build_cmds'])
        s += shell(commands=['test_program'], _test=True)

        str(s) # Force writing the SCI-F recipe file

        # slurp file content
        with open(scif_file.name) as f:
            content = f.read()
        try:
            os.unlink(scif_file.name)
        except WindowsError:
            # WindowsError: [Error 32] The process cannot access the file
            # because it is being used by another process
            pass
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_autotools.py View on Github external
"""
        if self.prefix:
            if self.__comment:
                if self.url:
                    self.rt += comment(self.url, reformat=False)
                elif self.repository:
                    self.rt += comment(self.repository, reformat=False)
            self.rt += copy(_from=_from, src=self.prefix, dest=self.prefix)
            if self.ldconfig:
                self.rt += shell(commands=[self.ldcache_step(
                    directory=posixpath.join(self.prefix, self.__libdir))])
            if self.runtime_environment_variables:
                self.rt += environment(
                    variables=self.environment_step(runtime=True))
            if self.annotate:
                self.rt += label(metadata=self.annotate_step())
            return str(self.rt)
        else: # pragma: no cover
            return
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_build.py View on Github external
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())
github NVIDIA / hpc-container-maker / hpccm / primitives / label.py View on Github external
primitive may not be exact.

        """

        if not lst: # pragma: nocover
            raise RuntimeError('no items provided to merge')

        labels = {}
        for item in lst:
            if not item.__class__.__name__ == 'label': # pragma: nocover
                logging.warning('item is not the correct type, skipping...')
                continue

            labels.update(item._label__metadata)

        return label(metadata=labels, _app=_app)
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_autotools.py View on Github external
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())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_cmake.py View on Github external
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())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / multi_ofed.py View on Github external
prefix=posixpath.join(self.__prefix, version),
                              symlink=self.__symlink,
                              version=version)

        # Inbox OFED
        if self.__inbox:
            self += ofed(prefix=posixpath.join(self.__prefix, 'inbox'),
                         symlink=self.__symlink)
            self += shell(commands=['ln -s {0} {1}'.format(
                posixpath.join(self.__prefix, 'inbox'),
                posixpath.join(self.__prefix, '5.0-0'))])

        # Annotations
        self.add_annotation('mlnx_versions', ', '.join(self.__mlnx_versions))
        self.add_annotation('inbox', self.__inbox)
        self += label(metadata=self.annotate_step())