def test_init_correct_params_but_database_path_not_defined(self): replay_path = None if "REPLAY_ATTACK_PATH" in os.environ: replay_path = os.environ["REPLAY_ATTACK_PATH"] del os.environ["REPLAY_ATTACK_PATH"] self.assertRaises( EnvironmentError, lambda: Configuration( 'ACE', self.database_paths_filename, ['replay-attack'], self.protocols, self.feature_extractor, self.pipeline, self.result_path, access_grid_config=self.access_grid_config, verbose=self.verbose, number_threads=self.number_threads, use_data_augmentation=self.use_data_augmentation, skip_features_extraction=self.skip_features_extraction, dict_extracted_features_paths=self. dict_extracted_features_paths, skip_training=self.skip_training, skip_scores_prediction=self.skip_scores_prediction, dict_scores_prediction=self.dict_scores_prediction, recreate=self.recreate)) if replay_path: os.environ["REPLAY_ATTACK_PATH"] = replay_path
def main(): args = evaluator_parser() if args.verbose: logging.basicConfig(level=logging.INFO) configuration = Configuration.fromfilename('FE', args.config_file) logging.info(configuration) configuration.save_to_file() features_extraction_protocol = FeaturesExtractionProtocol(configuration) features_extraction_protocol.run()
def main(): args = evaluator_parser() if args.verbose: logging.basicConfig(level=logging.INFO) configuration = Configuration.fromfilename('ACE', args.config_file) logging.info(configuration) configuration.save_to_file() algorithmic_constrained_evaluation_protocol = AlgorithmicConstrainedEvaluationProtocol( configuration) algorithmic_constrained_evaluation_protocol.run()
def test_init_incorrect_databases_param_no_exist(self): self.assertRaises( ValueError, lambda: Configuration( 'ACE', self.database_paths_filename, ['no_exist_database'], self.protocols, self.feature_extractor, self.pipeline, self.result_path, access_grid_config=self.access_grid_config, verbose=self.verbose, number_threads=self.number_threads, use_data_augmentation=self.use_data_augmentation, skip_features_extraction=self.skip_features_extraction, dict_extracted_features_paths=self. dict_extracted_features_paths, skip_training=self.skip_training, skip_scores_prediction=self.skip_scores_prediction, dict_scores_prediction=self.dict_scores_prediction, recreate=self.recreate))
def test_init_incorrect_result_path_param(self): os.environ["REPLAY_ATTACK_PATH"] = "resources" self.assertRaises( TypeError, lambda: Configuration( 'ACE', self.database_paths_filename, self.databases, self.protocols, self.feature_extractor, self.pipeline, ['WRONG_PARAM'], access_grid_config=self.access_grid_config, verbose=self.verbose, number_threads=self.number_threads, use_data_augmentation=self.use_data_augmentation, skip_features_extraction=self.skip_features_extraction, dict_extracted_features_paths=self. dict_extracted_features_paths, skip_training=self.skip_training, skip_scores_prediction=self.skip_scores_prediction, dict_scores_prediction=self.dict_scores_prediction, recreate=self.recreate)) del os.environ["REPLAY_ATTACK_PATH"]
def test_should_check_if_database_paths_are_loaded_as_global_env(self): if "REPLAY_ATTACK_PATH" in os.environ.keys(): del os.environ["REPLAY_ATTACK_PATH"] _ = Configuration( 'ACE', self.database_paths_filename, self.databases, self.protocols, self.feature_extractor, self.pipeline, self.result_path, access_grid_config=self.access_grid_config, verbose=self.verbose, number_threads=self.number_threads, use_data_augmentation=self.use_data_augmentation, skip_features_extraction=self.skip_features_extraction, dict_extracted_features_paths=self.dict_extracted_features_paths, skip_training=self.skip_training, skip_scores_prediction=self.skip_scores_prediction, dict_scores_prediction=self.dict_scores_prediction, recreate=True) self.assertTrue(os.environ["REPLAY_ATTACK_PATH"] == "resources") del os.environ["REPLAY_ATTACK_PATH"]
def test_init_fromfilename_correct_params(self): Configuration.fromfilename('ACE', self.configuration_file)
def test_print_to_file(self): filename_result = 'result/configuration.txt' configuration = Configuration.fromfilename('ACE', self.configuration_file) configuration.save_to_file(filename_result) self.assertTrue(os.path.isfile(filename_result))
def test_init_fromfilename_wrong_type_evaluation(self): self.assertRaises( ValueError, lambda: Configuration.fromfilename( 'WRONG', self.configuration_file))
def test_init_fromfilename_wrong_path(self): self.assertRaises(IOError, lambda: Configuration.fromfilename('ACE', 'WRONG'))
def get_configuration(cls, type_evaluation): return Configuration.fromfilename(type_evaluation, cls.configuration_file)