taps.executor.utils¶
FutureDependencyExecutor
¶
FutureDependencyExecutor(executor: Executor)
Bases: Executor
Executor wrapper that adds DAG-like features.
An Executor
implementation that wraps
another executor with logic for delaying task submission until all
Future
instances which are args or kwargs
of a task have completed. In other words, child tasks will not be
scheduled until the results of the child's parent tasks are available.
Parameters:
-
executor
(Executor
) –Executor to wrap.
Source code in taps/executor/utils.py
submit
¶
Schedule the callable to be executed.
Parameters:
-
function
(Callable[P, T]
) –Callable to execute.
-
args
(args
, default:()
) –Positional arguments.
-
kwargs
(kwargs
, default:{}
) –Keyword arguments.
Returns:
Source code in taps/executor/utils.py
map
¶
map(
function: Callable[..., T],
*iterables: Iterable[Any],
timeout: float | None = None,
chunksize: int = 1
) -> Iterator[T]
Map a function onto iterables of arguments.
Parameters:
-
function
(Callable[..., T]
) –A callable that will take as many arguments as there are passed iterables.
-
iterables
(Iterable[Any]
, default:()
) –Variable number of iterables.
-
timeout
(float | None
, default:None
) –The maximum number of seconds to wait. If None, then there is no limit on the wait time.
-
chunksize
(int
, default:1
) –If greater than one, the iterables will be chopped into chunks of size chunksize and submitted to the executor. If set to one, the items in the list will be sent one at a time.
Returns:
-
Iterator[T]
–An iterator equivalent to:
map(func, *iterables)
but the calls may be evaluated out-of-order.
Raises:
-
ValueError
–if chunksize is less than one.
Source code in taps/executor/utils.py
shutdown
¶
Shutdown the executor.
Parameters:
-
wait
(bool
, default:True
) –Wait on all pending futures to complete.
-
cancel_futures
(bool
, default:False
) –Cancel all pending futures that the executor has not started running. Only used in Python 3.9 and later.
Source code in taps/executor/utils.py
warmup_executor
¶
warmup_executor(
executor: Executor,
min_connected_nodes: int,
batch_size: int,
max_batches: int,
batch_sleep: int,
) -> None
Warm up an executor until enough nodes are seen.
Submits a bag of tasks to the executor where each task returns the hostname the task was executed on. Unique hostnames are used to identify active nodes.
Parameters:
-
executor
(Executor
) –Executor to warm up.
-
min_connected_nodes
(int
) –Number of unique nodes necessary to consider the executor warm.
-
batch_size
(int
) –Number of tasks to submit.
-
max_batches
(int
) –Number of iterations to try to warm nodes.
-
batch_sleep
(int
) –Seconds to sleep between batches.
Raises:
-
RuntimeError
–If
min_connected_nodes
nodes are not detected withinmax_batches
warmup iterations.