bokeh.validation Package

To create a Bokeh visualization, the central task is to assemble a collection model objects from bokeh.plotting into a graph that represents the scene that should be created in the client. It is possible to to this “by hand”, using the model objects directly. However, to make this process easier, Bokeh provides higher level interfaces such as bokeh.plotting and bokeh.plotting for users. These interfaces automate common “assembly” steps, to ensure a Bokeh object graph is created in a consistent, predictable way. However, regardless of what interface is used, it is possible to put Bokeh models together in ways that are incomplete, or that do not make sense in some way.

To assist with diagnosing potential problems, Bokeh performs a validation step when outputting a visualization for display. These errors and warnings are outlined below.

bokeh.validation.errors

Define standard error codes and messages for Bokeh validation checks.

1000 : COLUMN_LENGTHS
A ColumnDataSource has columns whose lengths are not all the same.
1001 : BAD_COLUMN_NAME
A glyph has a property set to a field name that does not correspond to any column in the GlyphRenderer‘s data source.
1002 : MISSING_GLYPH
A GlyphRenderer has no glyph configured.
1003 : NO_SOURCE_FOR_GLYPH
A GlyphRenderer has no data source configured.
1004 : REQUIRED_RANGE
A Plot is missing one or more required default ranges (will result in blank plot).
9999 : EXT
Indicates that a custom error check has failed.

bokeh.validation.warnings

Define standard warning codes and messages for Bokeh validation checks.

1000 : MISSING_RENDERERS
A Plot object has no renderers configured (will result in a blank plot).
1001 : NO_GLYPH_RENDERERS
A Plot object has no glyph renderers (will result in an empty plot frame).
1002 : EMPTY_LAYOUT
A layout model has no children (will result in a blank layout).
1003 : MALFORMED_CATEGORY_LABEL
Category labels cannot contain colons (will result in a blank layout).
9999 : EXT
Indicates that a custom warning check has failed.

bokeh.validation.decorators

error(code_or_name)

Mark a validator method for a Bokeh error condition

Parameters:code_or_name (int or str) – a code from bokeh.validation.errors or a string label for a custom check
Returns:decorator for Bokeh model methods
Return type:callable

Examples:

The first example uses a numeric code for a standard error provided in bokeh.validation.errors. This usage is primarily of interest to Bokeh core developers.

from bokeh.validation.errors import REQUIRED_RANGES

@error(REQUIRED_RANGES)
def _check_no_glyph_renderers(self):

The second example shows how a custom warning check can be implemented by passing an arbitrary string label to the decorator. This usage is primarily of interest to anyone extending Bokeh with their own custom models.

@error("MY_CUSTOM_WARNING")
def _check_my_custom_warning(self):
warning(code_or_name)

Mark a validator method for a Bokeh error condition

Parameters:code_or_name (int or str) – a code from bokeh.validation.errors or a string label for a custom check
Returns:decorator for Bokeh model methods
Return type:callable

Examples:

The first example uses a numeric code for a standard warning provided in bokeh.validation.warnings. This usage is primarily of interest to Bokeh core developers.

from bokeh.validation.warnings import NO_GLYPH_RENDERERS

@warning(NO_GLYPH_RENDERERS)
def _check_no_glyph_renderers(self):

The second example shows how a custom warning check can be implemented by passing an arbitrary string label to the decorator. This usage is primarily of interest to anyone extending Bokeh with their own custom models.

@warning("MY_CUSTOM_WARNING")
def _check_my_custom_warning(self):

bokeh.validation.exceptions

Provide exception types for Bokeh object graph validation.

exception ValidationError

Failed Bokeh validation check