Skip to content

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.

fix: from_panel using private APIs (#3813)

Akshay Agrawal8b1f4f171f41
diff --git a/marimo/_plugins/ui/_impl/from_panel.py b/marimo/_plugins/ui/_impl/from_panel.py
index dfc8f97cf4..405d1ca838 100644
--- a/marimo/_plugins/ui/_impl/from_panel.py
+++ b/marimo/_plugins/ui/_impl/from_panel.py
@@ -94,6 +94,7 @@ def render_extension(load_timeout: int = 500, loaded: bool = False) -> str:
Returns:
JavaScript code for Panel extension
"""
+ # See panel.io.notebook.py
from panel.config import panel_extension
new_exts: list[str] = [
@@ -106,26 +107,22 @@ def render_extension(load_timeout: int = 500, loaded: bool = False) -> str:
from bokeh.io.notebook import curstate # type: ignore
from bokeh.resources import CDN, INLINE
- from bokeh.settings import settings
from panel.config import config
from panel.io.notebook import ( # type: ignore
Resources,
_autoload_js,
- _Unset,
bundle_resources,
require_components,
state,
)
+ from panel.io.resources import set_resource_mode # type: ignore
curstate().output_notebook()
resources = INLINE if config.inline else CDN
- prev_resources = settings.resources(default="server")
- user_resources = settings.resources._user_value is not _Unset
nb_endpoint = not state._is_pyodide
- resources = Resources.from_bokeh(resources, notebook=nb_endpoint) # type: ignore[no-untyped-call]
-
- try:
+ with set_resource_mode(resources.mode):
+ resources = Resources.from_bokeh(resources, notebook=nb_endpoint) # type: ignore[no-untyped-call]
bundle = bundle_resources( # type: ignore[no-untyped-call]
None,
resources,
@@ -145,11 +142,6 @@ def render_extension(load_timeout: int = 500, loaded: bool = False) -> str:
reloading=loaded,
load_timeout=load_timeout,
)
- finally:
- if user_resources:
- settings.resources = prev_resources
- else:
- settings.resources.unset_value()
loaded_extensions.extend(new_exts)
return bokeh_js # type: ignore[no-any-return]