shyft.dashboard.base.app

This module contains classes and methods to define and serve bokeh apps for all projects in the same way

Functions

make_document(doc, get_app_layout, log_level)

This function creates a specific document for a user request and fills in the layout of the app provided by the layout callback.

start_bokeh_apps(apps[, show, port, ...])

This function starts a bokeh serve with the apps provided to the function

update_value_factory(layout_dom_object, ...)

Factory method to create update functions for attributes bokeh layout dom objects, without triggering the connected callback functions.

Classes

AppBase([thread_pool, app_kwargs])

This is the base class for any Dashboard app

Widget([logger])

class shyft.dashboard.base.app.AppBase(thread_pool: ThreadPoolExecutor | None = None, app_kwargs: Dict[str, Any] | None = None)[source]

Bases: ABC

This is the base class for any Dashboard app

__init__(thread_pool: ThreadPoolExecutor | None = None, app_kwargs: Dict[str, Any] | None = None)[source]

Init of base app

Parameters:
  • thread_pool – Optional thread pool used for async calls within the app

  • app_kwargs – Optional keyword arguments provided to the app through the start_bokeh_apps methods

abstract property name: str

This property returns the name of the app

abstract get_layout(doc: Document, logger: LoggerBox | None = None) LayoutDOM[source]

This function returns the full page layout for the app

shyft.dashboard.base.app.make_document(doc: Document, get_app_layout: Callable[[Document], LayoutDOM], log_level: int, enable_logger_box: bool = False) None[source]

This function creates a specific document for a user request and fills in the layout of the app provided by the layout callback. (The layout callback should be the implemented method BaseApp.get_layout of the BaseApp)

Parameters:
  • doc – bokeh document provided by the bokeh server

  • get_app_layout – layout callback should return the entire layout of the app

  • log_level – log level to initialize the logger box widget

  • enable_logger_box – if enabled a logger box widget is added to the app, which shows the log msg from all app widgets, this requires that logger in the BaseApp.get_layout function is passed to the widgets.

shyft.dashboard.base.app.start_bokeh_apps(apps: List[Type[AppBase]], show: bool = False, port: int = 5006, log_level=40, async_on: bool = True, async_max_worker: int = 12, show_logger_box: bool = False, server_kwargs: Dict[str, Any] | None = None, app_kwargs: List[Dict[str, Any]] | Dict[str, Any] | None = None) None[source]

This function starts a bokeh serve with the apps provided to the function

Parameters:
  • apps – List of AppBase classes

  • show – if True a browser with all apps will be opened

  • port – port where on which the apps are loaded ‘localhost:port’

  • log_level – Logging level in the console

  • async_on – use async data loading

  • async_max_worker – number of workers for thread pool doing the async data loading

  • show_logger_box – enable in-app logger

  • server_kwargs – keyword arguments for the Bokeh / tornado server

  • app_kwargs – list of dictionaries of additional keyword arguments for the apps, if a single dictionary is passed, a list is created with the same length as the number of apps

shyft.dashboard.base.app.update_value_factory(layout_dom_object, callback_attr: str, logger: Logger | None = None) Callable[[Any], None][source]

Factory method to create update functions for attributes bokeh layout dom objects, without triggering the connected callback functions.

Parameters:
  • layout_dom_object – bokeh object

  • callback_attr – attribute to update

  • logger – logger

Return type:

Callable which takes one argument to update the bokeh object attribute callback_attr

class shyft.dashboard.base.app.Widget(logger=None)[source]

Bases: object

__init__(logger=None) None[source]

Base class for all Widgets

Parameters:

logger – Optional logger, e.g composable_logger_box

abstract property layout: LayoutDOM
abstract property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

update_value_factory(layout_dom_object, callback_attr: str) Callable[[Any], None][source]