diff --git a/distributed/client.py b/distributed/client.py index 4036a889f2b..7eadf9448c0 100644 --- a/distributed/client.py +++ b/distributed/client.py @@ -22,10 +22,12 @@ from contextlib import contextmanager, suppress from contextvars import ContextVar from functools import partial +from importlib.metadata import PackageNotFoundError, version from numbers import Number from queue import Queue as pyQueue from typing import Any, ClassVar, Coroutine, Literal, Sequence, TypedDict +from packaging.version import parse as parse_version from tlz import first, groupby, keymap, merge, partition_all, valmap import dask @@ -1145,6 +1147,12 @@ def __repr__(self): return f"<{self.__class__.__name__}: No scheduler connected>" def _repr_html_(self): + try: + dle_version = parse_version(version("dask-labextension")) + JUPYTERLAB = False if dle_version < parse_version("6.0.0") else True + except PackageNotFoundError: + JUPYTERLAB = False + scheduler, info = self._get_scheduler_info() return get_template("client.html.j2").render( @@ -1154,6 +1162,7 @@ def _repr_html_(self): cluster=self.cluster, scheduler_file=self.scheduler_file, dashboard_link=self.dashboard_link, + jupyterlab=JUPYTERLAB, ) def start(self, **kwargs): diff --git a/distributed/widgets/templates/client.html.j2 b/distributed/widgets/templates/client.html.j2 index ad1c2e509ed..8a490acdd0b 100644 --- a/distributed/widgets/templates/client.html.j2 +++ b/distributed/widgets/templates/client.html.j2 @@ -29,6 +29,12 @@ + {% if jupyterlab %} + + {% endif %} + {% if scheduler is none %}

No scheduler connected.

{% elif cluster %}