Ejemplo n.º 1
0
    def run(self):
        application = self._create_tornado_web_app()

        init_model_evaluator(self.settings, self.tabpy_state,
                             self.python_service)

        protocol = self.settings[SettingsParameters.TransferProtocol]
        if protocol == 'http':
            application.listen(self.settings[SettingsParameters.Port])
        elif protocol == 'https':
            application.listen(
                self.settings[SettingsParameters.Port],
                ssl_options={
                    'certfile':
                    self.settings[SettingsParameters.CertificateFile],
                    'keyfile': self.settings[SettingsParameters.KeyFile]
                })
        else:
            msg = f'Unsupported transfer protocol {protocol}.'
            logger.critical(msg)
            raise RuntimeError(msg)

        logger.info('Web service listening on port '
                    f'{str(self.settings[SettingsParameters.Port])}')
        tornado.ioloop.IOLoop.instance().start()
Ejemplo n.º 2
0
def main():
    settings, subdirectory = get_config(config_file)

    logger.info('Initializing TabPy...')
    tornado.ioloop.IOLoop.instance().run_sync(lambda: init_ps_server(settings))
    logger.info('Done initializing TabPy.')

    executor = concurrent.futures.ThreadPoolExecutor(
        max_workers=multiprocessing.cpu_count())

    # initialize Tornado application
    application = tornado.web.Application(
        [
            # skip MainHandler to use StaticFileHandler .* page requests and
            # default to index.html
            # (r"/", MainHandler),
            (subdirectory + r'/query/([^/]+)', QueryPlaneHandler),
            (subdirectory + r'/status', StatusHandler),
            (subdirectory + r'/info', ServiceInfoHandler),
            (subdirectory + r'/endpoints', EndpointsHandler),
            (subdirectory + r'/endpoints/([^/]+)?', EndpointHandler),
            (subdirectory + r'/evaluate', EvaluationPlaneHandler,
             dict(executor=executor)),
            (subdirectory + r'/configurations/endpoint_upload_destination',
             UploadDestinationHandler),
            (subdirectory + r'/(.*)', tornado.web.StaticFileHandler,
             dict(path=settings['static_path'],
                  default_filename="index.html")),
        ],
        debug=False,
        **settings)

    settings = application.settings

    init_model_evaluator(settings)

    if settings['transfer_protocol'] == 'http':
        application.listen(settings['port'], address=settings['bind_ip'])
    elif settings['transfer_protocol'] == 'https':
        application.listen(settings['port'],
                           address=settings['bind_ip'],
                           ssl_options={
                               'certfile': settings['certificate_file'],
                               'keyfile': settings['key_file']
                           })
    else:
        raise RuntimeError('Unsupported transfer protocol.')

    logger.info('Web service listening on {} port {}'.format(
        settings['bind_ip'], str(settings['port'])))
    tornado.ioloop.IOLoop.instance().start()
Ejemplo n.º 3
0
def main():
    model = "python " + os.path.dirname(
        os.path.realpath(__file__)) + '/prod_fraud_model.py'

    p1 = subprocess.Popen(model, shell=True, stdout=subprocess.PIPE)

    settings, subdirectory = get_config()

    print('Initializing TabPy...')
    tornado.ioloop.IOLoop.instance().run_sync(lambda: init_ps_server(settings))
    print('Done initializing TabPy.')

    executor = concurrent.futures.ThreadPoolExecutor(
        max_workers=multiprocessing.cpu_count())

    # initialize Tornado application
    application = tornado.web.Application(
        [
            # skip MainHandler to use StaticFileHandler .* page requests and
            # default to index.html
            # (r"/", MainHandler),
            (subdirectory + r'/query/([^/]+)', QueryPlaneHandler),
            (subdirectory + r'/status', StatusHandler),
            (subdirectory + r'/info', ServiceInfoHandler),
            (subdirectory + r'/endpoints', EndpointsHandler),
            (subdirectory + r'/endpoints/([^/]+)?', EndpointHandler),
            (subdirectory + r'/evaluate', EvaluationPlaneHandler,
             dict(executor=executor)),
            (subdirectory + r'/configurations/endpoint_upload_destination',
             UploadDestinationHandler),
            (subdirectory + r'/(.*)', tornado.web.StaticFileHandler,
             dict(path=settings['static_path'],
                  default_filename="index.html")),
        ],
        debug=False,
        **settings)

    settings = application.settings

    init_model_evaluator(settings)

    application.listen(settings['port'], address=settings['bind_ip'])
    print('Web service listening on {} port {}'.format(settings['bind_ip'],
                                                       str(settings['port'])))
    tornado.ioloop.IOLoop.instance().start()
Ejemplo n.º 4
0
    def run(self):
        application = self._create_tornado_web_app()

        init_model_evaluator(
            self.settings,
            self.tabpy_state,
            self.python_service)

        if self.settings['transfer_protocol'] == 'http':
            application.listen(self.settings['port'])
        elif self.settings['transfer_protocol'] == 'https':
            application.listen(self.settings['port'],
                               ssl_options={
                'certfile': self.settings['certificate_file'],
                'keyfile': self.settings['key_file']
            })
        else:
            log_and_raise('Unsupported transfer protocol.', RuntimeError)

        logger.info('Web service listening on port {}'.format(
            str(self.settings['port'])))
        tornado.ioloop.IOLoop.instance().start()