| 1044 | ) |
| 1045 | |
| 1046 | def __dask_annotations__(self) -> dict[str, dict[Key, object]]: |
| 1047 | # optimization has to be called (and cached) since blockwise fusion can |
| 1048 | # alter annotations |
| 1049 | # see `dask.blockwise.(_fuse_annotations|_can_fuse_annotations)` |
| 1050 | dsk = self._optimized_dsk |
| 1051 | annotations_by_type: defaultdict[str, dict[Key, object]] = defaultdict(dict) |
| 1052 | for layer in dsk.layers.values(): |
| 1053 | if layer.annotations: |
| 1054 | annot = layer.annotations |
| 1055 | for annot_type, value in annot.items(): |
| 1056 | annotations_by_type[annot_type].update( |
| 1057 | {k: (value(k) if callable(value) else value) for k in layer} |
| 1058 | ) |
| 1059 | return dict(annotations_by_type) |
| 1060 | |
| 1061 | def __dask_keys__(self): |
| 1062 | if (keys := self.operand("output_keys")) is not None: |