bokeh.document.util

Provide ancillary utility functions useful for manipulating Bokeh documents.

compute_patch_between_json(from_json, to_json)[source]

Compute a JSON diff between a two Bokeh document states.

Note

This function is used to send changes that happened between calls to show() and push_notebook() and will be removed when a better implementation based on the Bokeh protocol is available.

Parameters:
  • from_json (JSON) – JSON representing a “starting” Bokeh document state
  • to_json (JSON) – JSON representing a “final” Bokeh document state
Returns
JSON
initialize_references_json(references_json, references, setter=None)[source]

Given a JSON representation of the models in a graph, and new model objects, set the properties on the models from the JSON

Parameters:
  • references_json (JSON) – JSON specifying attributes and values to initialize new model objects with.
  • references (dict[str, Model]) –

    A dictionary mapping model IDs to newly created (but not yet initialized) Bokeh models.

    This is an “out” parameter. The values it contains will be modified in-place.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps. (default: None)

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

instantiate_references_json(references_json)[source]

Given a JSON representation of all the models in a graph, return a dict of new model objects.

Parameters:references_json (JSON) – JSON specifying new Bokeh models to create
Returns:dict[str, Model]
references_json(references)[source]

Given a list of all models in a graph, return JSON representing them and their properties.

Parameters:references (seq[Model]) – A list of models to convert to JSON
Returns:list