コード例 #1
0
def _restart_bblfshd(first_run: bool=False) -> str:
    log = logging.getLogger(bblfsh_name)
    port = find_port()
    log.info("Restarting bblfshd")
    if not first_run:
        _stop_bblfshd()
    docker_client.containers.run(
        "bblfsh/bblfshd:v2.11.0", detach=True, auto_remove=True, privileged=True,
        name=bblfsh_name, ports={9432: port})
    log.info("Installing javascript driver")
    bblfsh = docker_client.containers.get("expected_vnodes_bblfshd")
    bblfsh.exec_run("bblfshctl driver install javascript docker://bblfsh/javascript-driver:v2.7.1")
    address = "localhost:%d" % port
    log.info("bblfshd available at %s" % address)
    return address
コード例 #2
0
 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()")
コード例 #3
0
 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
コード例 #4
0
    def __init__(self, analyzer: Type[Analyzer], db: str, fs: str,
                 init: bool = True, data_request_address: str = "localhost:10301"):
        """
        Initialization.

        :param db: path to an SQLite database with model metadata.
        :param fs: location where to store the trained model.
        :param analyzer: analyzer class to use.
        :param init: Value indicating whether to run the destructive database initialization \
                     or not. If you want to reuse an existing database set False.
        :param data_request_address: DataService GRPC endpoint to use.
        """
        self.analyzer = analyzer
        self.init = init
        self._port = find_port()
        self.data_request_address = data_request_address
        self._sql_alchemy_model_args = Namespace(
            db="sqlite:///%s" % db,
            fs=fs,
            cache_size="1G",
            cache_ttl="6h",
            db_kwargs={},
        )
        self._lookout_sdk = None
コード例 #5
0
 def setUp(self):
     self.handlers = Handlers()
     self.port = find_port()
     self.lookout_sdk = LookoutSDK()