Class Client

Connect to and submit computation to a Dask cluster

Declaration

class Client
source link

Documentation

The Client connects users to a Dask cluster.  It provides an asynchronous
user interface around functions and futures.  This class resembles
executors in ``concurrent.futures`` but also allows ``Future`` objects
within ``submit/map`` calls.  When a Client is instantiated it takes over
all ``dask.compute`` and ``dask.persist`` calls by default.

It is also common to create a Client without specifying the scheduler
address , like ``Client()``.  In this case the Client creates a
:class:`LocalCluster` in the background and connects to that.  Any extra
keywords are passed from Client to LocalCluster in this case.  See the
LocalCluster documentation for more information.

Attributes

Examples

Provide cluster's scheduler node address on initialization:

>>> client = Client('127.0.0.1:8786')  # doctest: +SKIP

Use ``submit`` method to send individual computations to the cluster

>>> a = client.submit(add, 1, 2)  # doctest: +SKIP
>>> b = client.submit(add, 10, 20)  # doctest: +SKIP

Continue using submit or map on results to build up larger computations

>>> c = client.submit(add, a, b)  # doctest: +SKIP

Gather results with the ``gather`` method.

>>> client.gather(c)  # doctest: +SKIP
33

You can also call Client with no arguments in order to create your own
local cluster.

>>> client = Client()  # makes your own local "cluster" # doctest: +SKIP

Extra keywords will be passed directly to LocalCluster

>>> client = Client(processes=False, threads_per_worker=1)  # doctest: +SKIP

See also

distributed.scheduler.Scheduler: Internal scheduler
distributed.LocalCluster:

Methods

Class methods

Subclasses

Reexports