#12792·wandb

[Bug]: Bokeh: initialize media for the supported Document input

Author: humdrum00001010Created Sep 10, 2026Updated Sep 11, 2026

Describe the bug

wandb.data_types.Bokeh explicitly accepts a Bokeh Document, but a valid nonempty document leaves the media object uninitialized: file_is_set() is false and artifact serialization contains only {"_type": "bokeh-file"}, with no path or data.

In the current constructor, a Document only suppresses the final type error. Initialization and _set_file run for a model or file path, but never for the declared Document alternative.

Minimal reproduction

python
import wandb
from wandb.data_types import Bokeh
from bokeh.document import Document
from bokeh.plotting import figure

plot = figure()
plot.line([0, 1], [0, 1])
doc = Document()
doc.add_root(plot)
media = Bokeh(doc)
print(media.file_is_set())
print(media.to_json(wandb.Artifact("document-example", type="dataset")))

standalone = figure()
standalone.line([0, 1], [0, 1])
print(Bokeh(standalone).file_is_set())
False
{'_type': 'bokeh-file'}
True

The control uses a separate model because a model already owned by the original document cannot be reattached to another one. This uses real Bokeh objects and a local Artifact; no run or server is involved.

Expected behavior

Initialize and serialize the data for the supported Document input, as for the equivalent model input.

Environment

  • W&B SDK: 0.30.0; relevant source is identical on main 8f93d444e29e4d1a50a888899f51051012ee2679
  • Bokeh: 3.10.0
  • Python: 3.12.12
  • OS: macOS 26.1, arm64
  • W&B server: not applicable; server rendering was not tested

Related #11495 fixes Bokeh 3.9 model serialization; the Document constructor path remains unhandled.