distributed 2021.10.0

ParametersReturnsBackRef
map(self, func, *iterables, key=None, workers=None, retries=None, resources=None, priority=0, allow_other_workers=False, fifo_timeout='100 ms', actor=False, actors=False, pure=None, batch_size=None, **kwargs)

Arguments can be normal objects or Futures

Parameters

func : callable

Callable to be scheduled for execution. If func returns a coroutine, it will be run on the main event loop of a worker. Otherwise func will be run in a worker's task executor pool (see Worker.executors for more information.)

iterables : Iterables

List-like objects to map over. They should have the same length.

key : str, list

Prefix for task names if string. Explicit names if list.

pure : bool (defaults to True)

Whether or not the function is pure. Set pure=False for impure functions like np.random.random . See pure functions for more details.

workers : string or iterable of strings

A set of worker hostnames on which computations may be performed. Leave empty to default to all workers (common case)

allow_other_workers : bool (defaults to False)

Used with :None:None:`workers`. Indicates whether or not the computations may be performed on workers that are not in the :None:None:`workers` set(s).

retries : int (default to 0)

Number of allowed automatic retries if a task fails

priority : Number

Optional prioritization of task. Zero is default. Higher priorities take precedence

fifo_timeout : str timedelta (default '100ms')

Allowed amount of time between calls to consider the same priority

resources : dict (defaults to {})

Defines the :None:None:`resources` each instance of this mapped task requires on the worker; e.g. {'GPU': 2} . See worker resources <resources> for details on defining resources.

actor : bool (default False)

Whether these tasks should exist on the worker as stateful actors. See actors for additional details.

actors : bool (default False)

Alias for actor

batch_size : int, optional

Submit tasks to the scheduler in batches of (at most) batch_size . Larger batch sizes can be useful for very large iterables , as the cluster can start processing tasks while later ones are submitted asynchronously.

**kwargs : dict

Extra keywords to send to the function. Large values will be included explicitly in the task graph.

Returns

List, iterator, or Queue of futures, depending on the type of the
inputs.

Map a function on a sequence of arguments

See Also

Client.submit

Submit a single function

Examples

This example is valid syntax, but we were not able to check execution
>>> L = client.map(func, sequence)  # doctest: +SKIP
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

distributed.worker.get_client distributed.client.Client.submit

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /distributed/client.py#1593
type: <class 'function'>
Commit: