当前位置: 首页>>代码示例>>Python>>正文


Python application.Application方法代码示例

本文整理汇总了Python中bokeh.application.Application方法的典型用法代码示例。如果您正苦于以下问题:Python application.Application方法的具体用法?Python application.Application怎么用?Python application.Application使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.application的用法示例。


在下文中一共展示了application.Application方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run_server

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def _run_server(fnc_make_document, iplot=True, notebook_url="localhost:8889", port=80, ioloop=None):
        """Runs a Bokeh webserver application. Documents will be created using fnc_make_document"""
        handler = FunctionHandler(fnc_make_document)
        app = Application(handler)

        if iplot and 'ipykernel' in sys.modules:
            show(app, notebook_url=notebook_url)
        else:
            apps = {'/': app}

            print(f"Open your browser here: http://localhost:{port}")
            server = Server(apps, port=port, io_loop=ioloop)
            if ioloop is None:
                server.run_until_shutdown()
            else:
                server.start()
                ioloop.start() 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:19,代码来源:bokeh_webapp.py

示例2: _launcher

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def _launcher(self, obj, threaded=False, io_loop=None):
        if io_loop:
            io_loop.make_current()
        launched = []
        def modify_doc(doc):
            bokeh_renderer(obj, doc=doc)
            launched.append(True)
        handler = FunctionHandler(modify_doc)
        app = Application(handler)
        server = Server({'/': app}, port=0, io_loop=io_loop)
        server.start()
        self._port = server.port
        self._server = server
        if threaded:
            server.io_loop.add_callback(self._loaded.set)
            thread = threading.current_thread()
            state._thread_id = thread.ident if thread else None
            io_loop.start()
        else:
            url = "http://localhost:" + str(server.port) + "/"
            session = pull_session(session_id='Test', url=url, io_loop=server.io_loop)
            self.assertTrue(len(launched)==1)
            return session, server
        return None, server 
开发者ID:holoviz,项目名称:holoviews,代码行数:26,代码来源:testserver.py

示例3: _try_start_web_server

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def _try_start_web_server(self):
        static_path = os.path.join(os.path.dirname(__file__), 'static')

        handlers = dict()
        for p, h in _bokeh_apps.items():
            handlers[p] = Application(FunctionHandler(functools.partial(h, self._scheduler_ip)))

        handler_kwargs = {'scheduler_ip': self._scheduler_ip}
        extra_patterns = [
            ('/static/(.*)', BokehStaticFileHandler, {'path': static_path})
        ]
        for p, h in _web_handlers.items():
            extra_patterns.append((p, h, handler_kwargs))

        retrial = 5
        while retrial:
            try:
                if self._port is None:
                    use_port = get_next_port()
                else:
                    use_port = self._port

                self._server = Server(
                    handlers, allow_websocket_origin=['*'],
                    address=self._host, port=use_port,
                    extra_patterns=extra_patterns,
                    http_server_kwargs={'max_buffer_size': 2 ** 32},
                )
                self._server.start()
                self._port = use_port
                logger.info('Mars UI started at %s:%d', self._host, self._port)
                break
            except OSError:
                if self._port is not None:
                    raise
                retrial -= 1
                if retrial == 0:
                    raise 
开发者ID:mars-project,项目名称:mars,代码行数:40,代码来源:server.py

示例4: run_dashboard

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def run_dashboard(database_paths, no_browser=None, port=None):
    """Start the dashboard pertaining to one or several databases.

    Args:
        database_paths (str or pathlib.Path or list): Path(s) to an sqlite3 file which
            typically has the file extension ``.db``. See :ref:`logging` for details.
        no_browser (bool, optional): If True the dashboard does not open in the browser.
        port (int, optional): Port where to display the dashboard.

    """
    database_name_to_path, no_browser, port = _process_dashboard_args(
        database_paths=database_paths, no_browser=no_browser, port=port
    )

    session_data = _create_session_data(database_name_to_path)

    master_app_func = partial(
        master_app,
        database_name_to_path=database_name_to_path,
        session_data=session_data,
    )
    apps = {"/": Application(FunctionHandler(master_app_func))}

    for database_name in database_name_to_path:
        partialed = partial(
            monitoring_app,
            database_name=database_name,
            session_data=session_data[database_name],
        )
        apps[f"/{database_name}"] = Application(FunctionHandler(partialed))

    if len(database_name_to_path) == 1:
        path_to_open = f"/{list(database_name_to_path)[0]}"
    else:
        path_to_open = "/"

    _start_server(
        apps=apps, port=port, no_browser=no_browser, path_to_open=path_to_open
    ) 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:41,代码来源:run_dashboard.py

示例5: assemble_bokeh_doc

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def assemble_bokeh_doc(self, widgets, plots, plot_update, theme):
        def main_doc(doc):
            doc.add_root(widgets)  # add the widgets to the document
            doc.add_root(plots)  # Add four plots to document, using the gridplot method of arranging them
            doc.add_periodic_callback(plot_update, 150)  # Add a periodic callback to be run every x milliseconds
            doc.theme = theme
 
        # Create bokeh app
        self.bokeh_app = Application(FunctionHandler(main_doc)) # Application is "a factory for Document instances" and FunctionHandler "runs a function which modifies a document" 
开发者ID:pysdr,项目名称:pysdr,代码行数:11,代码来源:pysdr_app.py

示例6: create_bokeh_server

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def create_bokeh_server(self):
        self.io_loop = IOLoop.current() # creates an IOLoop for the current thread
        # Create the Bokeh server, which "instantiates Application instances as clients connect".  We tell it the bokeh app and the ioloop to use
        server = Server({'/bkapp': self.bokeh_app}, io_loop=self.io_loop, allow_websocket_origin=["localhost:8080"]) 
        server.start() # Start the Bokeh Server and its background tasks. non-blocking and does not affect the state of the IOLoop 
开发者ID:pysdr,项目名称:pysdr,代码行数:7,代码来源:pysdr_app.py

示例7: start_bokeh

# 需要导入模块: from bokeh import application [as 别名]
# 或者: from bokeh.application import Application [as 别名]
def start_bokeh(self):
        try:
            self.note("Starting Bokeh Serve")
            # Need to create the device document here
            devHandler = DevicesTableHandler(self)
            dev_app = Application(devHandler)
            trendHandler = DynamicPlotHandler(self)
            notesHandler = NotesTableHandler(self)
            self.trend_app = Application(trendHandler)
            self.notes_app = Application(notesHandler)
            self.bk_worker = Bokeh_Worker(
                dev_app, self.trend_app, self.notes_app, self.localIPAddr.addrTuple[0]
            )
            self.FlaskServer = FlaskServer(
                network=self, port=self.flask_port, ip=self.localIPAddr.addrTuple[0]
            )
            self.bk_worker.start()
            self.bokehserver = True
            time.sleep(1)
            try:
                logging.getLogger().handlers[0].setLevel(logging.CRITICAL)
            except IndexError:
                # Possibly in Jupyter Notebook... root logger not defined
                pass
            update_log_level("default", log_this=False)
            self._log.info(
                "Server started : http://{}:{}".format(
                    self.localIPAddr.addrTuple[0], self.flask_port
                )
            )

        except OSError as error:
            self.bokehserver = False
            self._log.error(
                "[bokeh serve] required for trending (controller.chart) features"
            )
            self._log.error(error)

        except RuntimeError as rterror:
            self.bokehserver = False
            self._log.warning("Server already running")

        except BokehServerCantStart:
            self.bokehserver = False
            self._log.error("No Bokeh Server - controller.chart not available") 
开发者ID:ChristianTremblay,项目名称:BAC0,代码行数:47,代码来源:Complete.py


注:本文中的bokeh.application.Application方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。