MCPcopy
hub / github.com/pydata/xarray / CountingScheduler

Class CountingScheduler

xarray/tests/__init__.py:252–267  ·  view source on GitHub ↗

Simple dask scheduler counting the number of computes. Reference: https://stackoverflow.com/questions/53289286/

Source from the content-addressed store, hash-verified

250
251
252class CountingScheduler:
253 """Simple dask scheduler counting the number of computes.
254
255 Reference: https://stackoverflow.com/questions/53289286/"""
256
257 def __init__(self, max_computes=0):
258 self.total_computes = 0
259 self.max_computes = max_computes
260
261 def __call__(self, dsk, keys, **kwargs):
262 self.total_computes += 1
263 if self.total_computes > self.max_computes:
264 raise RuntimeError(
265 f"Too many computes. Total: {self.total_computes} > max: {self.max_computes}."
266 )
267 return dask.get(dsk, keys, **kwargs)
268
269
270def raise_if_dask_computes(max_computes=0):

Callers 1

raise_if_dask_computesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…