Is x a runnable task? A task is a tuple with a callable first argument Examples -------- >>> inc = lambda x: x + 1 >>> istask((inc, 1)) True >>> istask(1) False
(x)
| 38 | |
| 39 | |
| 40 | def istask(x): |
| 41 | """Is x a runnable task? |
| 42 | |
| 43 | A task is a tuple with a callable first argument |
| 44 | |
| 45 | Examples |
| 46 | -------- |
| 47 | |
| 48 | >>> inc = lambda x: x + 1 |
| 49 | >>> istask((inc, 1)) |
| 50 | True |
| 51 | >>> istask(1) |
| 52 | False |
| 53 | """ |
| 54 | from dask._task_spec import DataNode, GraphNode |
| 55 | |
| 56 | if isinstance(x, GraphNode): |
| 57 | return not isinstance(x, DataNode) |
| 58 | return type(x) is tuple and x and callable(x[0]) |
| 59 | |
| 60 | |
| 61 | def preorder_traversal(task): |
no outgoing calls