Exemplo n.º 1
0
    def test_equality(self):
        ts1 = toggle_set(['one', 'two',])
        ts2 = toggle_set(['one', 'two', '~three'])

        assert_not_equal(ts1, ts2)
        assert_equal(ts1.values(), ts2.values())
        assert_equal(ts2, toggle_set(['two', '~three', 'one']))
Exemplo n.º 2
0
    def test_equality(self):
        ts1 = toggle_set([
            'one',
            'two',
        ])
        ts2 = toggle_set(['one', 'two', '~three'])

        assert_not_equal(ts1, ts2)
        assert_equal(ts1.values(), ts2.values())
        assert_equal(ts2, toggle_set(['two', '~three', 'one']))
Exemplo n.º 3
0
    def execute(self, config, args):  # pylint: disable=arguments-differ
        output = self.set_up_output_directory(config, args)
        log.add_file(output.logfile)
        output.add_artifact('runlog', output.logfile, kind='log',
                            description='Run log.')

        disabled_augmentations = toggle_set([i != '~~' and "~{}".format(i) or i
                                            for i in args.augmentations_to_disable])
        config.jobs_config.disable_augmentations(disabled_augmentations)
        config.jobs_config.only_run_ids(args.only_run_ids)

        parser = AgendaParser()
        if os.path.isfile(args.agenda):
            includes = parser.load_from_path(config, args.agenda)
            shutil.copy(args.agenda, output.raw_config_dir)
            for inc in includes:
                shutil.copy(inc, output.raw_config_dir)
        else:
            try:
                pluginloader.get_plugin_class(args.agenda, kind='workload')
                agenda = {'workloads': [{'name': args.agenda}]}
                parser.load(config, agenda, 'CMDLINE_ARGS')
            except NotFoundError:
                msg = 'Agenda file "{}" does not exist, and there no workload '\
                      'with that name.\nYou can get a list of available '\
                      'by running "wa list workloads".'
                raise ConfigError(msg.format(args.agenda))

        # Update run info with newly parsed config values
        output.info.project = config.run_config.project
        output.info.project_stage = config.run_config.project_stage
        output.info.run_name = config.run_config.run_name

        executor = Executor()
        executor.execute(config, output)
Exemplo n.º 4
0
    def test_merge(self):
        ts1 = toggle_set(['one', 'two', 'three', '~four', '~five'])
        ts2 = toggle_set(['two', '~three', 'four', '~five'])

        ts3 = ts1.merge_with(ts2)
        assert_equal(ts1, toggle_set(['one', 'two', 'three', '~four', '~five']))
        assert_equal(ts2, toggle_set(['two', '~three', 'four', '~five']))
        assert_equal(ts3, toggle_set(['one', 'two', '~three', 'four', '~five']))
        assert_equal(ts3.values(), set(['one', 'two','four']))

        ts4 = ts1.merge_into(ts2)
        assert_equal(ts1, toggle_set(['one', 'two', 'three', '~four', '~five']))
        assert_equal(ts2, toggle_set(['two', '~three', 'four', '~five']))
        assert_equal(ts4, toggle_set(['one', 'two', 'three', '~four', '~five']))
        assert_equal(ts4.values(), set(['one', 'two', 'three']))
Exemplo n.º 5
0
    def test_merge(self):
        ts1 = toggle_set(['one', 'two', 'three', '~four', '~five'])
        ts2 = toggle_set(['two', '~three', 'four', '~five'])

        ts3 = ts1.merge_with(ts2)
        assert_equal(ts1, toggle_set(['one', 'two', 'three', '~four',
                                      '~five']))
        assert_equal(ts2, toggle_set(['two', '~three', 'four', '~five']))
        assert_equal(ts3, toggle_set(['one', 'two', '~three', 'four',
                                      '~five']))
        assert_equal(ts3.values(), set(['one', 'two', 'four']))

        ts4 = ts1.merge_into(ts2)
        assert_equal(ts1, toggle_set(['one', 'two', 'three', '~four',
                                      '~five']))
        assert_equal(ts2, toggle_set(['two', '~three', 'four', '~five']))
        assert_equal(ts4, toggle_set(['one', 'two', 'three', '~four',
                                      '~five']))
        assert_equal(ts4.values(), set(['one', 'two', 'three']))
Exemplo n.º 6
0
    def __init__(self, plugin_cache):
        self.plugin_cache = plugin_cache
        self.ids_to_run = []
        self.workloads = []
        self._enabled_augmentations = toggle_set()
        self._enabled_instruments = None
        self._enabled_processors = None
        self._read_augmentations = False
        self.disabled_augmentations = set()

        self.job_spec_template = obj_dict(not_in_dict=['name'])
        self.job_spec_template.name = "globally specified job spec configuration"
        self.job_spec_template.id = "global"
        # Load defaults
        for cfg_point in JobSpec.configuration.values():
            cfg_point.set_value(self.job_spec_template, check_mandatory=False)

        self.root_node = SectionNode(self.job_spec_template)
Exemplo n.º 7
0
    def __init__(self, plugin_cache):
        self.plugin_cache = plugin_cache
        self.ids_to_run = []
        self.workloads = []
        self._enabled_augmentations = toggle_set()
        self._enabled_instruments = None
        self._enabled_processors = None
        self._read_augmentations = False
        self.disabled_augmentations = set()

        self.job_spec_template = obj_dict(not_in_dict=['name'])
        self.job_spec_template.name = "globally specified job spec configuration"
        self.job_spec_template.id = "global"
        # Load defaults
        for cfg_point in JobSpec.configuration.values():
            cfg_point.set_value(self.job_spec_template, check_mandatory=False)

        self.root_node = SectionNode(self.job_spec_template)
Exemplo n.º 8
0
    def test_drop_all_previous(self):
        ts1 = toggle_set(['one', 'two', 'three'])
        ts2 = toggle_set(['four', '~~', 'five'])
        ts3 = toggle_set(['six', 'seven', '~three'])

        ts4 = ts1.merge_with(ts2).merge_with(ts3)
        assert_equal(ts4, toggle_set(['four', 'five', 'six', 'seven', '~three', '~~']))

        ts5 = ts2.merge_into(ts3).merge_into(ts1)
        assert_equal(ts5, toggle_set(['four', 'five', '~~']))

        ts6 = ts2.merge_into(ts3).merge_with(ts1)
        assert_equal(ts6, toggle_set(['one', 'two', 'three', 'four', 'five', '~~']))
Exemplo n.º 9
0
def merge_augmentations(raw):
    """
    Since, from configuration perspective, output processors and instruments are
    handled identically, the configuration entries are now interchangeable. E.g. it is
    now valid to specify a output processor in an instruments list. This is to make things
    easier for the users, as, from their perspective, the distinction is somewhat arbitrary.

    For backwards compatibility, both entries are still valid, and this
    function merges them together into a single "augmentations" set, ensuring
    that there are no conflicts between the entries.

    """
    cfg_point = JobSpec.configuration['augmentations']
    names = [
        cfg_point.name,
    ] + cfg_point.aliases

    entries = []
    for n in names:
        if n not in raw:
            continue
        value = raw.pop(n)
        try:
            entries.append(toggle_set(value))
        except TypeError as exc:
            msg = 'Invalid value "{}" for "{}": {}'
            raise ConfigError(msg.format(value, n, exc))

    # Make sure none of the specified aliases conflict with each other
    to_check = list(entries)
    while len(to_check) > 1:
        check_entry = to_check.pop()
        for e in to_check:
            conflicts = check_entry.conflicts_with(e)
            if conflicts:
                msg = '"{}" and "{}" have conflicting entries: {}'
                conflict_string = ', '.join('"{}"'.format(c.strip("~"))
                                            for c in conflicts)
                raise ConfigError(msg.format(check_entry, e, conflict_string))

    if entries:
        raw['augmentations'] = reduce(lambda x, y: x.union(y), entries)
Exemplo n.º 10
0
    def test_drop_all_previous(self):
        ts1 = toggle_set(['one', 'two', 'three'])
        ts2 = toggle_set(['four', '~~', 'five'])
        ts3 = toggle_set(['six', 'seven', '~three'])

        ts4 = ts1.merge_with(ts2).merge_with(ts3)
        assert_equal(
            ts4, toggle_set(['four', 'five', 'six', 'seven', '~three', '~~']))

        ts5 = ts2.merge_into(ts3).merge_into(ts1)
        assert_equal(ts5, toggle_set(['four', 'five', '~~']))

        ts6 = ts2.merge_into(ts3).merge_with(ts1)
        assert_equal(ts6,
                     toggle_set(['one', 'two', 'three', 'four', 'five', '~~']))
Exemplo n.º 11
0
def merge_augmentations(raw):
    """
    Since, from configuration perspective, output processors and instruments are
    handled identically, the configuration entries are now interchangeable. E.g. it is
    now valid to specify a output processor in an instruments list. This is to make things
    easier for the users, as, from their perspective, the distinction is somewhat arbitrary.

    For backwards compatibility, both entries are still valid, and this
    function merges them together into a single "augmentations" set, ensuring
    that there are no conflicts between the entries.

    """
    cfg_point = JobSpec.configuration['augmentations']
    names = [cfg_point.name, ] + cfg_point.aliases

    entries = []
    for n in names:
        if n not in raw:
            continue
        value = raw.pop(n)
        try:
            entries.append(toggle_set(value))
        except TypeError as exc:
            msg = 'Invalid value "{}" for "{}": {}'
            raise ConfigError(msg.format(value, n, exc))

    # Make sure none of the specified aliases conflict with each other
    to_check = [e for e in entries]
    while len(to_check) > 1:
        check_entry = to_check.pop()
        for e in to_check:
            conflicts = check_entry.conflicts_with(e)
            if conflicts:
                msg = '"{}" and "{}" have conflicting entries: {}'
                conflict_string = ', '.join('"{}"'.format(c.strip("~"))
                                            for c in conflicts)
                raise ConfigError(msg.format(check_entry, e, conflict_string))

    if entries:
        raw['augmentations'] = reduce(lambda x, y: x.union(y), entries)
Exemplo n.º 12
0
    def execute(self, config, args):  # pylint: disable=arguments-differ
        output = self.set_up_output_directory(config, args)
        log.add_file(output.logfile)
        output.add_artifact('runlog',
                            output.logfile,
                            kind='log',
                            description='Run log.')

        disabled_augmentations = toggle_set([
            i != '~~' and "~{}".format(i) or i
            for i in args.augmentations_to_disable
        ])
        config.jobs_config.disable_augmentations(disabled_augmentations)
        config.jobs_config.only_run_ids(args.only_run_ids)

        parser = AgendaParser()
        if os.path.isfile(args.agenda):
            includes = parser.load_from_path(config, args.agenda)
            shutil.copy(args.agenda, output.raw_config_dir)
            for inc in includes:
                shutil.copy(inc, output.raw_config_dir)
        else:
            try:
                pluginloader.get_plugin_class(args.agenda, kind='workload')
                agenda = {'workloads': [{'name': args.agenda}]}
                parser.load(config, agenda, 'CMDLINE_ARGS')
            except NotFoundError:
                msg = 'Agenda file "{}" does not exist, and there no workload '\
                      'with that name.\nYou can get a list of available '\
                      'by running "wa list workloads".'
                raise ConfigError(msg.format(args.agenda))

        # Update run info with newly parsed config values
        output.info.project = config.run_config.project
        output.info.project_stage = config.run_config.project_stage
        output.info.run_name = config.run_config.run_name

        executor = Executor()
        executor.execute(config, output)
Exemplo n.º 13
0
    def test_order_on_create(self):
        ts1 = toggle_set(['one', 'two', 'three', '~one'])
        assert_equal(ts1, toggle_set(['~one', 'two', 'three']))

        ts1 = toggle_set(['~one', 'two', 'three', 'one'])
        assert_equal(ts1, toggle_set(['one', 'two', 'three']))