def main(predictor: ADWINPredictor): engine = create_engine(os.environ["KB_CONNECTION_STRING"]) connection = Connection(engine, bulk_size=1000, bulk_time=1) name = os.environ["ANALYSER_NAME"] with open(f"/tmp/{name}_results.csv", "w") as f: # nosec predictor = predictor(connection, f) analyser = Analyser( # nosec f"{name}@localhost", os.environ["ANALYSER_PASSWORD"], predictor, connection, [f"monitor_{name.split('_')[1]}@localhost"]) logger.info("Waiting Ejabberd...") time.sleep(30) logger.info("Starting analyser...") analyser.start() logger.info("Analyser alive") while True: try: time.sleep(1) except KeyboardInterrupt: break analyser.stop() logger.info("Analyser stopped")
async def setUp(self): self.monitor = Monitor("monitor@localhost", "passw0rd", "data0") self.engine = create_engine("sqlite:///database.sql") self.breaker = CircuitBreaker() self.cache_to_save = 10 self.connection = Connection(self.engine, self.cache_to_save, 100000, self.breaker) self.analyser_predictor = HelperAnalyserPredictor(self.connection) self.sink = HelperSink(self.breaker) self.sink.external.reset_mock() self.analyser = Analyser("analyser@localhost", "passw0rd", self.analyser_predictor, self.connection, ["monitor@localhost"]) self.executor = Executor("executor@localhost", "passw0rd", self.sink) self.planner_predictor = HelperPlannerPredictor(self.connection) self.planner = Planner("planner@localhost", "passw0rd", self.planner_predictor, ["executor@localhost"]) self.monitor.start() self.executor.start() await asyncio.sleep(2) self.analyser.start() self.planner.start() await asyncio.sleep(2)
async def setUp(self): self.monitor = Monitor("monitor@localhost", "passw0rd", "data0") self.engine = create_engine("sqlite:///database.sql") self.breaker = CircuitBreaker() self.connection = Connection(self.engine, 10, 10000, self.breaker) self.predictor = HelperAnalyserPredictor(self.connection) self.analyser = Analyser("analyser@localhost", "passw0rd", self.predictor, self.connection, ["monitor@localhost"]) self.monitor.start() await asyncio.sleep(2) self.analyser.start() await asyncio.sleep(1)
async def setUp(self): if not path.exists("test/resources/database.dump"): raise IOError("database not exists") self.engine = create_engine("sqlite:///test/resources/database.dump") self.breaker = CircuitBreaker() self.connection = Connection(self.engine, 10, 10000, self.breaker) self.sink = HelperSink(self.breaker) self.sink.external.reset_mock() self.executor = Executor("executor@localhost", "passw0rd", self.sink) self.planner_predictor = HelperPlannerPredictor(self.connection) self.cache_number = 3 self.planner = Planner("planner@localhost", "passw0rd", self.planner_predictor, ["executor@localhost"], self.cache_number)
self.detectors[identifier].delta = delta logger.debug(f"delta up to {delta} on {identifier}" f" with rate {drift_rate}") self.last_rate[identifier] = drift_rate async def predict(self, X: PredictionData) -> bool: detector = self.detectors.get(X.identifier, ADWIN(self.delta)) self.detectors[X.identifier] = detector detector.add_element(X.data["sensor"]) return detector.detected_change() engine = create_engine(os.environ["KB_CONNECTION_STRING"]) connection = Connection(engine, bulk_size=1000, bulk_time=1) predictor = ADWINPredictor(connection) my_number = os.environ["MY_NUMBER"] analyser = Analyser( # nosec f"analyser_{my_number}@localhost", os.environ["ANALYSER_PASSWORD"], predictor, connection, [f"monitor_{my_number}@localhost"]) logger.info("Waiting Ejabberd...") time.sleep(30) logger.info("Starting analyser...") analyser.start() logger.info("Analyser alive") while True:
def setUp(self): self.engine = Mock() self.connection = Connection(self.engine, 10, 0.9)