def setup(self): param_def = { "x": MinMaxNumericParamDef(0, 1) } self.experiment = Experiment(name="test_optimizer_experiment", parameter_definitions=param_def) out_queue = Queue() in_queue = Queue() self.backend = QueueBackend(RandomSearch, self.experiment, out_queue, in_queue)
class TestQueueBackend(object): backend = None experiment = None def setup(self): param_def = { "x": MinMaxNumericParamDef(0, 1) } self.experiment = Experiment(name="test_optimizer_experiment", parameter_definitions=param_def) out_queue = Queue() in_queue = Queue() self.backend = QueueBackend(RandomSearch, self.experiment, out_queue, in_queue) def test_run(self): self.backend._in_queue.put("exit") self.backend.run() def test_check_update(self): self.backend._check_update() self.backend._in_queue.put("exit") time.sleep(0.1) self.backend._check_update() time.sleep(0.1) self.backend._check_update() self.backend._in_queue.put(self.experiment) time.sleep(0.1) self.backend._check_update() def test_check_generation(self): self.backend._check_generation()