當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。