Backends¶
backends
¶
Task execution backends for DagLite.
Backend
¶
Bases: ABC
Abstract base class for task execution backends.
A backend defines how task calls are executed — sequentially, across threads, across
processes, or on a remote cluster. Custom backends can be registered with the BackendManager
to extend daglite.
Subclasses must implement _submit.
Lifecycle:
start(session)— called once when the backend is first requested inside a session.submit(func, args, kwargs)— called to dispatch work.stop()— called when the session exits.
Source code in src/daglite/backends/base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
start
¶
Initialise backend resources (thread pools, process pools, queues, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
SessionContext | None
|
Active session context carrying event/plugin infrastructure and settings. |
required |
Source code in src/daglite/backends/base.py
stop
¶
submit
¶
submit(
func: Callable[..., Any],
args: tuple[Any, ...],
kwargs: dict[str, Any] | None = None,
*,
map_index: int | None = None,
) -> Future[Any]
Submit a single task call and return a Future for its result.
This is the fundamental execution primitive. Backends that wrap thread pools, process pools, or remote clusters implement this to dispatch one unit of work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
A callable to be executed on the backend. |
required |
args
|
tuple[Any, ...]
|
Positional arguments for the callable. |
required |
kwargs
|
dict[str, Any] | None
|
Optional keyword arguments for the callable. |
None
|
map_index
|
int | None
|
Optional index of the item in a fan-out map operation. |
None
|
Returns:
| Type | Description |
|---|---|
Future[Any]
|
A |