MCPcopy Index your code
hub / github.com/dask/dask / cull

Function cull

dask/_task_spec.py:1188–1210  ·  view source on GitHub ↗
(
    dsk: dict[KeyType, GraphNode], keys: Iterable[KeyType]
)

Source from the content-addressed store, hash-verified

1186
1187
1188def cull(
1189 dsk: dict[KeyType, GraphNode], keys: Iterable[KeyType]
1190) -> dict[KeyType, GraphNode]:
1191 if not isinstance(keys, (list, set, tuple)):
1192 raise TypeError(
1193 f"Expected list, set or tuple for keys, got {type(keys).__name__}"
1194 )
1195 if len(keys) == len(dsk):
1196 return dsk
1197 work = set(keys)
1198 seen: set[KeyType] = set()
1199 dsk2 = {}
1200 wpop = work.pop
1201 wupdate = work.update
1202 sadd = seen.add
1203 while work:
1204 k = wpop()
1205 if k in seen or k not in dsk:
1206 continue
1207 sadd(k)
1208 dsk2[k] = v = dsk[k]
1209 wupdate(v.dependencies)
1210 return dsk2
1211
1212
1213@functools.cache

Callers 3

cullMethod · 0.90
optimizeFunction · 0.90

Calls 1

setClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…