A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: use theme in bokeh formatter (#1353)
Myles Scolnickc39548529979
diff --git a/marimo/_output/formatters/bokeh_formatters.py b/marimo/_output/formatters/bokeh_formatters.pyindex 15ce5d8660..ab6b9a1b9e 100644--- a/marimo/_output/formatters/bokeh_formatters.py+++ b/marimo/_output/formatters/bokeh_formatters.py@@ -24,8 +24,14 @@ class BokehFormatter(FormatterFactory):) -> tuple[KnownMimeType, str]:import bokeh.embed # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501import bokeh.resources # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501+ from bokeh.io import ( # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501+ curdoc,+ )- html_content = bokeh.embed.file_html(plot, bokeh.resources.CDN)+ current_theme = curdoc().theme+ html_content = bokeh.embed.file_html(+ plot, bokeh.resources.CDN, theme=current_theme+ )return ("text/html",flatten_string(diff --git a/marimo/_smoke_tests/bugs/1351.py b/marimo/_smoke_tests/bugs/1351.pynew file mode 100644index 0000000000..c908974a0a--- /dev/null+++ b/marimo/_smoke_tests/bugs/1351.py@@ -0,0 +1,58 @@+# Copyright 2024 Marimo. All rights reserved.++import marimo++__generated_with = "0.5.1"+app = marimo.App()+++def __(mo):+ themes = ["dark_minimal", "light_minimal", "contrast", "night_sky", "caliber"]+ selected_theme = mo.ui.radio(themes, label="Theme", value="dark_minimal")+ selected_theme+ return selected_theme, themes+++def __(selected_theme):+ import polars as pl+ import holoviews as hv+ import hvplot.polars+ hv.extension("bokeh")+ hvplot.extension("bokeh")+ hv.renderer('bokeh').theme = selected_theme.value+ return hv, hvplot, pl+++def __(pl):+ df = pl.DataFrame({"a": range(1, 10), "b": range(1, 10)})+ df.plot.line(x="a", y="b",)+ return df,+++def __(selected_theme):+ from bokeh.plotting import curdoc, figure++ x = [1, 2, 3, 4, 5]+ y = [6, 7, 6, 4, 5]++ curdoc().theme = selected_theme.value++ p = figure(width=300, height=300)+ p.line(x, y)++ p+ return curdoc, figure, p, x, y+++def __():+ import marimo as mo+ return mo,+++if __name__ == "__main__":+ app.run()