MCPcopy
hub / github.com/dask/dask / test_nested_schedulers

Function test_nested_schedulers

dask/tests/test_callbacks.py:78–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77
78def test_nested_schedulers():
79 class MyCallback(Callback):
80 def _start(self, dsk):
81 self.dsk = dsk
82
83 def _pretask(self, key, dsk, state):
84 assert key in self.dsk
85
86 inner_callback = MyCallback()
87 inner_dsk = {"x": (add, 1, 2), "y": (add, "x", 3)}
88
89 def nested_call(x):
90 assert not Callback.active
91 with inner_callback:
92 return get_threaded(inner_dsk, "y") + x
93
94 outer_callback = MyCallback()
95 outer_dsk = {"a": (nested_call, 1), "b": (add, "a", 2)}
96
97 with outer_callback:
98 get_threaded(outer_dsk, "b")
99
100 assert not Callback.active
101 assert outer_callback.dsk.keys() == outer_dsk.keys()
102 assert inner_callback.dsk.keys() == inner_dsk.keys()
103 assert not Callback.active
104
105
106def test_add_remove_mutates_not_replaces():

Callers

nothing calls this directly

Calls 2

MyCallbackClass · 0.85
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…