MCPcopy
hub / github.com/dask/dask / get

Function get

dask/core.py:86–108  ·  view source on GitHub ↗

Get value from Dask Examples -------- >>> inc = lambda x: x + 1 >>> d = {'x': 1, 'y': (inc, 'x')} >>> get(d, 'x') 1 >>> get(d, 'y') 2

(dsk: Mapping, out: list | Key, cache: MutableMapping | None = None)

Source from the content-addressed store, hash-verified

84
85
86def get(dsk: Mapping, out: list | Key, cache: MutableMapping | None = None) -> Any:
87 """Get value from Dask
88
89 Examples
90 --------
91
92 >>> inc = lambda x: x + 1
93 >>> d = {'x': 1, 'y': (inc, 'x')}
94
95 >>> get(d, 'x')
96 1
97 >>> get(d, 'y')
98 2
99 """
100 for k in flatten(out):
101 if k not in dsk:
102 raise KeyError(f"{k} is not a key in the graph")
103 if cache is None:
104 cache = {}
105
106 dsk2 = convert_legacy_graph(dsk, all_keys=set(dsk) | set(cache))
107 result = execute_graph(dsk2, cache, keys=set(flatten([out])))
108 return _pack_result(result, out)
109
110
111def keys_in_tasks(keys: Collection[Key], tasks: Iterable[Any], as_list: bool = False):

Callers 4

test_quoteFunction · 0.90
scheduling.pyFile · 0.50

Calls 5

convert_legacy_graphFunction · 0.90
execute_graphFunction · 0.90
flattenFunction · 0.85
setClass · 0.85
_pack_resultFunction · 0.85

Tested by 3

test_quoteFunction · 0.72