Skip to content

Commit

Permalink
configure IDOM_CLIENT_IMPORT_SOURCE_URL (#2132)
Browse files Browse the repository at this point in the history
* configure idom import source url

* enforce versioning of IDOM with packaging
  • Loading branch information
rmorshea committed Apr 2, 2021
1 parent 032f36d commit 4533a60
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"panel": true
"panel.io.jupyter_server_extension": true
}
},
"NotebookApp": {
Expand Down
6 changes: 5 additions & 1 deletion panel/io/jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .resources import DIST_DIR


def load_jupyter_server_extension(notebook_app):
def _load_jupyter_server_extension(notebook_app):
web_app = notebook_app.web_app
route_pattern = urljoin(web_app.settings["base_url"], "panel_dist/(.*)")
web_app.add_handlers(
Expand All @@ -18,3 +18,7 @@ def load_jupyter_server_extension(notebook_app):
),
]
)


# compat for older versions of Jupyter
load_jupyter_server_extension = _load_jupyter_server_extension
19 changes: 17 additions & 2 deletions panel/pane/idom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from functools import partial
from threading import Thread
from queue import Queue as SyncQueue
from packaging.version import Version

from ..io.notebook import push_on_root
from ..io.resources import DIST_DIR, LOCAL_DIST
Expand All @@ -12,6 +13,10 @@
from .base import PaneBase


_IDOM_MIN_VER = "0.23"
_IDOM_MAX_VER = "0.24"


def _spawn_threaded_event_loop(coro):
loop_q = SyncQueue()

Expand All @@ -38,6 +43,11 @@ class IDOM(PaneBase):
_bokeh_model = _BkIDOM

def __init__(self, object=None, **params):
from idom import __version__ as idom_version
if Version(_IDOM_MIN_VER) > Version(idom_version) >= Version(_IDOM_MAX_VER):
raise RuntimeError(
f"Expected idom>={_IDOM_MIN_VER},<{_IDOM_MAX_VER}, but found {idom_version}"
)
super().__init__(object, **params)
self._idom_loop = None
self._idom_model = {}
Expand All @@ -64,10 +74,15 @@ def _setup(self):

def _get_model(self, doc, root=None, parent=None, comm=None):
from idom.core.layout import LayoutUpdate
from idom.config import IDOM_CLIENT_IMPORT_SOURCE_URL

# let the client determine import source location
IDOM_CLIENT_IMPORT_SOURCE_URL.set("./")

if comm:
url = '/panel_dist/idom/build/web_modules'
url = '/panel_dist/idom'
else:
url = '/'+LOCAL_DIST+'idom/build/web_modules'
url = '/'+LOCAL_DIST+'idom'

if self._idom_loop is None:
self._setup()
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
requires = [
"param >=1.9.0",
"pyct >=0.4.4",
"setuptools >=30.3.0",
"setuptools >=30.3.0",
"bokeh >=2.3.0,<2.4.0",
"pyviz_comms >=0.6.0",
"requests",
"bleach"
"bleach",
"packaging",
]

0 comments on commit 4533a60

Please sign in to comment.