Simple dask scheduler counting the number of computes. Reference: https://stackoverflow.com/questions/53289286/
| 250 | |
| 251 | |
| 252 | class 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 | |
| 270 | def raise_if_dask_computes(max_computes=0): |
no outgoing calls
no test coverage detected
searching dependent graphs…