def reload_configuration(self): """ Load again the experiment configuration, reading the config file from disk """ self._configuration = ConfigParser.ConfigParser() self._configuration.read(self._config_file) Config.get_instance().read(self._config_file) return Config.to_dictionary(self._configuration)
def check_configuration(working_dir, experiment_name): if not os.path.exists(working_dir): raise InvalidExperimentException("Invalid working directory %s" % working_dir) experiment_db_name = experiment_name + ".db" experiment_cf_name = experiment_name + ".conf" experiment_db = os.path.join(working_dir, experiment_db_name) experiment_cf = os.path.join(working_dir, experiment_cf_name) if not os.path.exists(experiment_db): raise InvalidExperimentException("Database file does not exist %s" % experiment_db) if not os.path.exists(experiment_cf): raise InvalidExperimentException("Configuration file does not exist %s" % experiment_cf) # TODO: Validate that the configuration database its ok try: import ConfigParser config = ConfigParser.ConfigParser() config.readfp(open(experiment_cf)) if not config.getboolean("BEHAVIOUR", "save"): raise InvalidExperimentException("BEHAVIOUR::save configured as false in %s, must be true" % experiment_cf) conf_db = config.get("BEHAVIOUR", "savedir") if conf_db != experiment_db_name: raise InvalidExperimentException("Invalid DB name configured in %s: is '%s' and should be '%s'" % (experiment_cf, conf_db, experiment_db_name)) return Config.to_dictionary(config), experiment_db # TODO: We need to check for the existence of a Evaluation and Preevaluation folder. If so, we have to also # check if the variable in the configuration matches the file in this folders? except Exception, err: raise InvalidExperimentException("Error reading configuration file %s: %s" % (experiment_cf, err))
def load_configuration(configuration_file): config_parser = ConfigParser.ConfigParser() config_parser.read(configuration_file) return Config.to_dictionary(config_parser)
def get_configuration(self): return Config.to_dictionary(self._configuration)