def test_filter(self): task_manager = automation.TaskManager( [(dict( stoichiometry=(1, 2), place_max=4, sample_count=20, log_level=2, sample_groups=[WallpaperGroup(number=i + 1) for i in range(2)]), dict(potentials=TaskManagerTests._default_potentials, distance=4, log_level=2, basin_kwargs=dict(niter=5), save_all=True, save_count=3))], preprocessors=[ automation.AutoFilteringProcessor(count=2), automation.ScalingProcessor((0.5, 0.5)) ]) task_manager.work("data/testdb_filter.db") # Make sure that filtering did happen db = automation.ResultsDatabase("data/testdb_filter.db") self.assertEqual(len(list(db.cells_in)), 4) self.assertEqual(len(list(db.cells_out)), 12)
def test_multiple_jobs(self): # Make sure that system can handle multiple jobs task_manager = automation.TaskManager( [(dict( stoichiometry=(1, 2), place_max=4, sample_count=2, log_level=2, sample_groups=[WallpaperGroup(number=i + 1) for i in range(2)]), dict(potentials=TaskManagerTests._default_potentials, distance=4, log_level=2, basin_kwargs=dict(niter=5), save_all=True, save_count=3))] * 2) task_manager.work("data/testdb_multiple_jobs.db") # All processing should have still happened db = automation.ResultsDatabase("data/testdb_multiple_jobs.db") self.assertEqual(len(list(db.cells_in)), 4) self.assertEqual(len(list(db.cells_out)), 12)
def test_preprocessor(self): # Make sure processor gets called on each input task_manager = automation.TaskManager( [(dict( stoichiometry=(1, 2), place_max=4, sample_count=4, log_level=2, sample_groups=[WallpaperGroup(number=i + 1) for i in range(2)]), dict(potentials=TaskManagerTests._default_potentials, distance=4, log_level=2, basin_kwargs=dict(niter=5), save_all=True, save_count=3))], preprocessors=[_custom_processor]) with open("data/testdb_check.in", mode="wb") as f: pass task_manager.work("data/testdb_preprocessor.db") with open("data/testdb_check.in", mode="rb") as f: self.assertEqual(len(f.read()), 4)
def test_default(self): # Make sure system runs with no crashes task_manager = automation.TaskManager([ (dict(stoichiometry=(1, 2), place_max=4, sample_count=4, log_level=2, sample_groups=[ WallpaperGroup(number=i + 1) for i in range(2) ]), dict(potentials=TaskManagerTests._default_potentials, distance=4, log_level=2, basin_kwargs=dict(niter=5), save_all=True, save_count=3)) ]) task_manager.work("data/testdb_default.db") # Make sure all processing did complete db = automation.ResultsDatabase("data/testdb_default.db") self.assertEqual(len(list(db.cells_in)), 4) self.assertEqual(len(list(db.cells_out)), 12)