| 1 |
:orphan: |
| 2 |
|
| 3 |
Diagnostics (distributed) |
| 4 |
========================= |
| 5 |
|
| 6 |
The :doc:`Dask distributed scheduler <scheduling>` provides live feedback in two |
| 7 |
forms: |
| 8 |
|
| 9 |
1. An interactive dashboard containing many plots and tables with live |
| 10 |
information |
| 11 |
2. A progress bar suitable for interactive use in consoles or notebooks |
| 12 |
|
| 13 |
Dashboard |
| 14 |
--------- |
| 15 |
|
| 16 |
For information on the Dask dashboard see :doc:`dashboard`. |
| 17 |
|
| 18 |
Capture diagnostics |
| 19 |
------------------- |
| 20 |
|
| 21 |
.. currentmodule:: dask.distributed |
| 22 |
|
| 23 |
.. autosummary:: |
| 24 |
get_task_stream |
| 25 |
Client.profile |
| 26 |
performance_report |
| 27 |
|
| 28 |
You can capture some of the same information that the dashboard presents for |
| 29 |
offline processing using the ``get_task_stream`` and ``Client.profile`` |
| 30 |
functions. These capture the start and stop time of every task and transfer, |
| 31 |
as well as the results of a statistical profiler. |
| 32 |
|
| 33 |
.. code-block:: python |
| 34 |
|
| 35 |
with get_task_stream(plot='save', filename="task-stream.html") as ts: |
| 36 |
x.compute() |
| 37 |
|
| 38 |
client.profile(filename="dask-profile.html") |
| 39 |
|
| 40 |
history = ts.data |
| 41 |
|
| 42 |
Additionally, Dask can save many diagnostics dashboards at once including the |
| 43 |
task stream, worker profiles, bandwidths, etc. with the ``performance_report`` |
| 44 |
context manager: |
| 45 |
|
| 46 |
.. code-block:: python |
| 47 |
|
| 48 |
from dask.distributed import performance_report |
| 49 |
|
| 50 |
with performance_report(filename="dask-report.html"): |
| 51 |
## some dask computation |
| 52 |
|
| 53 |
The following video demonstrates the ``performance_report`` context manager in greater |
| 54 |
detail: |
| 55 |
|
| 56 |
.. raw:: html |
| 57 |
|
| 58 |
<iframe width="560" |
| 59 |
height="315" |
| •60 |
src="https://www.youtube-nocookie.com/embed/nTMGbkS761Q" |
| 61 |
frameborder="0" |
| 62 |
allow="autoplay; encrypted-media" |
| 63 |
allowfullscreen> |
| 64 |
</iframe> |
| 65 |
|
| 66 |
|
| 67 |
Progress bar |
| 68 |
------------ |
| 69 |
|
| 70 |
.. currentmodule:: dask.distributed |
| 71 |
|
| 72 |
.. autosummary:: |
| 73 |
progress |
| 74 |
|
| 75 |
The ``dask.distributed`` progress bar differs from the ``ProgressBar`` used for |
| 76 |
:doc:`local diagnostics <diagnostics-local>`. |
| 77 |
The ``progress`` function takes a Dask object that is executing in the background: |
| 78 |
|
| 79 |
.. code-block:: python |
| 80 |
|
| 81 |
# Progress bar on a single-machine scheduler |
| 82 |
from dask.diagnostics import ProgressBar |
| 83 |
|
| 84 |
with ProgressBar(): |
| 85 |
x.compute() |
| 86 |
|
| 87 |
# Progress bar with the distributed scheduler |
| 88 |
from dask.distributed import Client, progress |
| 89 |
|
| 90 |
client = Client() # use dask.distributed by default |
| 91 |
|
| 92 |
x = x.persist() # start computation in the background |
| 93 |
progress(x) # watch progress |
| 94 |
|
| 95 |
x.compute() # convert to final result when done if desired |
| 96 |
|
| 97 |
|
| 98 |
Connecting to the Dashboard |
| 99 |
--------------------------- |
| 100 |
|
| 101 |
Some computer networks may restrict access to certain ports or only allow |
| 102 |
access from certain machines. If you are unable to access the dashboard then |
| 103 |
you may want to contact your IT administrator. |
| 104 |
|
| 105 |
Some common problems and solutions follow: |
| 106 |
|
| 107 |
Specify an accessible port |
| 108 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 109 |
|
| 110 |
Some clusters restrict the ports that are visible to the outside world. These |
| 111 |
ports may include the default port for the web interface, ``8787``. There are |
| 112 |
a few ways to handle this: |
| 113 |
|
| 114 |
1. Open port ``8787`` to the outside world. Often this involves asking your |
| 115 |
cluster administrator. |
| 116 |
2. Use a different port that is publicly accessible using the |
| 117 |
``--dashboard-address :8787`` option on the ``dask-scheduler`` command. |
| 118 |
3. Use fancier techniques, like `Port Forwarding`_ |
| 119 |
|
| 120 |
Port Forwarding |
| 121 |
~~~~~~~~~~~~~~~ |
| 122 |
|
| 123 |
If you have SSH access then one way to gain access to a blocked port is through |
| 124 |
SSH port forwarding. A typical use case looks like the following: |
| 125 |
|
| 126 |
.. code:: bash |
| 127 |
|
| 128 |
local$ ssh -L 8000:localhost:8787 user@remote |
| 129 |
remote$ dask-scheduler # now, the web UI is visible at localhost:8000 |
| 130 |
remote$ # continue to set up dask if needed -- add workers, etc |
| 131 |
|
| 132 |
It is then possible to go to ``localhost:8000`` and see Dask Web UI. This same approach is |
| 133 |
not specific to dask.distributed, but can be used by any service that operates over a |
| 134 |
network, such as Jupyter notebooks. For example, if we chose to do this we could |
| 135 |
forward port 8888 (the default Jupyter port) to port 8001 with |
| 136 |
``ssh -L 8001:localhost:8888 user@remote``. |
| 137 |
|
| 138 |
Required Packages |
| 139 |
~~~~~~~~~~~~~~~~~ |
| 140 |
|
| 141 |
Bokeh must be installed in your scheduler's environment to run the dashboard. If it's not the dashboard page will instruct you to install it. |
| 142 |
|
| 143 |
Depending on your configuration, you might also need to install ``jupyter-server-proxy`` to access the dashboard. |
| 144 |
|
| 145 |
API |
| 146 |
--- |
| 147 |
|
| 148 |
.. autofunction:: progress |
| 149 |
.. autofunction:: get_task_stream |