Skip to content

Commit

Permalink
Move min bokeh version constant to restore as optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverholworthy committed Oct 31, 2022
1 parent 1db2595 commit f06b272
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 4 additions & 5 deletions distributed/dashboard/core.py
Expand Up @@ -12,15 +12,14 @@
import dask

from distributed.dashboard.utils import BOKEH_VERSION
from distributed.versions import MIN_BOKEH_VERSION

_min_bokeh_version = "2.1.1"

if BOKEH_VERSION < parse_version(_min_bokeh_version):
if BOKEH_VERSION < parse_version(MIN_BOKEH_VERSION):
warnings.warn(
f"\nDask needs bokeh >= {_min_bokeh_version}, < 3 for the dashboard."
f"\nDask needs bokeh >= {MIN_BOKEH_VERSION}, < 3 for the dashboard."
"\nContinuing without the dashboard."
)
raise ImportError(f"Dask needs bokeh >= {_min_bokeh_version}, < 3")
raise ImportError(f"Dask needs bokeh >= {MIN_BOKEH_VERSION}, < 3")


def BokehApplication(applications, server, prefix="/", template_variables=None):
Expand Down
8 changes: 4 additions & 4 deletions distributed/http/scheduler/missing_bokeh.py
@@ -1,17 +1,17 @@
from __future__ import annotations

from distributed.dashboard.core import _min_bokeh_version
from distributed.http.utils import RequestHandler, redirect
from distributed.utils import log_errors
from distributed.versions import MIN_BOKEH_VERSION


class MissingBokeh(RequestHandler):
@log_errors
def get(self):
self.write(
f"<p>Dask needs bokeh >= {_min_bokeh_version}, < 3 for the dashboard.</p>"
f"<p>Install with conda: conda install bokeh>={_min_bokeh_version},<3</p>"
f"<p>Install with pip: pip install bokeh>={_min_bokeh_version},<3</p>"
f"<p>Dask needs bokeh >= {MIN_BOKEH_VERSION}, < 3 for the dashboard.</p>"
f"<p>Install with conda: conda install bokeh>={MIN_BOKEH_VERSION},<3</p>"
f"<p>Install with pip: pip install bokeh>={MIN_BOKEH_VERSION},<3</p>"
)


Expand Down
2 changes: 2 additions & 0 deletions distributed/versions.py
Expand Up @@ -12,6 +12,8 @@
from types import ModuleType
from typing import Any

MIN_BOKEH_VERSION = "2.1.1"

required_packages = [
("dask", lambda p: p.__version__),
("distributed", lambda p: p.__version__),
Expand Down

0 comments on commit f06b272

Please sign in to comment.