Repository navigation
Closed
Description
According to a recent update, distributed should only warn if bokeh is version >=3, and not break. But that is not the case:
/usr/local/lib/python3.9/site-packages/distributed/client.py:4591: in get_task_stream
return self.sync(
/usr/local/lib/python3.9/site-packages/distributed/utils.py:339: in sync
return sync(
/usr/local/lib/python3.9/site-packages/distributed/utils.py:406: in sync
raise exc.with_traceback(tb)
/usr/local/lib/python3.9/site-packages/distributed/utils.py:379: in f
result = yield future
/usr/local/lib/python3.9/site-packages/tornado/gen.py:762: in run
value = future.result()
/usr/local/lib/python3.9/site-packages/distributed/client.py:4615: in _get_task_stream
from distributed.dashboard.components.scheduler import task_stream_figure
/usr/local/lib/python3.9/site-packages/distributed/dashboard/components/scheduler.py:74: in <module>
from distributed.dashboard.core import TabPanel
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
from __future__ import annotations
import functools
import warnings
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from bokeh.server.server import BokehTornado
from bokeh.server.util import create_hosts_allowlist
from packaging.version import parse as parse_version
import dask
from distributed.dashboard.utils import BOKEH_VERSION
from distributed.versions import MAX_BOKEH_VERSION, MIN_BOKEH_VERSION
if BOKEH_VERSION < parse_version(MIN_BOKEH_VERSION) or BOKEH_VERSION > parse_version(
MAX_BOKEH_VERSION
):
warnings.warn(
f"\nDask needs bokeh >= {MIN_BOKEH_VERSION}, < 3 for the dashboard."
f"\nYou have bokeh=={BOKEH_VERSION}."
"\nContinuing without the dashboard."
)
> raise ImportError(
f"Dask needs bokeh >= {MIN_BOKEH_VERSION}, < 3, not bokeh=={BOKEH_VERSION}"
)
E ImportError: Dask needs bokeh >= 2.4.2, < 3, not bokeh==3.0.2
/usr/local/lib/python3.9/site-packages/distributed/dashboard/core.py:25: ImportError
This ImportError should not be thrown if the intention is that you warn the user that they might have problems with some of the features but it is up to them whether they want to use a newer bokeh or not.
See also discussion from #7173 (comment) and below.
There is also this comment: #7359 (comment) Which suggests that indeed, bokeh versions should not break distributed.
Environment:
- Dask and distributed version: 2022.11.0
- Python version: 3.9
- Bokeh version: 3.0.2
Metadata
Metadata
Assignees
Labels
No labels
Activity
gjoseph92 commentedon Nov 30, 2022
@gabicca can you share a minimal reproducer of how you're triggering this import error?
I created a fresh environment with distributed and too new of a bokeh version:
Importing distributed and launching a client works fine. The bokeh incompatibility is only a warning, not an error:
Details
pyproject.toml
poetry.lock
jrbourbeau commentedon Nov 30, 2022
Thanks for opening an issue for this @gabicca.
Just to clarify, plotting-related functionality in
distributeddoesn't work withbokeh>3at the moment. There are known issues with rendering dashboard, performance report, etc. plots. Asbokehis an optional dependency fordistributed, it's difficult to ensure abokeh<3pin is always applied. While we're working to resolve these knownbokehissues, we've addedbokeh<3pins topip install dask[complete]andconda install -c conda-forge dask. Hopefully that helps.gabicca commentedon Dec 1, 2022
Hi @gjoseph92 if you take a closer look at the traceback I posted, the error doesn't occur when you call Client, but when you call Client().get_task_stream().
I was playing with this, trying to get a simple example (the original error comes from a complicated test). And this is what I found.
Set up:
Indeed, at this point the warning comes up.
Next,
If you do the following the error doesn't occur:
client.get_task_stream()But if you give it arguments, it does:
client.get_task_stream(plot="save", filename="my_file.html")Versions:
dask, distributed: 2022.11.1
bokeh: 3.0.2
python: 3.9.12
gabicca commentedon Dec 1, 2022
Hi @jrbourbeau , could you please point me where bokeh is included in the requirements (even with a pin, which is fin and would work). I'm looking at the requirements.txt and setup.py files but not finding any reference.
Actually, now that I look at it, you refer to dask, not distributed. Is that what's recommended, install these requirements through dask. Eventhough, I'd find it more useful if distributed had a similar set up, allowing to have bokeh as an extra requirement, since distributed needs it for some of it features (See #7363).
By the way,
pip install dask[complete]doesn't work for me (though this is probably just a local problem):gjoseph92 commentedon Dec 1, 2022
bokehis not a requirement of the distributed package (because it's not a required dependency). Unfortunately, Python packaging doesn't respect restrictions for non-required dependencies. That is, we could markbokeh<3as an optional dependency ofdistributed, but pip, poetry, and other Python package managers wouldn't care—they'd still install bokeh 3 alongside distributed. The only way we could encourage package managers not to install bokeh 3 alongside distributed is to:bokeh<3a required dependency of distributed—which it isn't.extras_requiregroup (such asdistributed[diagnostics]) with abokeh<3dependency. Users who explicitly installeddistributed[diagnostics]would get the correct bokeh version, but just installingdistributed(ordistributed bokeh) could still get you the wrong one.Try
pip install 'dask[complete]'(note the quotes).This is specified here: https://github.com/dask/dask/blob/a7efdf938c1942dd3174f623d37b7f65b5384d87/setup.py#L20
[-]Distributed breaks with bokeh >= 3[/-][+]`get_task_stream(plot=True)` breaks with bokeh >= 3[/+]gabicca commentedon Dec 1, 2022
@gjoseph92 thanks, quotes solved the problem.
Note though:
"WARNING: distributed 2022.11.1 does not provide the extra 'diagnostics'"
Is that an actual thing? If not, it'd be great if it was, that's exactly the kind of thing I'd expect a package to have if only specific features depend on some extra packages. But this should be a conversation on #7363.
gjoseph92 commentedon Dec 1, 2022
@gabicca I actually think you're experiencing correct behavior here. You're trying to call a function which requires bokeh to generate its output (a bokeh-based plot). If an incompatible bokeh version is installed and the plot can't be generated, what would you want the function to return?
To me, a runtime error is much better behavior than, say, "successfully" generating an empty plot that just contains the text "Dask needs bokeh >= 2.4.2, < 3 for the dashboard".
Bokeh is an optional dependency, so having the wrong bokeh version installed shouldn't raise errors—unless you're trying to do things that explicitly require bokeh.