示例#1
0
def initialize_framework(default_config='default.yaml', **kwargs):
    """
    Reads default config if exists
    Args:
        config_data:

    Returns:

    """

    if os.path.exists(default_config):
        config_manager.load_yaml(default_config, section=MainConfig._section)
        config_manager.update_config(main_config)
        register_modules(main_config.modules)

        # set logging levels
        get_logger.set_level(main_config.log_level_console)
        get_logger.set_filehandler_level(main_config.log_level_file)

        if main_config.plotting_backend != None:
            import matplotlib.pyplot as plt
            plt.switch_backend(main_config.plotting_backend)

        # reload config, now that we have registered the modules.
        config_manager.load_yaml(default_config)
    else:
        logger.warning(f'Did not find default config ("{default_config}").')
    def load(self, name):
        """
            Load existing experiment
            path: Path where experiment is stored
        """
        self._experiment_name = name
        full_path = os.path.join(self._experiment_dir, name)
        if not os.path.exists(full_path):
            raise Exception("Could not find experiment directory (%s)." % full_path)

        self._directory = full_path

        # set path for log files
        get_logger.set_path(self._directory)

        # load config and update own config
        config_manager.load_yaml(os.path.join(self._directory, 'experiment.yaml'))
        config_manager.update_config(self.config)

        self._dbase = DataBase(self._directory)
        self._dbase.open()
        if not 'timestamp' in self._dbase.hdf5.attrs:
            logger.warning("timestamp not set, adding now.")
            self._dbase.hdf5.attrs['timestamp'] = get_timestamp()
        self._timestamp = self._dbase.hdf5.attrs['timestamp']
        logger.info(f'Loaded experiment from {self._directory}.')
示例#3
0
def load_config(path):
    config_manager.load_yaml(path)
    config_manager.update_config(main_config)