Passing `dashboard_address=None` does not disable dashboard
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
**Describe the issue**:
Passing `dashboard_address=None` to `LocalCluster()` does not disable dashboard, even though the [`LocalCluster` documentation](https://docs.dask.org/en/latest/deploying-python.html?highlight=localcluster#reference) states `None` should disable it.
Is this a bug or intended change with outdated documentation?
**Minimal Complete Verifiable Example**:
```python
In [1]: from distributed import LocalCluster
In [2]: cluster1 = LocalCluster()
In [3]: cluster2 = LocalCluster(dashboard_address=None)
/datasets/pentschev/miniconda3/envs/rn-230828/lib/python3.9/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 44165 instead
warnings.warn(
```
**Anything else we need to know?**:
It's unclear whether that's still the intended behavior. I found no tests or even uses for `dashboard_address=None` anywhere in the codebase, I would expect tests to use `dashboard_address=None` to prevent warnings such as the one below, but all tests use `dashboard_address=":0"` (bind to a random port) instead to prevent warnings that the dashboard port is already in use.
Probable fix
```patch
diff --git a/distributed/scheduler.py b/distributed/scheduler.py
index 0937e5b2..d8776b63 100644
--- a/distributed/scheduler.py
+++ b/distributed/scheduler.py
@@ -3529,6 +3529,7 @@ class Scheduler(SchedulerState, ServerNode):
default_port=self.default_port,
)
+ self.jupyter = jupyter
http_server_modules = dask.config.get("distributed.scheduler.http.routes")
show_dashboard = dashboard or (dashboard is None and dashboard_address)
# install vanilla route if show_dashboard but bokeh is not installed
@@ -3538,15 +3539,15 @@ class Scheduler(SchedulerState, ServerNode):
except ImportError:
show_dashboard = False
http_server_modules.append("distributed.http.scheduler.missing_bokeh")
- routes = get_handlers(
- server=self, modules=http_server_modules, prefix=http_prefix
- )
- self.start_http_server(routes, dashboard_address, default_port=8787)
- self.jupyter = jupyter
- if show_dashboard:
+
+ routes = get_handlers(
+ server=self, modules=http_server_modules, prefix=http_prefix
+ )
+ self.start_http_server(routes, dashboard_address, default_port=8787)
distributed.dashboard.scheduler.connect(
self.http_application, self.http_server, self, prefix=http_prefix
)
+
if self.jupyter:
try:
from jupyter_server.serverapp import ServerApp
```
Reproducer with patch above applied
```python
In [1]: from distributed import LocalCluster
In [2]: cluster1 = LocalCluster()
In [3]: cluster2 = LocalCluster(dashboard_address=None)
In [4]:
```
**Environment**:
- Dask version: dask=2023.8.2a230825, distributed=2023.8.2a230825
- Python version: 3.9.17
- Operating System: Ubuntu 20.04
- Install method (conda, pip, source): conda
Contributor guide
Assessment
This issue has not been assessed yet.