Check if a value in a Dask graph looks like a getter. 1. Is it a tuple with the first element a known getter. If a getter is found, it returns a tuple with (getter, array, index, asarray, lock). Otherwise it returns ``None``.
(
value: GraphNode,
)
| 66 | |
| 67 | |
| 68 | def _is_getter_task( |
| 69 | value: GraphNode, |
| 70 | ) -> tuple[Callable, Any, Any, bool, bool | None] | None: |
| 71 | """Check if a value in a Dask graph looks like a getter. |
| 72 | 1. Is it a tuple with the first element a known getter. |
| 73 | If a getter is found, it returns a tuple with (getter, array, index, asarray, lock). |
| 74 | Otherwise it returns ``None``. |
| 75 | """ |
| 76 | if not isinstance(value, Task): |
| 77 | return None |
| 78 | func = value.func |
| 79 | if func in GETTERS: |
| 80 | get = func |
| 81 | else: |
| 82 | return None |
| 83 | |
| 84 | length = len(value.args) |
| 85 | if length == 2: |
| 86 | # getter defaults to asarray=True, getitem is semantically False |
| 87 | return get, value.args[0], value.args[1], get is not getitem, None |
| 88 | elif length == 4: |
| 89 | return get, *list(value.args) |
| 90 | |
| 91 | return None |
| 92 | |
| 93 | |
| 94 | def _optimize_slices(dsk): |
no outgoing calls
no test coverage detected
searching dependent graphs…