本文整理匯總了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()
示例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
示例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
示例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
)
示例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"
示例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
示例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")