def run_analyzers(args: argparse.Namespace): """ Launch the service with the specified analyzers. Blocks until a KeyboardInterrupt. :param args: Parsed command line arguments. :return: None """ log = logging.getLogger("run") model_repository = create_model_repo_from_args(args) log.info("Created %s", model_repository) if args.request_server == "auto": data_request_address = "%s:10301" % args.server.split(":")[0] else: data_request_address = args.request_server data_service = DataService(data_request_address) log.info("Created %s", data_service) sys.path.append(os.getcwd()) manager = AnalyzerManager( analyzers=[ importlib.import_module(a).analyzer_class for a in args.analyzer ], model_repository=model_repository, data_service=data_service, ) sys.path = sys.path[:-1] log.info("Created %s", manager) listener = EventListener(address=args.server, handlers=manager, n_workers=args.workers) log.info("Created %s", listener) listener.start() log.info("Listening %s", args.server) listener.block() model_repository.shutdown() data_service.shutdown()
def test_push(self): listener = EventListener("localhost:%d" % self.port, self.handlers).start() server.run("push", "4984b98b0e2375e9372fbab4eb4c9cd8f0c289c6", "5833b4ba94154cf1ed07f37c32928c7b4411b36b", self.port) self.assertIsInstance(self.handlers.request, PushEvent) del listener
def test_push(self): listener = EventListener("localhost:%d" % self.port, self.handlers).start() self.lookout_sdk.push(self.COMMIT_FROM, self.COMMIT_TO, self.port, git_dir=os.getenv("LOOKOUT_SDK_ML_TESTS_GIT_DIR", ".")) self.assertIsInstance(self.handlers.request, PushEvent) del listener
def __enter__(self) -> "AnalyzerContextManager": self.manager = AnalyzerManager( analyzers=self.analyzer, model_repository=self.model_repository, data_service=self.data_service, ) self.listener = EventListener(address="0.0.0.0:%d" % self.port, handlers=self.manager, n_workers=self.args.workers) self.listener.start() return self
def setUp(self): self.setUpEvent = threading.Event() self.tearDownEvent = threading.Event() self.port = server.find_port() self.listener = EventListener("localhost:%d" % self.port, self).start() self.server_thread = threading.Thread(target=self.run_data_service) self.server_thread.start() self.data_service = DataService("localhost:10301") self.url = "file://" + str(Path(lookout.__file__).parent.absolute()) self.ref = "refs/heads/master" self.setUpEvent.wait()
def __enter__(self) -> "AnalyzerContextManager": self.model_repository = create_model_repo_from_args( self._sql_alchemy_model_args) if self.init: self.model_repository.init() self.data_service = DataService(self.data_request_address) self.manager = AnalyzerManager(analyzers=[self.analyzer], model_repository=self.model_repository, data_service=self.data_service) self.listener = EventListener(address="0.0.0.0:%d" % self.port, handlers=self.manager, n_workers=1) self.listener.start() return self
def setUp(self): self.setUpEvent = threading.Event() self.tearDownEvent = threading.Event() self.port = find_port() self.lookout_sdk = LookoutSDK() self.listener = EventListener("localhost:%d" % self.port, self).start() self.server_thread = threading.Thread(target=self.run_data_service) self.server_thread.start() self.data_service = DataService("localhost:10301") self.url = "file://" + str( Path(lookout.core.__file__).parent.parent.absolute()) self.ref = "refs/heads/master" self.setUpWasSuccessful = True self.setUpEvent.wait() if not self.setUpWasSuccessful: self.fail("failed to setUp()")
def __enter__(self) -> "AnalyzerContextManager": """ Create the context and run the events listener. """ self.model_repository = create_model_repo_from_args(self._sql_alchemy_model_args) if self.init: self.model_repository.init() self.data_service = DataService(self.data_request_address) self.manager = AnalyzerManager(analyzers=[self.analyzer], model_repository=self.model_repository, data_service=self.data_service) if not check_port_free(self._port): self._port = find_port() self.listener = EventListener(address="0.0.0.0:%d" % self._port, handlers=self.manager, n_workers=1) self.listener.start() self._lookout_sdk = LookoutSDK() return self