(c, s, a, b)
| 448 | |
| 449 | @gen_cluster(client=True) |
| 450 | async def test_annotations_blockwise_unpack(c, s, a, b): |
| 451 | pytest.importorskip("numpy") |
| 452 | da = pytest.importorskip("dask.array") |
| 453 | np = pytest.importorskip("numpy") |
| 454 | from dask.array.utils import assert_eq |
| 455 | |
| 456 | # A flaky doubling function -- need extra args because it is called before |
| 457 | # application to establish dtype/meta. |
| 458 | scale = varying([ZeroDivisionError("one"), ZeroDivisionError("two"), 2, 2]) |
| 459 | |
| 460 | def flaky_double(x): |
| 461 | return scale() * x |
| 462 | |
| 463 | # A reliable double function. |
| 464 | def reliable_double(x): |
| 465 | return 2 * x |
| 466 | |
| 467 | x = da.ones(10, chunks=(5,)) |
| 468 | |
| 469 | # The later annotations should not override the earlier annotations |
| 470 | with dask.annotate(retries=2): |
| 471 | y = x.map_blocks(flaky_double, meta=np.array((), dtype=np.float64)) |
| 472 | with dask.annotate(retries=0): |
| 473 | z = y.map_blocks(reliable_double, meta=np.array((), dtype=np.float64)) |
| 474 | |
| 475 | with dask.config.set(optimization__fuse__active=False): |
| 476 | z = await c.compute(z) |
| 477 | |
| 478 | assert_eq(z, np.ones(10) * 4.0) |
| 479 | |
| 480 | |
| 481 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected