def SetFromDb(self, db, experimentId): try: experimentController = ExperimentController(db, Experiment, None, None) experiment = experimentController.getRecordByKey(experimentId) defaultsController = AlgorithmDefaultsController(db, AlgorithmDefaults, None, None) defaults = defaultsController.getAll(experiment.algorithm_id) for d in defaults: self[str(d.parameter_name)] = str(d.default_value) configController = ExperimentConfigurationController(db, ExperimentConfiguration, None, None) configs = configController.getAll(experimentId) for c in configs: self[str(c.parameter_name)] = str(c.parameter_value) config_file = self.as_config_file(silent=False) return config_file except Exception as e: print e