def test_training_infer(config): """Test anomaly detection training on public dataset.""" model_adapter = SomModelAdapter( SomStorageAdapter(config=config, feedback_strategy=None)) tc_train = SomTrainCommand(node_map=2, model_adapter=model_adapter, recreate_model=True) result, dist = tc_train.execute() assert result == 0 model_adapter = SomModelAdapter( SomStorageAdapter(config=config, feedback_strategy=None)) tc_infer = SomInferCommand(model_adapter=model_adapter, sleep=False) result = tc_infer.execute() assert result == 0
def infer(self): """Run inference of model. :return: None """ inference = SomInferCommand(model_adapter=self.__model_adapter) self.tasks.add_steps(inference) self.start_job()
def run(self, single_run=False): """Abstraction around model adapter run method.""" break_out = False train = SomTrainCommand(model_adapter=self.__model_adapter) infer = SomInferCommand(model_adapter=self.__model_adapter) self.mgr.add_steps(train) self.mgr.add_steps(infer) while break_out is False: self.mgr.execute_steps() print("log::facade::run") time.sleep(5) break_out = single_run
def run(self, single_run=False): """Run train and inference and main event loop. :param single_run: if this is set to TRUE then we exit loop after first iteration. :return: None """ exit = False while exit is False: try: train = SomTrainCommand(model_adapter=self.__model_adapter) infer = SomInferCommand(model_adapter=self.__model_adapter) self.tasks.add_steps(train) self.tasks.add_steps(infer) self.start_job() logging.info("Job ran succesfully") except EmptyDataSetException as e: logging.debug(e) finally: time.sleep(5) exit = single_run
def infer(self): """Abstraction around model adapter inference method.""" tc_infer = SomInferCommand(model_adapter=self.__model_adapter) self.mgr.add_steps(tc_infer) self.mgr.execute_steps()