From 051f82ad9799dd86a42836b4b48768c94aa73eaf Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Fri, 1 Dec 2023 22:05:51 +0000 Subject: [PATCH] Add version check for absolute url fix (#8381) --- distributed/dashboard/core.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/distributed/dashboard/core.py b/distributed/dashboard/core.py index c9017ef821..96211bb2ea 100644 --- a/distributed/dashboard/core.py +++ b/distributed/dashboard/core.py @@ -6,8 +6,8 @@ from bokeh.application import Application from bokeh.application.handlers.function import FunctionHandler from bokeh.resources import Resources -from bokeh.server.server import BokehTornado from bokeh.server.util import create_hosts_allowlist +from packaging.version import parse as parse_version import dask @@ -32,9 +32,14 @@ from bokeh.models import TabPanel # noqa: F401 -class DaskBokehTornado(BokehTornado): - def resources(self, absolute_url: str | bool | None = True) -> Resources: - return super().resources(absolute_url) +if BOKEH_VERSION < parse_version("3.3.0"): + from bokeh.server.server import BokehTornado as DaskBokehTornado +else: + from bokeh.server.server import BokehTornado + + class DaskBokehTornado(BokehTornado): # type: ignore[no-redef] + def resources(self, absolute_url: str | bool | None = True) -> Resources: + return super().resources(absolute_url) def BokehApplication(applications, server, prefix="/", template_variables=None):