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])

Base class for all Widgets

class shyft.dashboard.base.app.AppBase(thread_pool=None, app_kwargs=None)[source]

Bases: ABC

This is the base class for any Dashboard app

Init of base app

Parameters:
  • thread_pool (ThreadPoolExecutor | None) – Optional thread pool used for async calls within the app

  • app_kwargs (Dict[str, Any] | None) – Optional keyword arguments provided to the app through the start_bokeh_apps methods

__init__(thread_pool=None, app_kwargs=None)[source]

Init of base app

Parameters:
  • thread_pool (ThreadPoolExecutor | None) – Optional thread pool used for async calls within the app

  • app_kwargs (Dict[str, Any] | None) – 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

abstractmethod get_layout(doc, logger=None)[source]

This function returns the full page layout for the app

Parameters:
Return type:

LayoutDOM

shyft.dashboard.base.app.make_document(doc, get_app_layout, log_level, enable_logger_box=False)[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 (Document) – bokeh document provided by the bokeh server

  • get_app_layout (Callable[[Document], LayoutDOM]) – layout callback should return the entire layout of the app

  • log_level (int) – log level to initialize the logger box widget

  • enable_logger_box (bool) – 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.

Return type:

None

shyft.dashboard.base.app.start_bokeh_apps(apps, show=False, port=5006, log_level=40, async_on=True, async_max_worker=12, show_logger_box=False, server_kwargs=None, app_kwargs=None)[source]

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

Parameters:
  • apps (List[Type[AppBase]]) – List of AppBase classes

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

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

  • log_level – Logging level in the console

  • async_on (bool) – use async data loading

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

  • show_logger_box (bool) – enable in-app logger

  • server_kwargs (Dict[str, Any] | None) – keyword arguments for the Bokeh / tornado server

  • app_kwargs (List[Dict[str, Any]] | Dict[str, Any] | None) – 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

Return type:

None

shyft.dashboard.base.app.update_value_factory(layout_dom_object, callback_attr, logger=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 (str) – attribute to update

  • logger (Logger | None) – 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

Base class for all Widgets

Parameters:

logger – Optional logger, e.g composable_logger_box

__init__(logger=None)[source]

Base class for all Widgets

Parameters:

logger – Optional logger, e.g composable_logger_box

Return type:

None

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)[source]
Parameters:

callback_attr (str)

Return type:

Callable[[Any], None]