Repository: dask/distributed

Issue:
Add Client.open_dashboard
As an alternative to clicking on the repr link.

Roughly

```python
def open_dashboard(self):
    info = client.scheduler_info()
    base = info['address']
    port = info['services']['bokeh']

    # there's probably already a way to get this URL.
    url = "http://{}:{}/status".format(urlparse(base).netloc.split(":")[0],
                                       port)
    webbrowser.open(url)
```


Discussion:
This might be nice for tutorials

On Fri, Jun 29, 2018 at 12:14 PM, Tom Augspurger <notifications@github.com>
wrote:

> As an alternative to clicking on the repr link.
>
> Roughly
>
> def open_dashboard(self):
>     info = client.scheduler_info()
>     base = info['address']
>     port = info['services']['bokeh']
>
>     # there's probably already a way to get this URL.
>     url = "http://{}:{}/status".format(urlparse(base).netloc.split(":")[0],
>                                        port)
>     webbrowser.open(url)
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/dask/distributed/issues/2083>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AASszAcKtKs-UXfHWIK59-xVuaF3YHsfks5uBlJ8gaJpZM4U9R4i>
> .
>

We found in tutorials that the URL reported by the kubernetes cluster object and the client did not match, that the former was correct - presumably because the client doesn't know it's running inside a cluster. Maybe the parallel discussions on relative addresses fixed that, but think it needs pointing out here.
This approach will have the same limitations as the link in
`Client._repr_html_`.

Personally, I would use it for debugging sessions when I'm repeatedly
creating new clients / clusters, and would like to have a dashboard open
while the computation is running.

On Fri, Jun 29, 2018 at 11:44 AM, Martin Durant <notifications@github.com>
wrote:

> We found in tutorials that the URL reported by the kubernetes cluster
> object and the client did not match, that the former was correct -
> presumably because the client doesn't know it's running inside a cluster.
> Maybe the parallel discussions on relative addresses fixed that, but think
> it needs pointing out here.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/dask/distributed/issues/2083#issuecomment-401410111>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIkk53To2xIz5WwwQeutGWIGfzPp1ks5uBllbgaJpZM4U9R4i>
> .
>

@martindurant, have struggled with this as well. Lately my solution to that problem is [`nbserverproxy`]( https://github.com/jupyterhub/nbserverproxy ), which proxies the scheduler port under the Jupyter Notebook service. Running `dask.config.set({"distributed.dashboard.link": "/proxy/{port}/status"})` sets the URL to the scheduler relative to the current URL and seems to work well regardless of the particular network config (in my limited experience). Would be curious to know if this works for you.
Conversation in this issue has separated into two equally valid points:

1.  We should have a method to open the dashboard from the client
2.  Finding the right address can sometimes be difficult

I think that conversation should continue mostly around point 1, which people seem to think is a nice idea.  Marking this as a good first issue.  
Pinging this slightly old issue -- should this still be considered a feature request? If so, @TomAugspurger do you think the PR you started is a still useful to draw some inspiration?
I think that we now have `Client.dashboard_link`. So in theory `webbrowser.open(client.dashboard_link)` should work just fine.
Also if this URL is rendered in a notebook, Jupyter will create a link. So that itself might be enough
OK, closing this. That may still be something interesting to do here because of https://github.com/dask/distributed/pull/3744 and finding the endpoints for worker-X.
(oh, but I notice that `dashboard_link` is not in the API docs)

Resolving patch:
diff --git a/distributed/client.py b/distributed/client.py
--- a/distributed/client.py
+++ b/distributed/client.py
@@ -808,6 +808,23 @@ def asynchronous(self):
 
     @property
     def dashboard_link(self):
+        """Link to the scheduler's dashboard.
+
+        Returns
+        -------
+        str
+            Dashboard URL.
+
+        Examples
+        --------
+        Opening the dashboard in your default web browser:
+
+        >>> import webbrowser
+        >>> from distributed import Client
+        >>> client = Client()
+        >>> webbrowser.open(client.dashboard_link)
+
+        """
         try:
             return self.cluster.dashboard_link
         except AttributeError:


Test patch: