Ejemplo n.º 1
0
    def load_configuration(self):
        """Loads configuration specified by a user on a command line.

        At this moment, DLBS has already loaded standard configuration (if `discard_default_config` flag is not
        present). DLBS will try to load user configuration from `config` file (if not None) overwriting default
        parameters. Then, it will try to load user provided parameters (`params`, `vars` and `extensions`) that will
        overwrite existing configuration.

        If `plan` file is present, it will be loaded if `action` is `run`.
        """
        if self.config_file is not None:
            logging.debug('Loading configuration from: %s', self.config_file)
            with open(self.config_file) as file_obj:
                user_config = json.load(file_obj)
                # Update parameter information from user configuration.
                ConfigurationLoader.update_param_info(self.param_info,
                                                      user_config,
                                                      is_user_config=True)
                # Update existing benchmark configuration.
                ConfigurationLoader.update(
                    self.config, ConfigurationLoader.remove_info(user_config))
        if self.plan_file is not None and self.action == 'run':
            logging.debug('Loading plan from: %s', self.plan_file)
            with open(self.plan_file) as plan_file:
                self.plan = json.load(plan_file)
 def load_configuration(self):
     """Loads configuration specified by a user on a command line."""
     if self.config_file is not None:
         logging.debug('Loading configuration from: %s', self.config_file)
         with open(self.config_file) as file_obj:
             user_config = json.load(file_obj)
             # Update parameter information from user configuration.
             ConfigurationLoader.update_param_info(self.param_info,
                                                   user_config,
                                                   is_user_config=True)
             # Update existing benchmark configuration.
             ConfigurationLoader.update(
                 self.config, ConfigurationLoader.remove_info(user_config))
     if self.plan_file is not None and self.action == 'run':
         logging.debug('Loading plan from: %s', self.plan_file)
         with open(self.plan_file) as plan_file:
             self.plan = json.load(plan_file)
Ejemplo n.º 3
0
 def test_remove_info(self):
     config = ConfigurationLoader.remove_info({
         'parameters': {
             'p1': 1,
             'p2': u'2',
             'p3': '3',
             'p4': ['1', '2', '3', '4'],
             'p5': False,
             'p6': -3.33,
             'p7': {
                 'val': '34',
                 'type': 's3tr',
                 'desc': 'Some desc'
             }
         }
     })
     for p in ('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7'):
         self.assertIn(p, config['parameters'])
     for s in (('p1', 1), ('p2', u'2'), ('p3', '3'),
               ('p4', ['1', '2', '3',
                       '4']), ('p5', False), ('p6', -3.33), ('p7', '34')):
         self.assertEqual(config['parameters'][s[0]], s[1])