bokeh.settings

Control global configuration options with environment variables. A global settings object that other parts of Bokeh can refer to.

Setting values are always looked up in the following prescribed order:

immediately supplied values

These are values that are passed to the setting:

settings.minified(minified_val)

If minified_val is not None, then it will be returned, as-is. Otherwise, if None is passed, then the setting will continute to look down the search order for a value. This is useful for passing optional function paramters that are None by default. If the parameter is passed to the function, then it will take precedence.

previously user-set values

If the value is set explicity in code:

settings.minified = False

Then this value will take precedence over other sources. Applications may use this ability to set values supplied on the command line, so that they take precedence over environment variables.

user-specified config override file

Values from a YAML configuration file that is explicitly loaded:

settings.load_config("/path/to/bokeh.yaml)

Any values from bokeh.yaml will take precedence over the sources below. Applications may offer command line arguments to load such a file. e.g. bokeh serve --use-config myconf.yaml

environment variable

Values found in the associated environment variables:

BOKEH_MINIFIED=no bokeh serve app.py
local user config file

Bokeh will look for a YAML configuration file in the current user’s home directory ${HOME}/.bokeh/bokeh.yaml.

global system configuration (not yet implemented)

Future support is planned to load Bokeh settings from global system configurations.

implicit defaults

These are default values defined by the setting declarations. There are regular defaults, as well as “dev” defaults that are used when the environment variable BOKEH_DEV=yes is set.

If no value is obtained after searching all of these locations, then a RuntimeError will be raised.

Defined Settings

Settings are accessible on the bokeh.settings.settings instance, via accessor methods. For instance:

settings.minified()

Bokeh provides the following defined settings:

allowed_ws_origin
  • Type: List[String]

  • Env var: BOKEH_ALLOW_WS_ORIGIN

  • Default: []

  • Dev Default: (Unset)

A comma-separated list of allowed websocket origins for Bokeh server applications.

browser
  • Type: String

  • Env var: BOKEH_BROWSER

  • Default: None

  • Dev Default: ‘none’

The default browser that Bokeh should use to show documents with.

Valid values are any of the browser names understood by the python standard library webbrowser module.

docs_cdn
  • Type: String

  • Env var: BOKEH_DOCS_CDN

  • Default: None

  • Dev Default: (Unset)

The version of BokehJS that should be use for loading CDN resources when building the docs.

To build and display the docs using a locally built BokehJS, use local. For example:

BOKEH_DOCS_CDN=local make clean serve

Will build a fresh copy of the docs using the locally built BokehJS and open a new browser tab to view them.

Otherwise, the value is interpreted a version for CDN. For example:

BOKEH_DOCS_CDN=1.4.0rc1 make clean

will build docs that use BokehJS version 1.4.0rc1 from CDN.

docs_version
  • Type: String

  • Env var: BOKEH_DOCS_CDN

  • Default: None

  • Dev Default: (Unset)

The Bokeh version to stipulate when building the docs.

This setting is necessary to re-deploy existing versions of docs with new fixes or changes.

ignore_filename
  • Type: Bool

  • Env var: BOKEH_IGNORE_FILENAME

  • Default: False

  • Dev Default: (Unset)

Whether to ignore the current script filename when saving Bokeh content.

log_level
  • Type: String

  • Env var: BOKEH_LOG_LEVEL

  • Default: ‘info’

  • Dev Default: ‘debug’

Set the log level for JavaScript BokehJS code.

Valid values are, in order of increasing severity:

  • trace

  • debug

  • info

  • warn

  • error

  • fatal

minified
  • Type: Bool

  • Env var: BOKEH_MINIFIED

  • Default: True

  • Dev Default: False

Whether Bokeh should use minified BokehJS resources.

nodejs_path
  • Type: String

  • Env var: BOKEH_NODEJS_PATH

  • Default: None

  • Dev Default: (Unset)

Path to the Node executable.

NodeJS is an optional dependency that is required for PNG and SVG export, and for compiling custom extensions. Bokeh will try to automatically locate an installed Node executable. Use this environment variable to override the location Bokeh finds, or to point to a non-standard location.

validate_doc
  • Type: Bool

  • Env var: BOKEH_VALIDATE_DOC

  • Default: True

  • Dev Default: (Unset)

whether Bokeh should perform validation checks on documents.

Setting this value to False may afford a small performance improvement.

phantomjs_path
  • Type: String

  • Env var: BOKEH_PHANTOMJS_PATH

  • Default: None

  • Dev Default: (Unset)

Path to the PhantomJS executable.

PhantomJS is an optional dependency that is required for PNG and SVG export. Bokeh will try to automatically locate an installed PhantomJS executable. Use this environment variable to override the location Bokeh finds, or to point to a non-standard location.

pretty
  • Type: String

  • Env var: BOKEH_PRETTY

  • Default: False

  • Dev Default: True

Whether JSON strings should be pretty-printed.

py_log_level
  • Type: Log Level

  • Env var: BOKEH_PY_LOG_LEVEL

  • Default: ‘none’

  • Dev Default: ‘debug’

The log level for Python Bokeh code.

Valid values are, in order of increasing severity:

  • trace

  • debug

  • info

  • warn

  • error

  • fatal

  • none

resources
  • Type: String

  • Env var: BOKEH_RESOURCES

  • Default: ‘cdn’

  • Dev Default: ‘absolute-dev’

What kind of BokehJS resources to configure, e.g inline or cdn

See the Resources class reference for full details.

rootdir
  • Type: String

  • Env var: BOKEH_ROOTDIR

  • Default: None

  • Dev Default: (Unset)

Root directory to use with relative resources

See the Resources class reference for full details.

secret_key
  • Type: String

  • Env var: BOKEH_SECRET_KEY

  • Default: None

  • Dev Default: (Unset)

A long, cryptographically-random secret unique to a Bokeh deployment.

sign_sessions
  • Type: String

  • Env var: BOKEH_SIGN_SESSIONS

  • Default: False

  • Dev Default: (Unset)

Whether the Boeh server should only allow sessions signed with a secret key.

If True, BOKEH_SECRET_KEY must also be set.

simple_ids
  • Type: Bool

  • Env var: BOKEH_SIMPLE_IDS

  • Default: True

  • Dev Default: (Unset)

Whether Bokeh should use simple integers for model IDs (starting at 1000).

If False, Bokeh will use UUIDs for object identifiers. This might be needed, e.g., if mulitple processes are contributing to a single Bokeh Document.

ssl_certfile
  • Type: String

  • Env var: BOKEH_SSL_CERTFILE

  • Default: None

  • Dev Default: (Unset)

The path to a certificate file for SSL termination.

ssl_keyfile
  • Type: String

  • Env var: BOKEH_SSL_KEYFILE

  • Default: None

  • Dev Default: (Unset)

The path to a private key file for SSL termination.

ssl_password
  • Type: String

  • Env var: BOKEH_SSL_PASSWORD

  • Default: None

  • Dev Default: (Unset)

A password to decrypt the SSL keyfile, if necessary.

strict
  • Type: Bool

  • Env var: BOKEH_STRICT

  • Default: (Unset)

  • Dev Default: (Unset)

Whether validation checks should be strict (i.e. raise errors).

version
  • Type: String

  • Env var: BOKEH_VERSION

  • Default: None

  • Dev Default: (Unset)

What version of BokehJS to use with CDN resources.

See the Resources class reference for full details.

Additionally, there are a few methods on the settings object:

class Settings[source]
bokehjsdir()[source]

The location of the BokehJS source tree.

css_files()[source]

The CSS files in the BokehJS directory.

js_files()[source]

The JS files in the BokehJS directory.

load_config(location)[source]

Load a user-specified override config file.

The file should be a YAML format with key: value lines.

secret_key_bytes()[source]

Return the secret_key, converted to bytes and cached.